Zum Hauptinhalt springen
POST
Start an image upload (get a presigned PUT URL)
Schritt eins des Bild-Uploads. Sende den filename, den content_type (image/jpeg, image/png oder image/webp) und die exakte Dateigröße in size_bytes. Die Antwort gibt 201 Created mit der neuen image_id, einer presigned upload_url (1 Stunde gültig), ihrem expires_at, dem Limit max_bytes und den allowed_content_types zurück. Als Nächstes PUT die rohen Dateibytes an upload_url, mit demselben Content-Type und ohne Authorization-Header:
Rufe dann POST /images/uploads/{image_id}/complete auf.
size_bytes ist erforderlich und muss die exakte Dateigröße sein (höchstens 10.485.760 Bytes): Sie wird in die upload_url signiert, daher wird ein PUT mit jeder anderen Länge abgelehnt. Du kannst höchstens 20 Uploads haben, die auf ihren Abschluss warten; darüber liefert prepare 429 too_many_pending_uploads. Erfordert einen der Scopes images.edit, images.transform oder videos.generate. Kostenlos.

Autorisierungen

Authorization
string
header
erforderlich

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

Body

application/json

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

filename
string
erforderlich

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

Required string length: 1 - 255
content_type
string
erforderlich

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
erforderlich

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.

Erforderlicher Bereich: 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.

Erforderlicher Bereich: x >= 1
height
integer | null

Optional height in pixels (see width).

Erforderlicher Bereich: x >= 1

Antwort

Successful Response

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

image_id
string<uuid>
erforderlich

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

upload_url
string
erforderlich

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

expires_at
string
erforderlich

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

max_bytes
integer
erforderlich

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

allowed_content_types
string[]
erforderlich

The accepted MIME types.