Passer au contenu principal
POST
Start an image upload (get a presigned PUT URL)
Première étape du téléversement d’image. Envoie le filename, le content_type (image/jpeg, image/png ou image/webp) et la taille exacte du fichier dans size_bytes. La réponse renvoie 201 Created avec le nouvel image_id, une upload_url presignée (valable 1 heure), son expires_at, la limite max_bytes et les allowed_content_types. Ensuite, fais un PUT des octets bruts du fichier vers upload_url avec le même Content-Type et sans en-tête Authorization :
Puis appelle POST /images/uploads/{image_id}/complete.
size_bytes est requis et doit être la taille exacte du fichier (au plus 10 485 760 octets) : elle est signée dans upload_url, donc un PUT de toute autre longueur est rejeté. Tu peux avoir au plus 20 uploads en attente de finalisation ; au-delà, prepare renvoie 429 too_many_pending_uploads. Requiert l’un des scopes images.edit, images.transform ou videos.generate. Gratuit.

Autorisations

Authorization
string
header
requis

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

Corps

application/json

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

filename
string
requis

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

Required string length: 1 - 255
content_type
string
requis

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
requis

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.

Plage requise: 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.

Plage requise: x >= 1
height
integer | null

Optional height in pixels (see width).

Plage requise: x >= 1

Réponse

Successful Response

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

image_id
string<uuid>
requis

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

upload_url
string
requis

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

expires_at
string
requis

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

max_bytes
integer
requis

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

allowed_content_types
string[]
requis

The accepted MIME types.