Cancel Fulfillment


Request Details

Item Value
Description The cancel fulfillment API is used when an item from the original purchase will not be fulfilled.
Method DELETE
Endpoint https://pos.crowdtwist.com/fulfillment
HTTP Header X-CT-Authorization = CTApiKey [API Key]
Note: there is a space between CTAPIKey and the API Key value


Request

Field Name Sample Value Required Format Notes
URL PARAMETERSnone
QUERY STRING PARAMETERSnone
HTTP HEADER
API Key QWERTYUIOP Yes String  


Request Body

Field Name Validation Required Format Notes
original_receipt_id Not null Yes String This is the client’s receipt id of the original purchase.
fuflillment_id Not null, unique Yes String For each fulfillment, this is the identifier to give this fulfillment request. This must be unique identifier to this request and it should map to the fulfillment request in the client’s system.
date_fulfilled Not null, ISO-8601 compliant Yes String The date the item is being cancelled. This date must be an ISO-8601 compliant date field with offset appended to it.
items Not null Yes Array This is the array of items to be fulfilled.
ITEMS ARRAY
sku Not null Yes String The SKU string identifier of the item that is being fulfilled.
quantity Not null; greater than zero Yes Integer The number of this item with this SKU is being fulfilled.


Successful Response – Request Body

Field Name Sample Value Required Format Description
receipt_id 18 Yes Integer The purchase receipt that is found that matched the receipt sent in. This is the receipt identifier that is CrowdTwist’s identifier in CrowdTwist’s system
total_points_cancelled 235 Yes Integer The number of points cancelled due to this fulfillment transaction.
user_id 42529648 Yes Integer The user found in our system that matches the user found on the purchase receipt. This user id is the identifier of the user in CrowdTwist’s system.
breakdown
{
  "sku": "SKU_3",
  "date_item_purchased": "2016-06-15T15:42:05"
}
{
  "sku": "SKU_3",
  "date_item_purchased": "2016-06-15T15:42:05"
}
No JSON Array List of items (with 1 quantity) and the points given for each of them through this fulfillment.
BREAKDOWN ARRAY
sku SKU_3 No Integer The sku of the item that was fulfilled.
date_item_purcahsed 2016-06-15T15:42:05 Yes Integer The date that this item was purchased. 


Error Response

Field Name Sample Value Required Format Description
system FulfillmentController Yes String A machine readable code that describes the error.
reason missing_data Yes String Type of error.
description FulfillmentController Yes Missing Data Exception A short, descriptive sentence detailing the error.
message Fulfillment must include original receipt id to process a fulfillment 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, receipt not found, etc.). – missing_data
– not_unique
– receipt_not_found
– quantity_too_large
– sku_not_found
– not_supported (if an endpoint is not supported, a status HTTP code of 405 will be returned)
– 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
– not_configured: error occurs when an configuration has not been configured yet


Sample Request – During Purchase

{
  "fulfillment_id": "fulfillment123",
  "original_receipt_id": "receipt123",
  "date_fulfilled": "2012-04-23T18:25:43.511+00:00",
  "items": [
    {
      "sku": "sku_1",
      "quantity": 2
    },
    {
      "sku": "sku_2",
      "quantity": 1
    }
  ]
}
{
  "fulfillment_id": "fulfillment123",
  "original_receipt_id": "receipt123",
  "date_fulfilled": "2012-04-23T18:25:43.511+00:00",
  "items": [
    {
      "sku": "sku_1",
      "quantity": 2
    },
    {
      "sku": "sku_2",
      "quantity": 1
    }
  ]
}

Sample Successful Response: Status Code 200

{
  "receipt_id": 18,
  "user_id": 12345,
  "total_points_cancelled": 110,
  "breakdown": [
    {
      "sku": "sku1",
      "date_item_purchased": "2017-06-02T13:13:40"
    },
    {
      "sku": "sku2",
      "date_item_purchased": "2017-06-02T13:13:40"
    }
  ]
}
{
  "receipt_id": 18,
  "user_id": 12345,
  "total_points_cancelled": 110,
  "breakdown": [
    {
      "sku": "sku1",
      "date_item_purchased": "2017-06-02T13:13:40"
    },
    {
      "sku": "sku2",
      "date_item_purchased": "2017-06-02T13:13:40"
    }
  ]
}

Sample Error Response: Status Code 400

{
  "system": "FulfillmentController",
  "reason": "missing_data",
  "description": "Missing Data Exception.",
  "message": "Fulfillment must include original receipt id to process a fulfillment."
}
{
  "system": "FulfillmentController",
  "reason": "missing_data",
  "description": "Missing Data Exception.",
  "message": "Fulfillment must include original receipt id to process a fulfillment."
}

Sample Error Response: Status Code 400

{
  "system": "FulfillmentController",
  "reason": "missing_data",
  "description": "Missing Data Exception.",
  "message": "Date fulfilled is missing from the fulfillment request."
}
{
  "system": "FulfillmentController",
  "reason": "missing_data",
  "description": "Missing Data Exception.",
  "message": "Date fulfilled is missing from the fulfillment request."
}

Sample Error Response: Status Code 400

{
  "system": "FulfillmentController",
  "reason": "sku_not_found",
  "description": "Sku Not Avaiable For Fulfillment.",
  "message": "Sku [sku_2] being processed for fulfillment but isn't available for fulfillment."
}
{
  "system": "FulfillmentController",
  "reason": "sku_not_found",
  "description": "Sku Not Avaiable For Fulfillment.",
  "message": "Sku [sku_2] being processed for fulfillment but isn't available for fulfillment."
}