User Code Submit

Request Details

Item Value
Description This endpoint submits a code from a code redemption campaign.
Method POST
Endpoint https://[environment]api[client_id].crowdtwist.com/v2/code_redemption_campaign/submit?api_key=[api_key]&id_type=[id_type]
HTTP Header X-CT-Authorization = CTApiKey [API Key]
Note: There is a space between CTApiKey and the API Key value.
Content Type application/json

Note: Question id’s will change each time a modification is made to the code redemption campaign. Because of this, it is best to make a Code Redemption Campaign call first to determine the ID’s.

Request

Field Name Sample Value Required Format Description
URL PARAMETERSnone
QUERY PARAMETERS
api_key QWERTYP Yes String
id_type email No String Type of ID being sent, defaults to ID if not specified.
Options:
– email
– facebook_user_id
– twitter_user_id
– id (CrowdTwist ID default if blank)
– third_party_id
– username
– mobile_phone_number


Request Body

Field Name

Sample Value

Required

Format

Description

user_id 1 Yes Mixed Unique ID of the user for whom activities will be returned.
campaign_id 23 No Integer ID of code redemption campaign code is submitting to. Either one of the campaign id or campaign group id must be present.
campaign_group_id 1234 No Integer ID of code redemption campaign group code is submitting to.  Either one of the campaign id or campaign group id must be present.
code_value AD8DAB Yes String Code user is submitting.
questions_answers {"45":"Store"} No Object Question-Answers object details. First part represents question id and second represents answer.

Response

Response Body

Field Name Sample Value Required Format Description
num_points 100 Yes Integer On success – the number of points earned for redeeming code.



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 param_error Requested campaign does not exist.
400 invalid_code This code does not exist or can not be redeemed again.
400 questions_required Answers to one or more questions require or the answers are invalid.
403 invalid_auth Invalid access credentials.
404 page_not_found User does not exist.

Samples

Sample Request

curl -X POST 'https://api.crowdtwist.com/v2/code_redemption_campaign/submit?api_key=QWERTYUIOP&id_type=email'

 

Sample Request Body

{ "user_id":"test@crowdtwist.com", "campaign_id": 1234, "code_value": "abc123", "questions_answers": { "7890": "answer text" } }

 

Sample Response Body

{ "num_points": 100 }

 

Sample Error Response

{ "error": "param_error", "message": "Requested campaign does not exist." }