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

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token (Authorization: Bearer sp_...). Created in the dashboard under Account > Tokens. See authentication.

Body

FieldTypeRequiredDescription
partsarrayMultipartOne { "partNumber": n, "etag": "..." } per uploaded part, with the ETag each part’s PUT returned.
fileNamestringYesThe original filename, used as the display name.
fileSizeintegerYesSize in bytes; must be positive, and must match the uploaded file.
folderIdstringNoMedia folder short ID. An unresolvable id leaves the file unfiled rather than failing the call.
notestringNoA note stored with the file (max 200 bytes).
highQualitybooleanNoCompress images at a higher quality setting.
preserveMetadatabooleanNoKeep EXIF and other metadata instead of stripping it.
widthintegerNoClient-measured display width, as a hint (0 to 100000).
heightintegerNoClient-measured display height, as a hint (0 to 100000).
durationMsintegerNoClient-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

CodeMeaning
404The uploadId is not one this API issued, or names an upload that does not belong to your workspace.
409The 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.
409The 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.
409A media file already exists for this upload. Code upload_key_in_use.
422A 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.
400The uploaded file failed validation: its real type is not allowed, or it is larger than the declared fileSize. The file is discarded.
402The file would exceed your storage quota. The file is discarded.
503Storage 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.