API DOCUMENTATION Last Update: Apr 2022

Batch Transactions

Record a batch of transactions for a customer account, including redemptions.

 

The data to be submitted to the API is composed of the following fields:

 

Fields common to all campaign types:

field   Example   Note
API 1.5
user_id john1970 Required
user_api_key 1959caadac9b13dcb3 Required
account_id greatwidgets Required
type batch_transactions Required
Required
delimiter pipe or comma or tab Required
apply_ratio yes or no Optional: See Notes
allow-undo yes Optional: 'yes' or don't include.
send_transaction_email Y Optional: 'Y' or don't include.
Output Format:
output JSON or XML Optional. If not provided, defaults to XML
callback someFunctionName Optional: JSONP format
condensed yes Optional (No white space)
Applies only to JSON(P) output

 

General Notes:

  • If apply_ratio is not given or is set to "no":
    • Points Campaigns:
      • Add transaction: amount = points
      • Redemptions: amount = points
    • Giftcard Campaigns:
      • Add transaction: amount = monetary value.
      • Redemptions: amount = monetary value.
    • Events Campaigns:
      • Add transaction: amount = number of events.
      • Redemptions: amount = number of events.
    • Earned Campaigns:
      • Add transaction: amount = monetary value.
      • Redemptions: amount = monetary value.
    • BuyX Campaings:
      • Add transaction: amount = number of items purchased
      • Redemptions: amount = accumulated items to deduct, NOT: number of items redeemed.
  • If apply_ratio is given as "yes":
    • Points Campaigns:
      • Add transaction: amount = monetary value (which will be converted into points)
      • Redemptions: amount = reward unique_id or reward_id (which will be converted into points)
    • Giftcard Campaigns:
      • (apply_ratio not applicable.)
    • Event Campaigns:
      • Add transaction: amount = number of events.
      • Redemptions: amount = reward unique_id or reward_id (which will be converted into accumulated events to be deducted)
    • Earned Campaigns:
      • Add transaction: amount = events (which will be converted into monetary value)
      • Redemptions: amount = monetary value.
    • BuyX Campaings: amount given will be assumed to be:
      • Purchases: amount = number of items purchased
      • Redemptions: amount = number of items redeemed (which will be converted into accumulated items to be deducted)
  • Unless there's a good reason, don't include the 'allow-undo' = 'yes' directive, otherwise every batch will be listed as an "undo-able" entry in the Manage Customer Records section of the Dashboard.
  • Dates should be provided in ISO format: YYYY-MM-DD (ISO-8601)

 

Fields for Points-Based Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 amount Required: if not used,
leave blank (empty)
visits_header_5 date Required: if not used,
leave blank (empty)
visits_header_6 authorization Required: if not used,
leave blank (empty)
visits_header_7 promo_id Required: if not used,
leave blank (empty)
Visits_Data (see below)
Data to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|14,95|2013-0315|API test import 1|123

1111222233334444|12121|N|50|2010-03-15|API test import 2|345,345,354

1111222233334444|12121|N|34.67|2010-03-15|API test import 3

1111222233334444|12121|N|0,50|2010-03-15|API test import 4

1111222233334444|12121|N|.75|2010-03-15|API test import 5

1111222233334444|12121|N|2.00|2010-03-15|API test import 6

1111222233334444|12121|Y|1500|2010-03-15|API test redeem 1

Notes:

  • 'code' is either
    • the unique Customer ID recored in the 'code' field when the customer account was first created AND there was no 'card_number'), or
    • the 'card_number' of the customer.
  • If date is not given, today's date will be used.
  • If promo_id is used, and multiple given and separated by commas, DO NOT USE comma as delimiter (duh!)

 

Fields for Gift-Card Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 amount Required: if not used,
leave blank (empty)
visits_header_5 date Required: if not used,
leave blank (empty)
visits_header_6 authorization Required: if not used,
leave blank (empty)
Visits_Data (see below)
Data to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|14,95|2010-03-15|API test import 1

1111222233334444|12121|N|34.67|2010-03-15|API test import 2

1111222233334444|12121|Y|49.62|2010-03-15|API test redeem 1

Notes:

  • 'code' is either
    • the unique Customer ID recored in the 'code' field when the customer account was first created AND there was no 'card_number'), or
    • the 'card_number' of the customer.
  • If date is not given, today's date will be used.

 

Fields for Buy-X-Get-One-Free / Membership Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 service_product Required
visits_header_5 amount Required: if not used,
leave blank (empty)
visits_header_6 date Required: if not used,
leave blank (empty)
visits_header_7 authorization Required: if not used,
leave blank (empty)
Visits_Data (see below)
Data to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|Coffees|3|2010-03-15|API test import 1

1111222233334444|12121|N|Cakes|1|2010-03-15|API test import 2

1111222233334444|12121|Y|Coffees|1|2010-03-15|API test redeem 1

Notes:

  • 'code' is either
    • the unique Customer ID recored in the 'code' field when the customer account was first created AND there was no 'card_number'), or
    • the 'card_number' of the customer.
  • If date is not given, today's date will be used.
  • 'service_product' is not the "id" but the "description" of the Item returned by the BuyX Campaign Items List API call. This is because some clients import lists of transaction with items they did not pre-enter in the admin interface. Thus, the import does allows new (service_product) items to be used that have not been pre-defined.
  • The caveat is that each service_product name must be exactly spelled and capitalized the same, usually not an issue when that information is taken from another database or output from a POS or inventory management system.  

 

Fields for Events (Visits) Based Campaigns:

<
  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 date Required: if not used,
leave blank (empty)
visits_header_5 authorization Required: if not used,
leave blank (empty)
visits_header_6 amount If redeemed = Y, otherwise
leave blank (empty)
Visits_Data (see below)
Events to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|2010-03-15|API add event

1111222233334444|12121|N|2010-03-15|API add event

Redemptions to be imported in batch: Single (text) field with <eol>s at end of each line:
1111222233334444|12121|Y|2010-03-15|API redeem|2

Notes:

  • 'code' is either
    • the unique Customer ID recored in the 'code' field when the customer account was first created AND there was no 'card_number'), or
    • the 'card_number' of the customer.
  • If date is not given, today's date will be used.

 

Fields for Earn-per-Event (Visits) Campaigns:

  field   Example   Note
visits_header_1 campaign_id Required
visits_header_2 code Required
visits_header_3 redeemed Required: Y | N
visits_header_4 date Required: if not used,
leave blank (empty)
visits_header_5 authorization Required: if not used,
leave blank (empty)
visits_header_6 amount If redeemed = Y, otherwise
leave blank (empty)
Visits_Data (see below)
Events to be imported in batch: single (text) field with <eol>s at the end of each line:

1111222233334444|12121|N|2010-03-15|API add event

1111222233334444|12121|N|2010-03-15|API add event

Redemptions to be imported in batch: single (text) field with <eol>s at end of each line:
1111222233334444|12121|Y|2010-03-15|API redeem|46.95

Notes:

  • 'code' is either
    • the unique Customer ID recored in the 'code' field when the customer account was first created AND there was no 'card_number'), or
    • the 'card_number' of the customer.
  • If date is not given, today's date will be used.

 

 

Example PHP Request for Points-Based Campaign:

If you are using PHP, the $data array would look like this:

  1. $data['API'] = '1.5';
  2. $data['user_id'] = 'john1970';
  3. $data['user_api_key'] = '1959caadac9a8f7e42938a7b13dcb3';
  4. $data['account_id'] = 'greatwidgets';
  5. $data['type'] = 'batch_transactions';
  6. $data['delimiter'] = 'pipe';
  7. $data['apply_ratio'] = 'yes';
  8. $data['allow-undo'] = 'yes';
  9. $data['visits_header_1'] = 'campaign_id';
  10. $data['visits_header_2'] = 'code';
  11. $data['visits_header_3'] = 'redeemed';
  12. $data['visits_header_4'] = 'amount';
  13. $data['visits_header_5'] = 'date';
  14. $data['visits_header_6'] = 'custom_field_3';
  15. $data['Visits_Data'] = '
  16. 4638472975924871|12121|N|14,95|2010-03-15|API test import 1
  17. 4638472975924871|12121|N|50|2010-03-15|API test import 2
  18. 4638472975924871|12121|N|34.67|2010-03-15|API test import 3
  19. 4638472975924871|12121|N|0,50|2010-03-15|API test import 4
  20. 4638472975924871|12121|N|.75|2010-03-15|API test import 5
  21. 4638472975924871|12121|N|2.00|2010-03-15|API test import 6
  22. 4638472975924871|12121|Y|1500|2010-03-15|API test redeem 1
  23. ';

 

Success XML Response:

  1. <response status="success">
  2. <batch status="all_imported">
  3. <transactions>7</transactions>
  4. </batch>
  5. </response>

 

Error XML Response:

  1. <response status="error">
  2. <error>Error message</error>
  3. </response>