Reward File Upload

Request Details

Item Value
Description The reward file upload API allows upload of supported files to an existing reward.
Method POST
Endpoint https://[environment]api[client_id].crowdtwist.com/v2/reward/[reward_group_id]/upload?api_key=[api_key]
Content Type multipart/form-data

Request

Field Name Sample Value Required Format Description
URL PARAMETERS
reward_group_id 193820 Yes Integer The id of the reward group you wish to add files to.
QUERY PARAMETERS
api_key QWERTYUIOP Yes String  


Request Body

Field Name Sample Value Required Format Description
file Image.jpg Yes String The file you are uploading. Must be a jpg, png, pdf, zip, gif or csv. See below for mapping.
input_field REWARD_IMAGE Yes String The reward field for this file. Must be either “REWARD_IMAGE”, “TOS”, “DOWNLOAD” or “CODE”. See below for mapping.
input_type UPDATE Yes String Whether or not this file is being appended or updated. Must be either “APPEND” or “UPDATE”.
code_type text No String

“text” or “url”, how the code should be displayed to the member.

Note: Only present for CODE reward type.

Accepted and Mapped "file" Field Extensions

Input Field Accepted File Extensions
REWARD_IMAGE jpg, png, gif
TOS pdf
DOWNLOAD jpg, png, zip, gif, pdf
CODE UTF-8 csv

Accepted and Mapped "input_type" Field Values

Input Field Accepted File Extensions
REWARD_IMAGE

UPDATE: Replaces the current associated reward image(s) with the newly provided file.

APPEND: Adds the newly provided reward image to the reward image (max 5).

TOS

UPDATE: Replaces the current associated terms-of-service with the newly provided file (if one is present).

APPEND: Not accepted.

DOWNLOAD

UPDATE: Replaces the current associated digital download with the newly provided file (if one is present).

APPEND: Not accepted.

CODE

UPDATE: Removes all existing codes from the reward, replacing them with the newly provided codes.

APPEND: Adds the newly uploaded codes to the existing code list.

Response

Response Body

Field Name Sample Value Required Format Description
file_id 06888601f3cb7ac1d9a92ffe1127bc00453d8b41 Yes String The CrowdTwist file id.
reward_title T-shirt Yes String The title of the reward.


Error Responses

Field Name Sample Value Required Format Description
error Field value is empty. Yes String This is a short form of the error.
message Value of field [fieldname] must not be empty. Yes String This is a detailed message around the error specifying, as specifically as possible, what the fields are that are missing or where exactly the error is.


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, receipt not found, etc.). – missing_data
– not_unique
– receipt_not_found
– invalid_amount
– invalid_currency
– invalid_date
– invalid_custom_field
– invalid
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
– missing_field
– invalid_data
– not_configured: error occurs when an configuration has not been configured yet


Example Response Codes

Response Code Error Message
400 file_type_invalid File must be a [list of valid type] file.
400 reward_not_found Page not found.
400 file_too_large File exceeds 5MB.
400 invalid_input_type Append operation is not valid for TOS files.
400 invalid_input_type An invalid input_type was provided.
400 invalid_input_field Only REWARD_IMAGE and TOS are allowed for [input_field].
400 image_limit_exceeded At most 6 images can be added to a reward.
400 input_error Field [field] is required.
400 no_file_sent No file passed in file parameter.
400 multiple_files_sent Only one file may be sent in each request.

Samples

Sample Request Body - Standard Rewards

{ "file": "TEST.jpg", "input_field": "REWARD_IMAGE", "type": "UPDATE" }


Sample Response Body

{ "file_id": "5123745558914880", "reward_title": "T-shirt" }


Sample Error Response: Status Code 400 – Non-image for Reward Image

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


Sample Error Response: Status Code 400 – Non-PDF for Terms of Service

{ "error": "file_type_invalid", "message": "File must be one of [application/pdf]." }


Sample Error Response: Status Code 400 – Incorrect Field Name

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