Skip to main content

POST Presigned URL to Upload File

Overview


The following table contains important information about the POST method in regards to the upload process with presigned url.

POST Method
MethodPOST
URL or Endpoint/api/projects/projectId/uploads/url
HeadersAuthorization
ParametersprojectId
BodyCheck the request body below.

The description of the URL parameter is as follows:

projectId URL Parameter
URL Parameter NameprojectId
MandatoryYes
Typestring
DescriptionUnique identifier for project

Request Body​

{
"fileName": "{fileName}",
"contentLength": 0,
"mimeType": "{mimeType}",
"contentType": "{contentType}",
"enableDuplicateCheck": false,
"fileHash": "{fileHash}",
"author": "{author}",
"presignedUrlExpiryTimeHours": 0
}

Information about the fields that appear when you request the body of the video are displayed in the table below.

Field NameMandatoryTypeDescription
fileNameYesstringName of the file.
mimeTypeNostringType of the file.
contentTypeNostringContent type of the file.
contentLengthNointegerLength of the file (in bytes).
enableDuplicateCheckNobooleanDetermines whether duplicate upload should be disallowed.
fileHashNostringThe hash of the file to be uploaded.
Required if enableDuplicateCheck is true.
authorNostringAuthor of the upload. Trimmed, at most 200 characters. Stored with the upload and returned on this response and on GET Presigned URL to View File. It cannot be changed afterwards. Required when the project setting uploadRequiresAuthor is on, see PATCH Project Settings.
presignedUrlExpiryTimeHoursNointegerPresigned URL expiry time in hours. Value must be between 1 and 168. If sent as null or omitted, it defaults to 12 hours.
info

If the enableDuplicateCheck field is set to true and fileHash is provided, the system will check for existing files with the same file hash and prevent them from being uploaded again. If set to false or omitted, duplicates will be allowed.

Important: This field should be enabled for both the initial upload and any subsequent uploads. If not enabled initially, the system will not perform the duplicate check, and duplicates will be allowed, even if the file hash is the same.

Author-scoped duplicate check: when the project setting enforceUploadOwnership is on, a file hash only matches uploads that carry the same author (trimmed, case-insensitive). A request without an author only matches uploads without an author. With the setting off, the check matches any upload of the project with the same hash, as before.

Author on uploads

The optional author identifies who owns the uploaded file. When the project setting enforceUploadOwnership is on, an encode request that references this upload must carry the same author (compared trimmed and case-insensitively), otherwise it is rejected with 403 UPLOAD_AUTHOR_MISMATCH. See the POST Video documentation.

When the project setting uploadRequiresAuthor is on, a request without author (or with a blank one) is rejected with 400 UPLOAD_AUTHOR_REQUIRED before anything is created.

Response​

If the action is successful, the service sends back an HTTP 200 response.

{
"success": true,
"errors": [],
"messages": [],
"result": {
"uploadFileDetailsId": 0,
"url": "{url}",
"requestKey": "{requestKey}",
"filePath": "{filePath}",
"author": "{author}"
},
"resultInfo": null,
"statusCode": 200
}

Information about the fields that appear when you request the body of the video are displayed in the table below.

Parameter NameTypeDescription
successboolIf the response is successful, it will return true. Otherwise, it will return false.
errorsarray[string]Indicates if there was an error.
messagesarray[string]Returns the response message from the back-end.
resultobjectReturns the response object.
uploadFileDetailsIdinteger($int32)The ID of upload file details.
urlstringThe URL where the resource can be accessed.
requestKeystringA unique key associated with the request.
filePathstringThe file path of the resource.
authorstringThe author stored with the upload, or null when none was sent.
resultInfostringReturns extra information about the result.
statusCodeinteger($int32)Returns the HTTP Status Code.

202 Accepted​

The endpoint may return HTTP 202 when the request is accepted for asynchronous processing. Example response:

{
"success": true,
"errors": [],
"messages": [],
"result": {
"uploadFileDetailsId": 0,
"requestKey": "{requestKey}"
},
"resultInfo": "string",
"statusCode": 202
}
note

A 202 response does not indicate failure; it indicates that the upload request was accepted but the file is not yet fully processed. Common scenarios include:

  • File Upload Initiation: If a filehash collision occurs and the server cannot confirm that the original file upload was completed (endpoint POST /api/projects/{projectId}/uploads/success/{requestKey} was not called), the initiation will return 202 Accepted with the existing requestKey (indicating the upload is pending completion).

Errors​

For information about the errors that are common to all actions, see Common Errors:

  • HTTP Status Code 400: Bad Request

    Returned with the fixed code UPLOAD_AUTHOR_REQUIRED when the project setting uploadRequiresAuthor is on and the request carries no author:

{
"success": false,
"errors": ["UPLOAD_AUTHOR_REQUIRED"],
"messages": [],
"result": null,
"resultInfo": "This project requires an author on every upload.",
"errorCode": "UPLOAD_AUTHOR_REQUIRED",
"statusCode": 400
}
  • HTTP Status Code 401: Unauthorized

  • HTTP Status Code 403: Forbidden

  • HTTP Status Code 404: Result Not Found

  • HTTP Status Code 409: Conflict

{
"success": true,
"errors": [],
"messages": [],
"result": {
"uploadFileDetailsId": "{uploadFileDetailsId}",
"requestKey": "{requestKey}"
},
"resultInfo": null,
"statusCode": 409,
}
  • HTTP Status Code 410: Gone

  • HTTP Status Code 500: Internal Server Error

  • HTTP Status Code 503: Backend Fetch Failed