Vai al contenuto principale
POST
Start an image upload (get a presigned PUT URL)
Passaggio uno del caricamento di immagini. Invia il filename, il content_type (image/jpeg, image/png o image/webp) e la dimensione esatta del file in size_bytes. La risposta restituisce 201 Created con il nuovo image_id, un upload_url presigned (valido 1 ora), il suo expires_at, il limite max_bytes e gli allowed_content_types. Poi fai il PUT dei byte grezzi del file su upload_url con lo stesso Content-Type e senza header Authorization:
Poi chiama POST /images/uploads/{image_id}/complete.
size_bytes è obbligatorio e deve essere la dimensione esatta del file (al massimo 10,485,760 byte): è firmata in upload_url, quindi un PUT di qualsiasi altra lunghezza viene rifiutato. Puoi avere al massimo 20 upload in attesa di completamento; oltre, prepare restituisce 429 too_many_pending_uploads. Richiede uno qualsiasi degli scope images.edit, images.transform o videos.generate. Gratuito.

Autorizzazioni

Authorization
string
header
obbligatorio

Organization API key (Authorization: Bearer samsa_sk_...) or OAuth 2.1 access token (Authorization: Bearer samsa_at_...).

Corpo

application/json

POST /images/uploads/prepare body — describe the file you will PUT.

filename
string
obbligatorio

Original filename. Stored as the image name; never used as the storage key.

Required string length: 1 - 255
content_type
string
obbligatorio

MIME type of the file — one of: image/jpeg, image/png, image/webp. Send the SAME value as the Content-Type header of the PUT; complete refuses bytes that are a different format.

size_bytes
integer
obbligatorio

The EXACT size of the file in bytes (at most 10485760). It is signed into upload_url: a PUT of any other length is rejected by storage. curl --data-binary @file sends the file's real length.

Intervallo richiesto: 1 <= x <= 10485760
width
integer | null

Optional width in pixels. Only used to refuse an image over the 32 MP limit early; the stored dimensions are measured from the uploaded bytes at complete.

Intervallo richiesto: x >= 1
height
integer | null

Optional height in pixels (see width).

Intervallo richiesto: x >= 1

Risposta

Successful Response

201 body for POST /images/uploads/prepare — where and how to PUT the file.

image_id
string<uuid>
obbligatorio

The new image's id. Send it to POST /images/uploads/{image_id}/complete after the PUT.

upload_url
string
obbligatorio

Presigned URL. PUT the raw file bytes here with the header Content-Type: <content_type> (no Authorization header).

expires_at
string
obbligatorio

UTC instant (ISO 8601) after which upload_url stops accepting the PUT (1 hour after prepare).

max_bytes
integer
obbligatorio

Largest accepted file size in bytes; complete refuses a bigger file.

allowed_content_types
string[]
obbligatorio

The accepted MIME types.