Skip to content

Create a bucket

POST/v1/asset-buckets

Queues a new bucket and returns 202 Accepted with the operation_id of the create operation. The bucket starts in provisioning and moves to ready (or failed) when the operation finishes. Poll Get an operation or List buckets to see when it is ready. Uploads, access keys and CORS changes are only accepted once the bucket is ready.

Things to know:

  • Bucket names must be unique in the workspace. Uniqueness is checked on the slug of the name, so Marketing Assets and marketing-assets clash.
  • visibility defaults to public. It cannot be changed after creation.
  • The underlying S3 bucket name (s3_bucket_name) is generated for you from the workspace slug and the bucket's ID.
  • Send X-Idempotency to make retries safe. Repeating a create with the same key returns the original operation with 200 OK and is_replay: true, and no second bucket is created. The key is checked first, before the past-due check and validation. Reusing it for a different action returns 409 with action: idempotency_key_reused.
  • Past-due or suspended accounts cannot create buckets (402, action: past_due).

Requires the resource write permission (owner, admin or developer role).

Authentication

Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.

Headers

X-Workspace-SlugstringRequired

Slug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.

X-Idempotencystring

Optional key that makes retries safe. Repeating a request with a key already used for the same action returns the original operation with 200 OK and is_replay: true instead of queuing it again. Reusing it for a different action or bucket returns 409 with action: idempotency_key_reused.

Request body

namestringRequired

Display name of the bucket. Leading and trailing spaces are trimmed. Its slug must be unique among the workspace's buckets.

visibilitystring

public serves objects from a public URL. private requires a signed URL to read objects. Case-insensitive.

Default publicOne ofpublicprivate

Response

202

The create operation was queued.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
operation_idstringRequired

ID of the queued operation. Pass it to Get an operation.

bucketobjectRequired
Show attributes
uidstringRequired

Unique identifier of the bucket.

namestringRequired

Display name of the bucket.

slugstringRequired

URL-safe version of the name. Unique within the workspace.

statusstringRequired

Lifecycle state. Uploads, access keys and CORS changes need ready.

One ofprovisioningreadyfaileddeletingdeleted

visibilitystringRequired

public objects are served from their public URL. private objects need a signed read URL.

One ofpublicprivate

public_base_urlstringRequired

Base URL recorded for the bucket on the public assets host. Use each object's public_url or read_url to fetch objects, rather than building URLs from this value.

s3_bucket_namestringRequired

Name of the underlying S3 bucket. Use it as the bucket name with S3 clients.

key_prefixstring

Key prefix under which uploads made through the API are stored. Omitted when it cannot be derived.

storage_used_bytesinteger

Total size of the bucket's ready objects, in bytes. Omitted when zero.

free_storage_bytesinteger

Your account's free file storage allowance in bytes. Omitted on some responses (for example after updating allowed origins or deleting).

max_image_size_bytesinteger

Maximum size of a single upload, in bytes. Despite the name it applies to every file type. Omitted on some responses.

created_atstring (date-time)Required

When the bucket was created.

last_failurestring

Why the last create or delete failed. Omitted when there was no failure.

cors_originsarray of stringsRequired

Browser origins allowed to make cross-origin requests. The console's own origin is always allowed and is not listed. Set with Set bucket allowed origins.

statusstringRequired

Status of the operation. queued for a new request; the original operation's current status on a replay.

One ofqueuedrunningsucceededfailed

events_urlstringRequired

Path of the operation's progress event stream.

is_replaybooleanRequired

true when an X-Idempotency key was reused and the original operation is returned instead of a new one.

is_completedboolean

true when a replayed operation has already finished. Omitted unless true.

Response

200

Replay. The X-Idempotency key was already used for this action, so the original operation is returned and nothing is queued. status is the operation's current status. bucket is the bucket's current state, or only uid, slug and status: deleted once it is gone.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
operation_idstringRequired

ID of the queued operation. Pass it to Get an operation.

bucketobjectRequired
Show attributes
uidstringRequired

Unique identifier of the bucket.

namestringRequired

Display name of the bucket.

slugstringRequired

URL-safe version of the name. Unique within the workspace.

statusstringRequired

Lifecycle state. Uploads, access keys and CORS changes need ready.

One ofprovisioningreadyfaileddeletingdeleted

visibilitystringRequired

public objects are served from their public URL. private objects need a signed read URL.

One ofpublicprivate

public_base_urlstringRequired

Base URL recorded for the bucket on the public assets host. Use each object's public_url or read_url to fetch objects, rather than building URLs from this value.

s3_bucket_namestringRequired

Name of the underlying S3 bucket. Use it as the bucket name with S3 clients.

key_prefixstring

Key prefix under which uploads made through the API are stored. Omitted when it cannot be derived.

storage_used_bytesinteger

Total size of the bucket's ready objects, in bytes. Omitted when zero.

free_storage_bytesinteger

Your account's free file storage allowance in bytes. Omitted on some responses (for example after updating allowed origins or deleting).

max_image_size_bytesinteger

Maximum size of a single upload, in bytes. Despite the name it applies to every file type. Omitted on some responses.

created_atstring (date-time)Required

When the bucket was created.

last_failurestring

Why the last create or delete failed. Omitted when there was no failure.

cors_originsarray of stringsRequired

Browser origins allowed to make cross-origin requests. The console's own origin is always allowed and is not listed. Set with Set bucket allowed origins.

statusstringRequired

Status of the operation. queued for a new request; the original operation's current status on a replay.

One ofqueuedrunningsucceededfailed

events_urlstringRequired

Path of the operation's progress event stream.

is_replaybooleanRequired

true when an X-Idempotency key was reused and the original operation is returned instead of a new one.

is_completedboolean

true when a replayed operation has already finished. Omitted unless true.

Errors

StatusMeaning
400Validation failed. Possible messages: invalid request (malformed JSON or missing name), name is required (blank after trimming), visibility must be public or private.
401The API key is missing, invalid, expired or revoked.
402The account is past due, so new paid resources cannot be created.
403You cannot access the workspace, your role does not allow this action, or the account is suspended.
409A bucket with the same name (slug) already exists in this workspace, or the X-Idempotency key was already used for a different action (action: idempotency_key_reused).

Errors use the standard error format.