Upload an imageMenu

Upload an image

POST/v1/assets

Requires an API key with the templates:write scope. About keys and scopes

Works with integration, agent and partner keys. Also available to embed sessions.

A repeat without a key does it again; send Idempotency-Key and a retry within 24 hours replays the first response. About idempotency

Uploads one PNG, JPEG or GIF of at most 2 MB and 25 megapixels for image blocks, as a multipart part named file, with an optional name for the library (the file's name otherwise). The request sample shows a complete upload. The returned url is public and stable, so it can go straight into a template. A retry with the same Idempotency-Key and the same file replays the first response; a different file under that key is 409 IDEMPOTENCY_KEY_REUSED.

Header parameters

Kirora-Workspacestringoptional

Partner keys only: the child workspace to act in, by the external id the partner gave it. Without it, a partner key acts in its own workspace. Any other key that sends it is refused with 403, and an unknown workspace is 404.

pattern ^[A-Za-z0-9._:-]{1,128}$

Idempotency-Keystringoptional

Makes a retry safe: a repeat with the same key and body within 24 hours gets the first response again, with Idempotency-Replay: true. The same key with another request is 409 IDEMPOTENCY_KEY_REUSED; while the first is still running, 409 IDEMPOTENCY_KEY_IN_USE; after an unsafe first request failed or never returned, 409 IDEMPOTENCY_KEY_OUTCOME_UNKNOWN. Use a new key, such as a UUID, for each new request.

8–255 characters

Request body

filestringrequired

A PNG, JPEG or GIF of at most 2097152 bytes.

binary · content type image/png, image/jpeg or image/gif · up to 2,097,152 bytes

namestringoptional

The name the library shows, up to 200 characters; the file's name when omitted.

1–200 characters

Returns

Returns 201 Created with an Asset in data. It can also return 409 Conflict, 413 Payload Too Large or 415 Unsupported Media Type; see the statuses below. Otherwise returns an error; Errors lists every code and which to retry.

  • 201 CreatedThe uploaded image and its public URL.
  • 409 ConflictThe request conflicts with current state — a duplicate unique value, or a resource whose status does not allow this operation.
  • 413 Payload Too LargeThe body is larger than this operation accepts (PAYLOAD_TOO_LARGE).
  • 415 Unsupported Media TypeThe body is not JSON, or not the upload the operation takes (UNSUPPORTED_MEDIA_TYPE).
idstringrequired

uuid

typestringrequired

The kind of file: image. More kinds, such as video, may be added: branch on type and keep the ones you do not know.

one of image

namestringrequired

The name the library shows.

filenamestringrequired

The file's name as uploaded or copied.

urlstringrequired

The file's public address, such as an image src.

uri

mimeTypestringrequired

The file's format.

one of image/png, image/jpeg, image/gif

sizeBytesintegerrequired

File size in bytes.

min > 0

widthintegerrequired

The file's width in px.

min > 0

heightintegerrequired

The file's height in px.

min > 0

createdAtstringrequired

date-time

Headers on 201 Created

Idempotency-Replaystringoptional

true when this is the stored response to an earlier request with the same key.

one of true