Create bucket use

Hello. I’m trying to create bucket in my task, use function.
I referred to this topic: How am I able to create and drop buckets in Tasks?
and use post function like this:

import "http"
import "json"
    url: "http://localhost:8086/api/v2/buckets",
    headers: {
        Authorization: "Token {my token}",
        "Content-type": "application/json"
    data: json.encode(v: {
        "name": "TestBucket",
        "orgID": {myOrg},
        "retentionRules": [{
                "everySeconds": 86400,
                "shardGroupDurationSeconds": 0,
                "type": "expire"
        "schemaType": "implicit"

But influxdb returns error “failed to unmarshal json: id must have a length of 16 bytes”.
When I check InfluxDB 2.0 api document, “id” doesn’t need at bucket create request body.
What am I missing?

Hello @tendo_aris,
You might find the following useful:

This worked for me:

curl --location --request POST '' \
--header 'Authorization: Token {{mytoken}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"orgID": "{{my org ID}}",
"name": "test-bucket",
"description": "This is an example",
"rp": "string",
"retentionRules": [
"type": "expire",
"everySeconds": 86400,
"shardGroupDurationSeconds": 0
"schemaType": "implicit"

I am running into the very same problem. I try to create a bucket via the SWIFT SDK (sample from github) and also using the curl call from above or trying from postman, but all times it fails with the error:

“code”: “invalid”,
“message”: “failed to unmarshal json: id must have a length of 16 bytes”

the only difference is that I use the following url:

Any idea how to solve the problem??

Thanks Armin

Hello @Woworsky,
What did you use as your org ID?
It should be the actual id that you can find under your profile, not your email or org name.

Hello @Anaisdg
Thanks for the hint to use orgID and not orgName. My fault, it works now.