API: POST Receipt Data

Description

Send receipt details which includes payment details, items details, and location information to a RESTful API. If you are unable to provide a value for a field that is not required, do not send in that field. Do not send in a NULL or blank value.

URL

POST api.banyan.com/rest/v1/receipt

Authentication

This as a restricted resource that requires an authentication token. See the API Authentication guide for details.

Headers

As we said above, you will use the token you receive in your header call to the POST Receipt endpoint.

Header NameDescriptionRequiredValues
Authorization: BearerAccess TokenRequiredSee Authorization section
Content-TypeThe receipt format to sendOptionalapplication/JSON
AcceptThe response format sent backOptionalapplication/JSON

Example:

curl -v -s -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://api.banyan.com/rest/v1/version"

POST Body

Top Level Objects

ElementDescriptionTypeRequiredNotes
merchant_receipt_idUnique to the transactionstringRequired
purchase_tsWhen the purchase occurredRFC3339RequiredTimestamp is in UTC, example: 2021-01-28T14:43:50.52Z
currencyAlphabetic currency code associated with the value in ISO 4217 format.stringOptionalDefault is USD
consumer_tokenA hashed token that is unique to the household or consumerstringOptional
order_typeLocation of where the transaction took placestringOptionalValid values include {web, in_store, phone, third_party_delivery}
merchant_total_amountThe full amount on the receiptstringOptionalIncludes cash back for debit transactions
barcode_urlThe URL to the image of a receipt barcodestringOptional
merchant_midThe merchant id provided by the acquiring bankstringOptional
fulfillment_typeHow the items are received by the customerstringOptionalValid values include {in_store, shipped, delivered, pick_up}
image_urlThe URL to the image of the receiptstringOptional
custom_fieldA customizable key value pair field used for passing data on to an enriched transactionstringOptional

Payment Object
Each payment used on the receipt is a different object in the array

ElementDescriptionTypeRequiredNotes
paymentsAn array of paymentsTop Level ObjectRequired
payment_typeWhether the payment was in cash, gift card, debit or creditstringOptional
schemeIf debit or credit, what network is the card onstringOptionalValid values include Mastercard, Visa, Discover and American Express. Please format it as {'AX', 'DS', 'MC', 'OR', 'PP', 'VI'} where OR is "other" and 'PP' is Paypal
card_last_fourThe last four digits on a debit or credit cardstringOptional
total_amountThe total amount per payment per receiptstringRequired
tip_amountThe total amount of tip on the paymentstringOptional
tax_amountThe total amount of tax on the paymentstringOptional
subtotal_amountThe total amount of the items without discounts, taxes, tip, shippingstringOptional
shipping_amountThe amount of shipping cost on the paymentstringOptional
cash_back_amountThe amount received from debit/EBT card as cash from tellerstringOptional
other_positive_amountsAny additional amounts included in the total amount that are not specifiedarray of stringsOptional
other_negative_amountsAny negative amounts included in the total amount that are not specifiedarray of stringsOptional
authorization_codeSix digit alphanumeric code passed between banks that signal a transaction is possiblestringOptional
arnA unique number that tags a credit or debit card transaction when it goes from the merchant’s bank through to the cardholder's bank.stringOptionalonly available on credit card transactions from visa and mastercard
is_virtualWhether the card sent is a virtual card/wallet or a standard credit cardboolOptionalonly available for credit/debit transactions

Item Object
Each item on the receipt is its own object in the array

ElementDescriptionTypeRequiredNotes
itemAn array of itemstop level objectRequired
merchant_item_idUnique id represented on the receiptstringOptionalThis number will help with QA efforts to know that Banyan has the complete receipt information
upcUniversal product codestringOptional
skuUnique id to the merchantstringOptional
image_urlUrl of an image of the itemstringOptional
brandBrand of the itemstringOptional
descriptionItem descriptionstringOptional
amount_paidQuantity multiplied by Discount Price Per UnitstringRequiredIf an item is returned, this should be a negative number
quantitynumber of itemsstringOptionalIf an item is returned, this should be a negative number
full_price_per_unitThe list price of the item before discountsstringOptional
discount_price_per_unitThe amount paid for the item, can be less than the full pricestringOptional
tagCustom field used to add further descriptions of itemsarray of stringsOptionale.g., category:|:beauty

Merchant Object

ElementDescriptionTypeRequiredNotes
merchantElements pertaining to the location of the purchasetop level objectOptional
nameThe internal name of the storestringOptionalE.g., ABC Store #23
display_nameDeprecatedstringDeprecatedDeprecated

Location Object

ElementDescriptionTypeRequiredNotes
locationElements pertaining to the address of the store where the purchase took placetop level objectOptional
nameThe legal / listed name of the store of the purchasestringOptional
display_nameThe banner name of the store of the purchasestringOptional

Location.Address Object

ElementDescriptionTypeRequiredNotes
address_line_oneStreet address of the storestringOptional
address_line_twoAdditional address informationstringOptional
cityCity of the storestringOptional
stateState of the storestringOptional
countryCountry of the storestringOptionalISO 3066-1, Alpha 2 format preferred
postal_codePostal code of the storestringOptionalNeeds to be 5 characters in length

Sample Request

For the most up to date sample request, please see the API Reference

POST http://api.banyan.com/rest/v1/receipt
Bearer: {token_id}
Content-Type: application/json
Accept: application/json

{
  "merchant_receipt_id": "c2143ffb-63c4-442c-b152-816bdc3ca7dc",
  "purchase_ts": "2023-02-10T14:54:57.603Z",
  "merchant": {
    "name": "Rachel Bedding Test",
    "display_name": "Rachel Bedding Test"
  },
  "location": {
    "name": "RachelBeddingTest",
    "display_name": "RachelBeddingTest",
    "phone_number": "439-571-0756",
    "address": {
      "address_line_one": "32949 Plains bury",
      "city": "Lockmantown",
      "state": "Louisiana",
      "country": "USA",
      "postal_code": "85726"
    }
  },
  "order_type": "in_store",
  "fullfilment_type":"in_store",
  "currency": "usd",
  "merchant_total_amount": "25",
  "payments": [
    {
      "total_amount": "25",
      "payment_type": "credit",
      "scheme": "Elo",
      "bin": "638413",
      "card_last_four": "6664",
      "auth_code": "407200",
      "arn": "523763351",
      "subtotal_amount": "23",
      "tax_amount": "2",
      "tip_amount": "0",
      "cash_back_amount": "0"
    }
  ],
  "items": [
    {
      "merchant_item_id": "123",
      "upc": "22222222222222",
      "brand": "BrandD",
      "description": "Sheet Detergent",
      "amount_paid": "25",
      "full_price_per_unit": "25",
      "discount_price_per_unit": "25",
      "quantity": "1",
      "tags": [
                "category_description:|:Bedding",
                "brand:|:BrandD",
                "subclass_desc:|:Detergent"
            ]
    }
  ],
  "merchant_consumer_token": "222222222222",
  "image_url": "https://nielsen.com/receipt/image/898577492124",
  "barcode_url": "https://nielsen.com/receipt/barcode/898577492124"
}

Response

ElementDescriptionTypeNotes
byn_receipt_idThe ID of the receipt generated by BanyanstringThis is what to use when using the GET method on /receipt

Sample Response

{
    "data": [
        {
            "byn_receipt_id": "41863f4c-a5dc-53b6-9fcb-44e8b57c4af7"
        }
    ],
    "errors": []
}

Status Codes and Errors

The receipt will be validated upon delivery, and if there is an error, we will report it in our request response. Errors can also be seen in the API Reference

CodeDescriptionNotes
200SuccessA record was written to the /receipt resource
400Bad RequestThis error code will come with a brief description of what needs to be changed such as a data type or unknown field name
404Not FoundNot authorized to view data
500Internal Server Error