Upload an image as an asset
POST/assets
Stores one image (PNG, JPEG or WebP, at most 20 MB) as a new asset of the key's account. Send multipart/form-data with the image in the file part, plus exactly one of productId or brandId (a file with no product) and an optional name. The 201 is a small AssetUpload body, not the asset read shape: a brand-level file is not visible to GET /assets. The type is read from the file itself, not from the declared content type. Idempotency-Key is required: a retry with the same key and the same file returns the same asset and stores nothing new. The returned assetId can be attached to a chat turn.
Request
Responses
- 201
- 400
- 401
- 403
- 404
- 409
- 413
- 415
- 422
- 429
- 503
Created. The new asset (or the replay of an earlier upload with this key).
Bad Request. The Idempotency-Key header is missing (IDEMPOTENCY_KEY_REQUIRED) or malformed (INVALID_IDEMPOTENCY_KEY).
Unauthorized. Missing, malformed, unknown, revoked, or expired bearer token — or the token owner no longer holds the required entitlement (ENTITLEMENT_LOST). A uniform problem body is returned with a distinct code; no owner/condition detail (no-leak).
Forbidden. The key lacks the assets:write scope (API_TOKEN_SCOPE_DENIED).
Not Found (PRODUCT_NOT_FOUND or BRAND_NOT_FOUND). The productId or brandId is not one of the key's account's: another account's, a deleted one and a missing one answer the same.
Conflict. A request under this key is still in progress (IDEMPOTENCY_IN_PROGRESS, retry after Retry-After); or the key was already used for a different request (IDEMPOTENCY_KEY_REUSED).
Response Headers
Seconds to wait before retrying — on IDEMPOTENCY_IN_PROGRESS only.
Payload Too Large (PAYLOAD_TOO_LARGE). The file is over 20 MB. Nothing was stored.
Unsupported Media Type (UNSUPPORTED_MEDIA_TYPE). The file's own bytes are not a PNG, JPEG or WebP image. Nothing was stored.
Unprocessable Content (VALIDATION_ERROR). The file part is missing, neither or both of productId and brandId were sent, or a field is malformed.
Too Many Requests. Either the per-key window of 30 uploads/minute was exceeded (a plain-text body), or this server is already receiving as many uploads as it can (UPLOAD_BUSY, a problem+json body). Retry the SAME request after Retry-After. Nothing was stored.
Response Headers
IETF draft-7 rate-limit policy/state (limit, remaining, reset).
Seconds to wait before retrying.
Service Unavailable (WRITES_PAUSED). Writes are paused for this account right now. Nothing was changed and the Idempotency-Key was not consumed, so retry the SAME request after Retry-After. Reads are unaffected.
Response Headers
Seconds to wait before retrying.