Finish a direct upload
Finish the flow started by POST /uploads. This assembles a multipart upload, checks the uploaded file, and adds it to the media library. Until it succeeds the file is not in the library and cannot be referenced from a page.
POST https://sitepaste.com/api/v1/public/uploads/{uploadId}/complete
Requires the media scope.
Usage
curl -X POST https://sitepaste.com/api/v1/public/uploads/Um8ZBMuFXwQYTp_yiuJT0Hnck8RDZAEzpog/complete \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"fileName": "field-recording.mp4",
"fileSize": 734003200,
"parts": [
{ "partNumber": 1, "etag": "\"a1b2...\"" },
{ "partNumber": 2, "etag": "\"c3d4...\"" }
]
}'
Authorizations
| Header | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token (Authorization: Bearer sp_...). Created in the dashboard under Account > Tokens. See authentication. |
Body
| Field | Type | Required | Description |
|---|---|---|---|
| parts | array | Multipart | One { "partNumber": n, "etag": "..." } per uploaded part, with the ETag each part’s PUT returned. |
| fileName | string | Yes | The original filename, used as the display name. |
| fileSize | integer | Yes | Size in bytes; must be positive, and must match the uploaded file. |
| folderId | string | No | Media folder short ID. An unresolvable id leaves the file unfiled rather than failing the call. |
| note | string | No | A note stored with the file (max 200 bytes). |
| highQuality | boolean | No | Compress images at a higher quality setting. |
| preserveMetadata | boolean | No | Keep EXIF and other metadata instead of stripping it. |
| width | integer | No | Client-measured display width, as a hint (0 to 100000). |
| height | integer | No | Client-measured display height, as a hint (0 to 100000). |
| durationMs | integer | No | Client-measured duration in milliseconds, as a hint. Must not be negative. |
siteId and pageId, which set the file’s protection, are sent to POST /uploads, not here.
Response
201 Created with the stored file, and a Location header naming it in the media library:
{
"url": "https://media.example.com/media/.../f8e2a1b3c4d5.webp",
"filename": "f8e2a1b3c4d5.webp",
"mimeType": "image/webp",
"sizeBytes": 184320,
"width": 1600,
"height": 1067
}
url is what you reference from page content. An unprotected file gets an absolute URL. A protected file’s URL is a /media/... path that opens only for visitors who can open a page that shows it. The filename and type can differ from what you uploaded: images are converted, and the file gets a new name. A video that is still being transcoded also carries transcodeStatus. Its url works immediately and changes when transcoding finishes. Its filename does not change, so the Location and the media routes keep working through the transcode.
Errors
| Code | Meaning |
|---|---|
| 404 | The uploadId is not one this API issued, or names an upload that does not belong to your workspace. |
| 409 | The upload has already been completed. Code upload_already_completed. The body carries the fileId of the file the first completion made and Location names it under /media, so a retry that lost the first answer can carry on with that file. Nothing is charged. |
| 409 | The upload holds no bytes yet, because the client never sent them or the upload was aborted. Code upload_incomplete, message no uploaded bytes found for this upload; send the file before completing it. Send the file, then complete it. |
| 409 | A media file already exists for this upload. Code upload_key_in_use. |
| 422 | A field is missing or invalid: note over 200 bytes, width or height out of range, a negative durationMs, or parts sent on a direct upload, which has no parts to assemble. fields names them. |
| 400 | The uploaded file failed validation: its real type is not allowed, or it is larger than the declared fileSize. The file is discarded. |
| 402 | The file would exceed your storage quota. The file is discarded. |
| 503 | Storage is unavailable, so the upload cannot be completed. Nothing is written; retry later. |
Rate limiting
This route spends from the upload budget of 600 a minute, which it shares with POST /media and nothing else. Only a request that could actually finish an upload is charged, so an unknown upload id or a malformed body costs nothing. Use this flow for a bulk import.