File Upload

Request Details

Item Value
Description The File Upload API is used to send CrowdTwist a file
Method POST
Endpoint https://[environment]api[client_id].crowdtwist.com/v2/upload?api_key=[api_key]
Content Type multipart/form-data

Request

Field Name Sample Value Required Format Notes
URL PARAMETERSnone
QUERY STRING PARAMETERS
api_key QWERTYUIOP Yes String


Request Body

Field Name Sample Value Required Format Notes
file clip_image00455.jpg Yes .jpg / .jpeg / .png / .gif / .pdf File under 6MB in size

Response

Response Body

Field Name Sample Value Required Format Description
file_id 5123745558914880 Yes String ID of the file stored in CrowdTwist’s datastore


Error Responses

Field Name Sample Value Required Format Description
error input_error yes string The type of rest API error.
message Uploaded file is not an image or PDF yes string A longer, descriptive sentence detailing the error.


Error Response Codes

Error Error Code Description Reason
Input Error 4xx Returned whenever the request is missing required fields, including situations in which the body is malformed (e.g. HTTP method not supported, etc.). -uploaded file is not an image or PDF
-uploaded file too large
-File upload failed.
Forbidden 4xx Returned whenever a request is attempting a forbidden action -file in request not an uploaded file
Server Error 5xx HTTP error status code is returned due to an error that occurred in the backend. – internal_error: unexpected error occurred in the CrowdTwist backend

Samples

Sample Request

POST /v2/upload?api_key=key HTTP/1.1 Host: api.crowdtwist.com Cache-Control: no-cache Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="clip_image00455.jpg" Content-Type: image/jpeg ------WebKitFormBoundary7MA4YWxkTrZu0gW--


Sample Response Body

{ "file_id": "5123745558914880" }


Sample Error Response: Status Code 400 – Incorrect File Type

{ "error": "file_type_invalid", "message": "File must be one of [application/pdf, image/png, image/jpeg, image/gif, image/tiff]." }


Sample Error Response: Status Code 400 – File size too large

{ "error": "file_too_large", "message": "File exceeds 6MB." }


Sample Error Response: Status Code 400 – Incorrect Field Name

{ "error": "invalid_file", "message": "The provided file is invalid." }