Purchase


Request Details

Item Value
Description Allows a client to record a purchase within our platform. This API is used for clients with the CrowdTwist Purchase V1 integration.
Method POST
Endpoint https://api.crowdtwist.com/v2/purchases?api_key=[api_key]
Content Type: JSON (application/json)


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
date_purchase 1339383080   UNIX Timestamp Date of the purchase
loc_id 21     Location identifier. This parameter is used to tie multiple purchases to the same location.
receipt_id 3M8D5EUSH68     Receipt ID of the purchase.
shipping 15.50     Total shipping costs.
tax 12.30     Total order tax.
total $123     Total amount of the purchase. (All items combined)
items [{
  “id”:930,”quantity”:2,
  “cost”:14.99
},{
  “id”:931,”quantity”:1,
  “cost”:44.99
}]
  Array List of items in the purchase.
ITEM OBJECT
id abc1234   String product id
quantity 2     Quantity of product purchased
price 19.99     Price of product purchased
OPTIONAL PARAMETERS
loc_address_1       Address of the location.
loc_address_2       Address of the location.
loc_address_3       Address of the location.
loc_description       Description of the purchase location.
loc_lat       Latitude of the purchase location.
loc_long       Longitude of the location.
user_id       User ID of the purchaser.


Successful Response

Field Name Sample Value Required Format Description
status message Yes String Status
message purchase created successfully Yes String A short, descriptive sentence detailing the status.


Error Response

Field Name Sample Value Required Format Description
error param_error Yes String Missing the user_id parameter.
message Missing the user_id parameter. Yes String A short, descriptive sentence detailing the error.


Error Response Codes

Error Message
input_error The input provided in invalid or formatted incorrectly.
internal_error Something went wrong on our end.
page_not_found The requested page does not exist or has been removed.
param_error A missing or invalid parameter is included in the request.


Sample Request

curl -X POST
https://api.crowdtwist.com/v2/purchases?api_key=QWERTYUIOP
{
  "receipt_id": "3M8D5EUSH68",
  "items": [
    {
      "id": 930,
      "quantity": 2,
      "cost": 14.99
    },
    {
      "id": 931,
      "quantity": 1,
      "cost": 44.99
    }
  ],
  "loc_id": "21",
  "date_purchase": 1339383080,
  "shipping": "144.99",
  "tax": 144.99,
  "total": 144.99
}
curl -X POST
https://api.crowdtwist.com/v2/purchases?api_key=QWERTYUIOP
{
  "receipt_id": "3M8D5EUSH68",
  "items": [
    {
      "id": 930,
      "quantity": 2,
      "cost": 14.99
    },
    {
      "id": 931,
      "quantity": 1,
      "cost": 44.99
    }
  ],
  "loc_id": "21",
  "date_purchase": 1339383080,
  "shipping": "144.99",
  "tax": 144.99,
  "total": 144.99
}


Sample Successful Response: Status Code 200

{
  "message": "purchase created successfully"
}
{
  "message": "purchase created successfully"
}

Sample Error Response: Status Code 400

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