Upload

Media never goes through the API origin as raw bytes. Request a presigned URL, PUT the file to S3, then pass the returned taskId into client.jobs.createJob().

Request a URL

$curl -X POST \
> https://api.segmentationapi.com/v1/uploads/presign \
> -H "Content-Type: application/json" \
> -H "Authorization: Bearer YOUR_SEGMENTATION_API_KEY" \
> -d '{"contentType": "image/png"}'
1const upload = await client.uploads.createUploadPresign({ contentType: "image/png" });

The JSON body and PresignUploadResponse fields are in the API reference. The URL expires after expiresIn seconds (300 by default).

PUT the file

$curl -X PUT "$UPLOAD_URL" \
> -H "Content-Type: image/png" \
> --data-binary "@frame-0001.png"
1await fetch(upload.uploadUrl, {
2 method: "PUT",
3 headers: { "content-type": "image/png" },
4 body: pngBytes,
5});

The Content-Type on the PUT must match the contentType you presigned. A mismatch is a 403 from S3.

Formats

Common, well-tested types:

TypeMIME types
Imagesimage/png, image/jpeg, image/webp
Videovideo/mp4, video/quicktime, video/webm, video/x-matroska

Any image/* or video/* MIME type is accepted. The type you presign with is the type your PUT must send.