Introduction

Heartland Retail provides a full-featured REST API to users. The API can be used to fetch data, integrate with other products, or build custom applications on top of the POS.

All URL paths are relative to an account-specific subdomain: https://{{subdomain}}.retail.heartland.us/api/

Have a suggestion for a correction or improvement to our API docs? Please open an issue on GitHub.

Client Libraries

Here are some client libraries to make interacting with our API easier:

Don't see your language? You can still interact with our API using a general purpose HTTP library.

Want your client library listed here? Open an issue on GitHub.

OAuth

OAuth2 is a protocol that lets external applications request authorization to private details in a user's Heartland Retail account without getting their password. OAuth tokens can be limited to specific data (see Scopes), and can be revoked by users at any time. You'll need to register your application before getting started.

A registered app is assigned a unique Client ID and Client Secret which will be used in the OAuth flow. The Client Secret should not be shared.

To register your application please submit a request.

OAuth Flow

1.) Requesting authorization

Redirect the user to to this URL to request access to their Heartland Retail account on your behalf:

https://retail.heartland.us/oauth/authorize

The following values should be passed as query string parameters:

Name Type Description
client_id String Required. The client ID you received from Heartland Retail when you registered.
scope String Required. A space delimited list of requested permissions. See Scopes.
redirect_uri String The URL in your app where users will be sent after authorization.
state String Random string to be passed back upon completion. It is used to protect against cross-site request forgery attacks.

2.) Issuing an access token

If the user authorizes your app, Heartland Retail will redirect back to your specified redirect_uri with a temporary code in a code GET parameter, as well as a state parameter if you provided one in the previous step. If the states don't match, the request may have been created by a third party and you should abort the process.

Exchange this for an access token: GET https://retail.heartland.us/api/oauth/token

Name Type Description
client_id String Required. The client ID you received from Heartland Retail when you registered.
client_secret String Required. The client secret you received from Heartland Retail when you registered.
code String Required. The code you received as a response to Step 1
grant_type String Required. The grant type of this flow is authorization_code
redirect_uri String Required. The URL you passed in Step 1

You'll receive a JSON response containing an access_token:

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ",
  "token_type": "bearer"
}

3.) Looking up the account's hostname

Interaction with the Heartland Retail API is always done through a hostname particular to each company's account. After receiving the access_token for the account you need to perform a one time lookup of the account's hostname.

To receive the account's host send a request with the received access_token to the following URL:

GET https://retail.heartland.us/api/system/host
Authorize: Bearer {{ access_token }}

Response:

{"host": "example.retail.heartland.us"}

This host value should be used to construct the base URL for future API calls for that Heartland Retail account.

4.) Using access token and host

The access token allows you to make requests to the API on a behalf of a user. All requests must be performed using the host retrieved from the previous step.

GET https://{{ host }}/api/system/whoami
Authorize: Bearer {{ access_token }}

Scopes

Name Description
cash_drawer.close Close cash drawer
cash_drawer.manage Manage cash drawers
cash_drawer.open Open cash drawer
cash_paid.create Create cash paid out/in transactions
cash_paid.read View cash paid out/in history
custom_field.manage Manage custom fields
customer.export Export customers
customer.manage Create and manage customers
customer.merge Merge customers
customer.read View customers
financial.event.read View financial events
financial.manage Manage financial configuration
gift_card.manage Manage gift cards and adjust balances
grid_templates.manage Manage grid templates
integrations.manage Manage integrations
inventory.adjustment.manage Manage adjustments
inventory.adjustment.read View adjustments
inventory.bin.manage Update bin locations
inventory.counts.create Create physical counts
inventory.counts.finalize Review discrepancies and accept physical counts
inventory.counts.acknowledge_discrepancies Acknowledge discrepant counts
inventory.threshold.manage Edit item reorder points and target quantity
inventory.transaction.read View inventory history
inventory.transfer.read View transfers
inventory.transfer.recall_shipment Recall transfer shipments
inventory.transfer.receive Receive transfers
inventory.transfer.resolve_discrepancies Resolve transfer discrepancies
inventory.transfer.select_from_shipment Select receipt items from transfer shipment
inventory.transfer.ship Ship transfers
inventory.values.read View current inventory values
inventory.vendor.read View inventory vendor information
item.create_on_fly Create items on the fly
item.export Export items
item.manage Manage items and grids
item.merge Merge items
item.view_cost View item cost and margin information
location.manage Manage locations
location.read View locations
payment.manage Manage payments
payment.read View payments
payment_type.manage Manage payment types
pos.manage Manage POS settings
purchasing.order.manage Manage orders
purchasing.order.read.canceled View canceled orders
purchasing.order.read.closed View closed orders
purchasing.order.read.open View open orders
purchasing.order.read.pending View pending orders
purchasing.order.read View all orders
purchasing.receipt.manage Manage receipts
purchasing.receipt.read View receipts
purchasing.receipt.select_from_order Select receipt items from purchase order
purchasing.receipt.acknowledge_unauthorized_quantities Acknowledge unauthorized receipt quantities
purchasing.return.manage Manage returns
purchasing.return.read View returns
purchasing.vendor.manage Manage vendors
purchasing.vendor.read View vendors
reason_codes.manage Manage reason codes
reporting.modify Reporting Analysis
reporting.read.group.custom_payment Group reports by custom payment type
reporting.read.group.customer Group reports by customer
reporting.read.group.date Group reports by date
reporting.read.group.gift_card Group reports by gift card payments
reporting.read.group.inventory_adjustment Group reports by inventory adjustment reason
reporting.read.group.inventory_transfer Group reports by inventory transfer
reporting.read.group.item Group reports by item
reporting.read.group.location Group reports by location
reporting.read.group.payment Group reports by payment type
reporting.read.group.promotion_name Group reports by promotion name
reporting.read.group.purchasing Group reports by purchase order
reporting.read.group.sales_transaction Group reports by sales transaction
reporting.read.group.tax_rule Group reports by tax rule
reporting.read.group.time Group reports by time
reporting.read.group.vendor Group reports by vendor
reporting.read.group Group reports
reporting.read.metric.beginning_gift_card View beginning gift card balances
reporting.read.metric.beginning_inventory View beginning inventory values
reporting.read.metric.current_inventory View current inventory values
reporting.read.metric.ending_gift_card View ending gift card balances
reporting.read.metric.ending_inventory View ending inventory values
reporting.read.metric.gift_cards_expired View gift card expirations
reporting.read.metric.inventory_adjustment View inventory adjustment metrics
reporting.read.metric.inventory_transfer View transfer metrics
reporting.read.metric.location_sales_gift_cards View location sales gift cards issued metrics
reporting.read.metric.location_sales View location sales metrics
reporting.read.metric.payment View payment type metrics
reporting.read.metric.purchasing View purchasing metrics
reporting.read.metric.sales_tax View sales tax metrics
reporting.read.metric.shipping View shipping metrics
reporting.read.metric.source_sales_gift_cards View source sales gift cards issued metrics
reporting.read.metric.source_sales View source sales metrics
reporting.read.metric Group by metric
reporting.read View reporting
reporting.sales.read Read sales dashboard reports
reporting.saved_reports.manage Manage Saved Reports
reporting.saved_reports.read View Saved Reports
role.manage Manage roles
sales.coupons.manage Manage coupons
sales.coupons.read View and redeem coupons
sales.daily_summary.read View Daily Summary
sales.invoice.manage Create and fulfill invoices from sales orders
sales.order.adjust_item_price Adjust item prices on a sales order
sales.order.distribute Distribute sales orders
sales.order.edit Create and edit sales orders
sales.order.manage Manage sales orders
sales.order.view View sales orders
sales.pos.adjust_tax_amount Adjust tax amount in the POS
sales.promotions.manage Manage promotions
sales.tax.manage Manage sales tax
sales.ticket.manage Manage POS tickets
sales.transaction.adjust_item_price Adjust item prices in the POS
sales_plans.manage Manage sales plans
setting.manage Manage general settings
shipping_method.manage Manage shipping methods
station.manage Manage stations
user.manage Manage users
ui_extensions.manage Manage UI extensions
webhooks.manage Manage Webhooks
pos_pre_complete_webhooks.manage Add or remove POS Pre Complete Webhooks

Authentication

Accessing the Heartland Retail API requires a secret API token. You can manage your API keys in the API Tokens page. To access the API Tokens page in Heartland Retail click the name in the top right corner of the Heartland Retail dashboard. A drop down menu will open, you can now click "my account" to bring you to your account page. Then click "API" to bring you to API Tokens page.

Generating an API Token:

  1. Click the "Generate new token" button. This will bring you to the "New API Token" page.
  2. Type in a description for the API Token.
  3. Click the "Generate Token" button.
  4. API Token will appear. Be sure to copy your new API token now. You won’t be able to see it again.
  5. Click the "Done" button.

Each HTTP request to the API should include an Authorization header with the API token. Example:

curl -H "Authorization: Bearer {{token}}"

Permissions

Each user in Heartland Retail is assigned a role. These roles have configurable permissions. It is important to note that once you are authenticated your API calls will be limited to the set of actions allowed by your permissions.

If you are making API requests and getting 401 Unauthorized responses you may want to check your permissions via GET /api/system/whoami

Request:
require 'heartland-retail'
client = HeartlandRetail::Client.new(
  'https://{{subdomain}}.retail.heartland.us/api',
  token: '{{token}}'
)
curl -H "Authorization: Bearer {{token}}" "https://{{subdomain}}.retail.heartland.us/api/system/whoami"
Response:
true
{"id": 100001, "login": "login", "first_name": "", "last_name": ""}

Search Results

Search results objects are simple wrappers around result sets that indicate the total number of records that match the request, the number of pages available, and an array containing the results for the current page.

There are two query parameters that alter how what is returned in via search results:

  • page - which page in the results set to retrieve.
  • per_page - how many records to return in each page.

Search Results

total:
Integer

Total number of records returned by the search

pages:
Integer

The number of pages of results

results:
Array

A list of result objects

Filtering

Filtering

Collection resources can be filtered in several ways:

Full-Text Queries

Full text queries perform fuzzy searching across all indexed text fields (which fields exactly varies by collection). Partial word matches are support from the beginning of a term.

/api/items?query=big+blue+thing
/api/items?query=startswi

Filters

Advanced filters use a JSON-encoded query language. This can be specified in one of two ways:

  1. Encoded as query string parameter hash (for convenience)
  2. As a JSON encoded string (for more complex queries)

In each case the value is passed via the _filter parameter or the shorthand ~ parameter. Both parameter names are equivalent.

Using query string parameters

Queries up to a certain level of complexity can be expressed directly as query string parameters. This is useful for constructing ad-hoc queries in a browser:

/api/items?~[price][$gt]=100&~[price][$lt]=200

Resulting pseudo-SQL:

(price > 100 AND price < 100)

Using JSON

For arbitrarily complex queries it is recommended that the filters be encoded as a JSON string.

Here is an example of a complex query using nested logical operators and multiple comparison operators:

JSON:

{
  "$or": [
    {"price": {"$gte": 10, "$lte": 20}},
    {"price": 0},
    {"$and": [
      {"cost": 0},
      {"updated_at": {"$gt": "2012-01-01"}}
    ]}
  ],
  "active": true,
  "tax_category": {"$in": ["c1", "c2", "c3"]}
}

URL-encoded:

/api/items?_filter[]=%7B%22$or%22:[%7B%22price%22:%7B%22$gte%22:10,%22$lte%22:20%7D%7D,%7B%22price%22:0%7D,%7B%22$and%22:[%7B%22cost%22:0%7D,%7B%22updated_at%22:%7B%22$gt%22:%222012-01-01%22%7D%7D]%7D],%22tax_category%22:%7B%22$in%22:[%22c1%22,%22c2%22,%22c3%22]%7D,%22active%22:true%7D

Resulting pseudo-SQL:

(
  ((price >= 10) AND (price <= 20))
  OR (price = 0)
  OR ((cost = 0) AND (updated_at > '2012-01-01'))
)
AND (tax_category IN ('c1', 'c2', 'c3'))
AND (active IS TRUE)

Comparison Operators

  • $eq - Equals
  • $neq - Not equals
  • $in - In array
  • $nin - Not in array
  • $gt - Greater than
  • $gte - Greater than or equals
  • $lt - Less than
  • $lte - Less than or equals
  • $like - Like (see Like Queries)

Like Queries

Like queries use * as a wildcard. The wildcard character must be specified somewhere to get partial match behavior. If no wildcard is specified, $like behaves as $eq. Like queries are case insensitive.

  • Starts with: /api/items?~[custom@color][$like]=blue*
  • Ends with: /api/items?~[custom@color][$like]=*blue
  • Contains: /api/items?~[custom@color][$like]=*blue*

Logical Operators

Logical operators can be arbitrarily nested.

  • $and - Group array of nested expressions with logical AND
  • $or - Group array of nested expressions with logical OR

Custom Fields

Custom fields can be used in any filter expression with this syntax:

/api/items?~[custom@color]=blue
/api/items?~[custom@score][$gt]=100

Filtering Null Values

Checking for null or non-null values can be done using the $eq/$neq operators and the JSON syntax:

{
  "custom@category": {"$eq": null},
  "description": {"$neq": null}
}

Resulting pseudo-SQL:

(custom@category IS NULL) AND (description IS NOT NULL)

Filtering with references to other fields

To compare fields to other fields rather than literal values use a string with the field name wrapped in double curly-braces (e.g. {{field_name}}).

{
  "qty_shipped": {"$gt": "{{qty_received}}"}
}

Resulting pseudo-SQL:

(qty_shipped > qty_received)

Embedding

It is possible to embed the contents of associated objects in an API response using one or more _include[] query string parameters.

For example, to retrieve an object that has a my_object_id property (or any property ending in _id), you can embed the related my_object data like this:

GET /api/some-resource/1234?_include[]=my_object

The response will look something like this:

{
  "id": 1234,
  "my_object_id": 5678,
  "my_object": {
    "id": 5678,
    "description": "Object Description"
  }
}

Reporting

Reporting API

GET /api/reporting/analyzer

Params

metrics[] (required)

An array of metrics to include in the output (see Metrics section). Must specify at least one.

groups[] (optional)

An array of dimension fields to group by (see Groups section).

start_date (optional), end_date (optional)

An ISO 8601 formatted date string (date only, no time). This is used as the start/end date for any metric that has a date dimension.

sales.filters, item.filters, location.filters (optional)

A JSON filter expression (see Filtering doc for syntax) to filter the item, location, or sale records to include when computing metrics.

subtotal (optional, default: false)

If set to true, the response will include rows for subtotals at each grouping level (see groups[]). Setting to true without specifying any groups[] will result in an error.

Each result object will include an additional subtotal_level property. Its value will be null for each non-subtotal result. For the subtotals, its value will be an integer corresponding to the index in the groups[] param array.

For example, given the following groups:

location.name, item.custom@group, item.custom@category

These would be the corresponding subtotal_level property values:

Subtotal Groups Subtotal Level
location.name, item.custom@group 2
location.name 1
Grand Total 0

Metrics

Source Sales

Supported groups: item.*, location.*, customer.*, date.*, time.*

  • source_sales.net_sales
  • source_sales.net_qty_sold
  • source_sales.net_markdowns
  • source_sales.net_margin
  • source_sales.net_margin_ratio
  • source_sales.gross_sales
  • source_sales.gross_qty_sold
  • source_sales.gross_returns
  • source_sales.gross_qty_returned
  • source_sales.transaction_count
  • source_sales.customer_count
  • source_sales.item_count

Location Sales

Supported groups: item.*, location.*, customer.*, date.*, time.*

  • location_sales.sellthrough
  • location_sales.inventory_turn
  • location_sales.net_sales
  • location_sales.net_qty_sold
  • location_sales.net_markdowns
  • location_sales.net_margin
  • location_sales.net_margin_ratio
  • location_sales.gross_sales
  • location_sales.gross_qty_sold
  • location_sales.gross_returns
  • location_sales.gross_qty_returned
  • location_sales.transaction_count
  • location_sales.customer_count
  • location_sales.item_count

Beginning Inventory

Supported groups: item.*, location.*

Required params: start_date

  • beginning_inventory.qty_owned
  • beginning_inventory.cost_owned
  • beginning_inventory.price_owned
  • beginning_inventory.qty_on_po
  • beginning_inventory.price_on_po
  • beginning_inventory.qty_committed
  • beginning_inventory.cost_committed
  • beginning_inventory.price_committed
  • beginning_inventory.qty_in_transit
  • beginning_inventory.cost_in_transit
  • beginning_inventory.price_in_transit
  • beginning_inventory.qty_on_hand
  • beginning_inventory.cost_on_hand
  • beginning_inventory.price_on_hand
  • beginning_inventory.qty_available
  • beginning_inventory.cost_available
  • beginning_inventory.price_available

Ending Inventory

Supported groups: item.*, location.*

Required params: end_date

  • ending_inventory.qty_owned
  • ending_inventory.cost_owned
  • ending_inventory.price_owned
  • ending_inventory.qty_on_po
  • ending_inventory.price_on_po
  • ending_inventory.qty_committed
  • ending_inventory.cost_committed
  • ending_inventory.price_committed
  • ending_inventory.qty_in_transit
  • ending_inventory.cost_in_transit
  • ending_inventory.price_in_transit
  • ending_inventory.qty_on_hand
  • ending_inventory.cost_on_hand
  • ending_inventory.price_on_hand
  • ending_inventory.qty_available
  • ending_inventory.cost_available
  • ending_inventory.price_available

Shipping

Supported groups: locations.*

  • shipping.net_shipping_income

Payments

Supported groups: locations.*, payments.*, credit_card_payments.*

  • payment.payment_type_count
  • payment.credit_card_type_count
  • payment.payments_received
  • payment.refunds
  • payment.net_payments

Groups

NOTE: Some metric/group combinations are invalid. See the metric sections for a list of supported grouping levels. An invalid combination of metrics and groups will result in an error. For example, it's not possible to compute inventory values grouped by customer since inventory levels inherently have no customer dimension.

Item

  • item.public_id
  • item.description
  • item.custom@*key*

Customer

  • customer.public_id
  • customer.first_name
  • customer.last_name
  • customer.email
  • customer.custom@*key*

Location

  • location.public_id
  • location.name

Date

  • date.date
  • date.year
  • date.month_of_year
  • date.month_of_year_name
  • date.week_of_year
  • date.week_of_year_name
  • date.day_of_week
  • date.day_of_week_name

Time

  • time.time
  • time.hour

Payment

  • payment.type

Credit Card Payment

  • credit_card_payment.type

Inventory

Inventory APIs control everything related to items in the system, their inventory values, adjusting inventory, and transfering inventory between locations

Adjustment Set

A adjustment set is a record of items that have been or will be adjusted.

Inventory Adjustment Set

id:
integer (auto-generated)
adjustment_reason_id:
integer (required)
location_id:
integer (required)
note:
text
status:
text (required)
created_by_user_id:
integer (auto-generated)

The user who created this record

updated_by_user_id:
integer (auto-generated)

The most recent user who updated this record

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

Inventory Adjustment Set Line

id:
integer (auto-generated)
adjustment_set_id:
integer (required)
item_id:
integer (required)
qty:
integer (required)
unit_cost:
numeric(10,2) (required)
created_by_user_id:
integer (auto-generated)

The user who created this record

updated_by_user_id:
integer (auto-generated)

The most recent user who updated this record

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

Inventory Adjustment Set Example:
{
  "id": 100028,
  "adjustment_reason_id": 103502,
  "location_id": 100864,
  "created_by_user_id": 100113,
  "updated_by_user_id": 100006
}
Inventory Adjustment Set Line Example:
{
  "id": 101735,
  "adjustment_set_id": 108287,
  "item_id": 105326,
  "qty": 105501,
  "unit_cost": 70.88,
  "created_by_user_id": 101217,
  "updated_by_user_id": 101181
}

Create an adjustment set

POST /api/inventory/adjustment_sets

Creating an adjustment set requires an adjustment reason id and a location id. The location id is used to determine where the adjustment set will be applied.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"adjustment_reason_id":100717,"location_id":102597}' "https://{{subdomain}}.retail.heartland.us/api/inventory/adjustment_sets"
client["inventory/adjustment_sets"]
  .post({"adjustment_reason_id"=>108030, "location_id"=>103372})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/inventory/adjustment_sets/173941

Retrieve an adjustment set

GET /api/inventory/adjustment_sets/{{adjustment_set_id}}

An adjustment set is retrieved using its unique identifier. This identifier can be found by searching for adjustment sets, from references in other records, or from the Location header returned in response to the creation of a new adjustment set.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/adjustment_sets/{{adjustment_set_id}}"
client["inventory/adjustment_sets/{{adjustment_set_id}}"]
  .get.body
Response:
{
  "id": 100624,
  "adjustment_reason_id": 101283,
  "location_id": 108244,
  "created_by_user_id": 103634,
  "updated_by_user_id": 107135
}
{"id"=>109573,
 "adjustment_reason_id"=>106410,
 "location_id"=>106293,
 "created_by_user_id"=>103418,
 "updated_by_user_id"=>108061}

Retrieve an adjustment set's lines

GET /api/inventory/adjustment_sets/{{adjustment_set_id}}/lines

An adjustment set has zero or more associated lines.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/adjustment_sets/{{adjustment_set_id}}/lines/?per_page=1"
client["inventory/adjustment_sets/{{adjustment_set_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 107187,
      "adjustment_set_id": 106050,
      "item_id": 101961,
      "qty": 106912,
      "unit_cost": 83.73,
      "created_by_user_id": 105680,
      "updated_by_user_id": 103875
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>109337,
    "adjustment_set_id"=>107893,
    "item_id"=>100203,
    "qty"=>105247,
    "unit_cost"=>80.81,
    "created_by_user_id"=>103493,
    "updated_by_user_id"=>109554},
   "..."]}

Add an item to an adjustment set

POST /api/inventory/adjustment_sets/{{adjustment_set_id}}/lines

Adds an item with the given qty to the adjustment set. This method can also be used to increment the quantity of an existing item line.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"adjustment_set_id":102269,"item_id":106988,"qty":108293,"unit_cost":43.91}' "https://{{subdomain}}.retail.heartland.us/api/inventory/adjustment_sets/{{adjustment_set_id}}/lines"
client["inventory/adjustment_sets/{{adjustment_set_id}}/lines"]
  .post({"adjustment_set_id"=>106209, "item_id"=>107574, "qty"=>101212, "unit_cost"=>93.83})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/inventory/adjustment_sets/13965/lines/155987

Search adjustment sets

GET /api/inventory/adjustment_sets

Adjustment sets can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/adjustment_sets/?per_page=1"
client["inventory/adjustment_sets"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 105426,
      "adjustment_reason_id": 105042,
      "location_id": 101130,
      "created_by_user_id": 101525,
      "updated_by_user_id": 101699
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>107413,
    "adjustment_reason_id"=>101669,
    "location_id"=>100468,
    "created_by_user_id"=>104250,
    "updated_by_user_id"=>105785},
   "..."]}

Items

The items resource exposes the ability to create and modify items in the Heartland Retail system. The vast majority of item APIs make use of the item record type:

Item

id:
integer (auto-generated)
public_id:
text

The unique public identifier for this item. This can be used to provide your own naming scheme to your inventory. Items can be searched for using this value.

metadata:
text

a placeholder for custom data (deprecated)

cost:
numeric(10,2) (required)

The default cost of purchasing this item

price:
numeric(10,2) (required)

The default sales price

description:
text

A short description of the item.

long_description:
text

A long description of the item

custom:
hash

An object that acts as a container for custom values defined in Heartland Retail as well as any arbitrary values stored by integrations or custom applications.

active:
boolean

Whether or not this record is currently active and being used

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

financial_class_id:
integer

The id of the financial class this item belongs to.

weight:
numeric(10, 2)

The weight of the tem

width:
numeric(10, 2)

The width of the item

height:
numeric(10, 2)

The height of the item

depth:
numeric(10, 2)

The depth of the item

import_batch_id:
integer (computed)

If this item was imported or modified by an import this attribute references the import batch that brought this item into the system or updated it most recently.

primary_vendor_id:
integer

The id for the primary vendor record that supplies this item.

Item Example:
{
  "id": 106114,
  "cost": 59.46,
  "price": 80.18,
  "financial_class_id": 106785,
  "import_batch_id": 104275,
  "primary_vendor_id": 102337
}

Create an item

POST /api/items

Items are created by POSTing an item record containing the required attributes to the /api/items resource. When successful, the response headers will contain a Location header that indicates the url at which the newly created item can be found. The item's unique id will be the last portion of that URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"cost":66.67,"price":98.94}' "https://{{subdomain}}.retail.heartland.us/api/items"
client["items"]
  .post({"cost"=>23.19, "price"=>39.55})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/items/190402

Retrieve an item

GET /api/items/{{item_id}}

Items are retrieved from the Heartland Retail API via their unique id. The id can be found via searches, references from other records, or from the Location header in a Create Item response.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/items/{{item_id}}"
client["items/{{item_id}}"].get.body
Response:
{
  "id": 104462,
  "cost": 24.93,
  "price": 55.86,
  "financial_class_id": 100787,
  "import_batch_id": 108148,
  "primary_vendor_id": 109370
}
{"id"=>103783,
 "cost"=>59.69,
 "price"=>36.69,
 "financial_class_id"=>109917,
 "import_batch_id"=>105339,
 "primary_vendor_id"=>101938}

Update an item

PUT /api/items/{{item_id}}

Items can be edited by PUTting an item record containing a valid subset of item attributes to the item's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"cost":69.41,"price":22.61,"financial_class_id":108288,"import_batch_id":105804,"primary_vendor_id":108675}' "https://{{subdomain}}.retail.heartland.us/api/items/103562"
client["items/{{item_id}}"]
  .put(my_item_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Search items

GET /api/items

Items can be searched by GETting the root of the items resource /api/items. This API call will result in a search result record containing zero or more item records in the values attribute. See Search Results for more information on search results.

Items can be filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/items/?per_page=1"
client["items"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 104865,
      "cost": 48.1,
      "price": 28.32,
      "financial_class_id": 105678,
      "import_batch_id": 109051,
      "primary_vendor_id": 108143
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>105130,
    "cost"=>37.53,
    "price"=>37.67,
    "financial_class_id"=>106847,
    "import_batch_id"=>107774,
    "primary_vendor_id"=>102353},
   "..."]}

Merge items

POST /api/items/{{item_id}}/merges

If you have duplicate items and would like to combine them into one item you can do so using the merges API. This will combine their open inventory quantities, inventory histories, and sales histories.

The base item specified in the URL is considered the "master" item. Include an array of slave_ids in the request body. These "slave" items will be deleted after having their data combined into the master.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"slave_ids":[100002,100003]}' "https://{{subdomain}}.retail.heartland.us/api/items/{{item_id}}/merges"
client["items/{{item_id}}/merges"]
  .post({"slave_ids"=>[100002, 100003]})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/items/159202/merges/142090

Item Grids

The items resource exposes the ability to create and modify items in the Heartland Retail system. The vast majority of item grids APIs make use of the item record type:

Item Grid

id:
integer (auto-generated)
metadata:
text

a placeholder for custom data

description:
text (required)

A short description of the item.

long_description:
text

A long description of the item

item_cost:
numeric(10,2)

The default cost of purchasing this item

item_price:
numeric(10,2)

The default sales price

item_original_price:
numeric(10,2)

The original sales price

item_custom:
hash

An object that acts as a container for custom values defined in Heartland Retail as well as any arbitrary values stored by integrations or custom applications.

active:
boolean

Whether or not this record is currently active and being used

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

item_financial_class_id:
integer

The id of the financial class this item belongs to.

item_primary_vendor_id:
integer

The id for the primary vendor record that supplies this item.

Item Grid Example:
{
  "id": 108303,
  "item_cost": 63.3,
  "item_price": 43.0,
  "item_original_price": 42.28,
  "item_financial_class_id": 104846,
  "item_primary_vendor_id": 108274
}

Create an item grid

POST /api/item_grids

Item grids are created by POSTing an item grid record containing the required attributes to the /api/item_grids resource. When successful, the response headers will contain a Location header that indicates the url at which the newly created item grid can be found. The item grid's unique id will be the last portion of that URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/item_grids"
client["item_grids"].post({}).headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/item_grids/143380

Retrieve an item grid

GET /api/item_grids/{{item_grid_id}}

Item grids are retrieved from the Heartland Retail API via their unique id. The id can be found via searches, references from other records, or from the Location header in a Create Item grid response.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/item_grids/{{item_grid_id}}"
client["item_grids/{{item_grid_id}}"].get.body
Response:
{
  "id": 103382,
  "item_cost": 87.5,
  "item_price": 43.05,
  "item_original_price": 90.98,
  "item_financial_class_id": 101168,
  "item_primary_vendor_id": 102408
}
{"id"=>103580,
 "item_cost"=>59.02,
 "item_price"=>22.81,
 "item_original_price"=>57.18,
 "item_financial_class_id"=>101042,
 "item_primary_vendor_id"=>105787}

Update an item grid

PUT /api/item_grids/{{item_grid_id}}

Item grids can be edited by PUTting an item grid record containing a valid subset of item grid attributes to the item grid's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"item_cost":35.88,"item_price":24.38,"item_original_price":67.5,"item_financial_class_id":102178,"item_primary_vendor_id":109601}' "https://{{subdomain}}.retail.heartland.us/api/item/grids/101001"
client["item_grids/{{item_grid_id}}"]
  .put(my_item_grid_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Search item grids

GET /api/item_grids

Item grids can be searched by GETting the root of the item grids resource /api/item_grids. This API call will result in a search result record containing zero or more item grid records in the values attribute. See Search Results for more information on search results.

Item grids can be filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/item_grids/?per_page=1"
client["item_grids"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100072,
      "item_cost": 13.74,
      "item_price": 27.0,
      "item_original_price": 50.01,
      "item_financial_class_id": 108778,
      "item_primary_vendor_id": 106054
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>107514,
    "item_cost"=>91.82,
    "item_price"=>56.97,
    "item_original_price"=>66.39,
    "item_financial_class_id"=>109509,
    "item_primary_vendor_id"=>100651},
   "..."]}

Inventory Values

The inventory values API allows you to retrieve real-time inventory values from across your business. This API uses our advanced filtering capabilities to let you filter and group the data however you like.

Retrieve inventory values by item

GET /api/inventory/values

Inventory values are retrieved via a GET request to /api/inventory/values.

Request:
client[:inventory][:values].query(group: [:location_id]).get.body
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/values?group[]=item_id&per_page=2"
Response:
{"total"=>19611,
 "pages"=>9806,
 "results"=>
  [{"qty"=>1880.0,
    "qty_on_hand"=>1880.0,
    "qty_committed"=>7.0,
    "qty_on_po"=>19.0,
    "qty_in_transit"=>9.0,
    "qty_available"=>1873.0,
    "unit_cost"=>10.25,
    "item_id"=>68033},
   {"qty"=>112.0,
    "qty_on_hand"=>112.0,
    "qty_committed"=>0.0,
    "qty_on_po"=>8.0,
    "qty_in_transit"=>0.0,
    "qty_available"=>112.0,
    "unit_cost"=>24.93017857142857,
    "item_id"=>68034}]}
{
   "total":19611,
   "pages":9806,
   "results":[
      {
         "qty":1880.0,
         "qty_on_hand":1880.0,
         "qty_committed":7.0,
         "qty_on_po":19.0,
         "qty_in_transit":9.0,
         "qty_available":1873.0,
         "unit_cost":10.2494840425531915,
         "item_id":68033
      },
      {
         "qty":112.0,
         "qty_on_hand":112.0,
         "qty_committed":0.0,
         "qty_on_po":8.0,
         "qty_in_transit":0.0,
         "qty_available":112.0,
         "unit_cost":24.9301785714285714,
         "item_id":68034
      }
   ]
}

Inventory Transactions

Heartland Retail creates a record whenever any type of inventory transaction takes place. The Inventory Transactions API allows you to access these records.

Inventory transaction APIs work with the inventory transaction record type:

Inventory Transaction

id:
integer (auto-generated)

The unique identifier for a transaction

item_id:
integer (required)

the item id whose inventory was altered.

unit_cost:
numeric(10,2) (required)

the per-item cost for the items altered in this transaction

location_id:
integer (required)

the id of the location whose inventory is being altered

delta_qty:
numeric(10,2)

the change in quantity

delta_qty_on_po:
numeric(10,2)

the change in quantity pending on a purchase order

delta_qty_committed:
numeric(10,2)

the change in quantity committed to a sale

delta_qty_in_transit:
numeric

the change in quantity being transferred between stores

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

Inventory Transaction Example:
{
  "id": 102320,
  "item_id": 100510,
  "unit_cost": 96.85,
  "location_id": 106772,
  "delta_qty": 15.66,
  "delta_qty_on_po": 50.82,
  "delta_qty_committed": 69.0
}

Search inventory transactions

GET /api/inventory/transactions

Searching and filtering inventory transactions is done via a simple GET request to /api/inventory/transactions.

Request:
client[:inventory][:transactions].query(per_page: 2).get.body
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transactions?per_page=2"
Response:
{
  "total"=>119,
  "pages"=>60,
  "results"=>
  [
    {
      "id"=>100001,
      "item_id"=>100001,
      "unit_cost"=>45.0,
      "created_at"=>"2013-08-05T09:43:55-04:00",
      "delta_qty"=>-1.0,
      "delta_qty_on_po"=>nil,
      "delta_qty_committed"=>nil,
      "delta_qty_in_transit"=>nil,
      "location_id"=>100001
    },
    {
      "id"=>100002,
      "item_id"=>100003,
      "unit_cost"=>7.0,
      "created_at"=>"2013-08-06T08:20:13-04:00",
      "delta_qty"=>-1.0,
      "delta_qty_on_po"=>nil,
      "delta_qty_committed"=>nil,
      "delta_qty_in_transit"=>nil,
      "location_id"=>100001
    }
  ]
}
{
  "total": 119,
  "pages": 60,
  "results": [
    {
      "id": 100001,
      "item_id": 100001,
      "unit_cost": 45.0,
      "created_at": "2013-08-05T09:43:55-04:00",
      "delta_qty": -1.0,
      "delta_qty_on_po": null,
      "delta_qty_committed": null,
      "delta_qty_in_transit": null,
      "location_id": 100001
    },
    {
      "id": 100002,
      "item_id": 100003,
      "unit_cost": 7.0,
      "created_at": "2013-08-06T08:20:13-04:00",
      "delta_qty": -1.0,
      "delta_qty_on_po": null,
      "delta_qty_committed": null,
      "delta_qty_in_transit": null,
      "location_id": 100001
    }
  ]
}

Inventory Transfers

The inventory transfers resource exposes the ability to create and modify inventory transfers in the Heartland Retail system.

There are two common flows for Inventory Transfers:

Create Transfer => Add Transfer Lines => Mark as shipped => Select received Lines => Mark as received => Complete

Alternatively you can create an Inventory Transfer Request first:

Create Transfer Request => Add Requested Lines => Mark as requested => Select shipped Lines => Mark as shipped => Select received Lines => Mark as received => Complete

The vast majority of inventory transfer APIs make use of the inventory transfer record type:

Inventory Transfer

id:
integer (auto-generated)

The id of the transfer record

status:
text (required)

Status of the transfer

from_location_id:
integer

The id of the location from which items are shipped

to_location_id:
integer

The id of the location to which items are shipped

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

created_by_user_id:
integer
updated_by_user_id:
integer

The id of the last user who updated the transfer

shipped_at:
timestamp without time zone

The timestamp when the transfer was shipped

shipped_by_user_id:
integer

The id of the user who shipped the transfer

received_at:
timestamp without time zone

The timestamp when the transfer was received

received_by_user_id:
integer

The id of the user who received the transfer

total_qty_shipped:
numeric(10,2)

Total quantity of items shipped

total_qty_received:
numeric(10,2)

Total quantity of items received

total_qty_lost:
numeric(10,2)

Total quantity of items lost

custom:
object

Custom field values

total_qty_requested:
numeric(10,2)

Total quantity of items requested (for Transfer Requests)

due_date:
date

Due Date for Transfer Requests

purchasing_receipt_id:
integer

The id of purchasing receipt that initiated the Transfer Request

total_qty_discrepant:
numeric(10,2)

Total quantity of items discrepant (the difference between qtyreceived and qtyshipped)

receipt_overdue:
boolean

Whether the transfer is overdue to be received or not

pick_overdue:
boolean

Whether the transfer is overdue to be picked or not

Inventory TransferLines Bulk Updating

An expected format to update one or more transfer lines.

transfer_lines:
object (required)

A collection of one or more lines entries.

all_selected:
boolean

If true then any existing transfer lines will be updated

column_name:
text

The column to update (only when all_selected is true)

source_column_name:
text

The column name to update to (only when all_selected is true)

Inventory Transfer Example:
{
  "id": 104608,
  "status": "in_transit",
  "from_location_id": 106265,
  "to_location_id": 100742,
  "created_by_user_id": 109693,
  "updated_by_user_id": 101909,
  "shipped_by_user_id": 104300,
  "received_by_user_id": 101372,
  "total_qty_shipped": 53.59,
  "total_qty_received": 10.91,
  "total_qty_lost": 47.16,
  "custom": {
    "custom1": "Custom value 1",
    "custom2": "Custom value 2"
  },
  "total_qty_requested": 49.72,
  "purchasing_receipt_id": 109357,
  "total_qty_discrepant": 11.74
}
Inventory TransferLines Bulk Updating Example:
{
  "transfer_lines": {
    "123": "{ 'qty_received' => 5 }",
    "321": "{ 'qty_received' => 2 }"
  },
  "column_name": "qty_received",
  "source_column_name": "qty_shipped"
}

Search inventory transfers

GET /api/inventory/transfers

Inventory Transfers can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/?per_page=1"
client["inventory/transfers"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100778,
      "status": "in_transit",
      "from_location_id": 107266,
      "to_location_id": 103122,
      "created_by_user_id": 103893,
      "updated_by_user_id": 107274,
      "shipped_by_user_id": 107956,
      "received_by_user_id": 105629,
      "total_qty_shipped": 45.26,
      "total_qty_received": 13.01,
      "total_qty_lost": 14.04,
      "custom": {
        "custom1": "Custom value 1",
        "custom2": "Custom value 2"
      },
      "total_qty_requested": 17.62,
      "purchasing_receipt_id": 101077,
      "total_qty_discrepant": 46.6
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>102088,
    "status"=>"in_transit",
    "from_location_id"=>108132,
    "to_location_id"=>109239,
    "created_by_user_id"=>102102,
    "updated_by_user_id"=>107470,
    "shipped_by_user_id"=>105185,
    "received_by_user_id"=>102406,
    "total_qty_shipped"=>23.12,
    "total_qty_received"=>31.88,
    "total_qty_lost"=>36.91,
    "custom"=>{"custom1"=>"Custom value 1", "custom2"=>"Custom value 2"},
    "total_qty_requested"=>11.5,
    "purchasing_receipt_id"=>109659,
    "total_qty_discrepant"=>26.69},
   "..."]}

Get an inventory transfer

GET /api/inventory/transfers/{{transfer_id}}

Inventory Transfers can be fetched by GETting the inventory transfer's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}"
client["inventory/transfers/{{transfer_id}}"]
  .get.body
Response:
{
  "id": 100581,
  "status": "in_transit",
  "from_location_id": 109244,
  "to_location_id": 109454,
  "created_by_user_id": 101455,
  "updated_by_user_id": 103846,
  "shipped_by_user_id": 100423,
  "received_by_user_id": 104173,
  "total_qty_shipped": 26.31,
  "total_qty_received": 67.37,
  "total_qty_lost": 33.31,
  "custom": {
    "custom1": "Custom value 1",
    "custom2": "Custom value 2"
  },
  "total_qty_requested": 89.08,
  "purchasing_receipt_id": 101071,
  "total_qty_discrepant": 35.36
}
{"id"=>106697,
 "status"=>"in_transit",
 "from_location_id"=>105115,
 "to_location_id"=>102306,
 "created_by_user_id"=>102289,
 "updated_by_user_id"=>109238,
 "shipped_by_user_id"=>109706,
 "received_by_user_id"=>102411,
 "total_qty_shipped"=>56.05,
 "total_qty_received"=>66.15,
 "total_qty_lost"=>85.15,
 "custom"=>{"custom1"=>"Custom value 1", "custom2"=>"Custom value 2"},
 "total_qty_requested"=>49.74,
 "purchasing_receipt_id"=>109864,
 "total_qty_discrepant"=>88.92}

Create an inventory transfer

POST /api/inventory/transfers

Inventory Transfers are created by POSTing a inventory transfer record containing the required attributes to the /api/inventory/transfers resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"status":"in_transit"}' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers"
client["inventory/transfers"]
  .post({ "from_location_id"=>"123", "to_location_id"=>"321" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/inventory/transfers/190551

Update an inventory transfer

PUT /api/inventory/transfers/{{transfer_id}}

Inventory Transfers can be edited by PUTting an inventory transfer record containing a valid subset of inventory transfer attributes to the inventory transfer's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"status":"in_transit","from_location_id":105144,"to_location_id":103537,"created_by_user_id":105556,"updated_by_user_id":102126,"shipped_by_user_id":108482,"received_by_user_id":106048,"total_qty_shipped":98.32,"total_qty_received":93.54,"total_qty_lost":35.76,"custom":{"custom1":"Custom value 1","custom2":"Custom value 2"},"total_qty_requested":50.79,"purchasing_receipt_id":106150,"total_qty_discrepant":40.4}' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/100142"
client["inventory/transfers/{{transfer_id}}"]
  .put(my_inventory_transfer_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Search inventory transfer lines

GET /api/inventory/transfers/{{transfer_id}}/lines

Inventory Transfer Lines can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/lines/?per_page=1"
client["inventory/transfers/{{transfer_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 103921,
      "transfer_id": 105386,
      "item_id": 102611,
      "qty_shipped": 67.74,
      "qty_received": 91.59,
      "qty_lost": 62.22,
      "unit_cost": 30.74,
      "qty_discrepant": 49.56,
      "qty_over": 58.91,
      "qty_short": 29.51,
      "created_by_user_id": 101882,
      "updated_by_user_id": 100241,
      "qty_requested": 88.17
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>102829,
    "transfer_id"=>109652,
    "item_id"=>101156,
    "qty_shipped"=>81.3,
    "qty_received"=>44.41,
    "qty_lost"=>28.88,
    "unit_cost"=>40.55,
    "qty_discrepant"=>14.69,
    "qty_over"=>76.07,
    "qty_short"=>83.62,
    "created_by_user_id"=>105122,
    "updated_by_user_id"=>100322,
    "qty_requested"=>85.75},
   "..."]}

Get an inventory transfer line

GET /api/inventory/transfers/{{transfer_id}}/lines/{{line_id}}

Inventory Transfer Lines can be fetched by GETting the inventory transfer line's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/lines/{{line_id}}"
client["inventory/transfers/{{transfer_id}}/lines/{{line_id}}"]
  .get.body
Response:
{
  "id": 101428,
  "transfer_id": 105143,
  "item_id": 109957,
  "qty_shipped": 95.96,
  "qty_received": 10.3,
  "qty_lost": 15.39,
  "unit_cost": 32.29,
  "qty_discrepant": 52.51,
  "qty_over": 92.32,
  "qty_short": 27.87,
  "created_by_user_id": 101783,
  "updated_by_user_id": 100505,
  "qty_requested": 55.5
}
{"id"=>105840,
 "transfer_id"=>101109,
 "item_id"=>105798,
 "qty_shipped"=>10.98,
 "qty_received"=>82.95,
 "qty_lost"=>91.76,
 "unit_cost"=>48.6,
 "qty_discrepant"=>70.57,
 "qty_over"=>61.63,
 "qty_short"=>56.97,
 "created_by_user_id"=>106256,
 "updated_by_user_id"=>100751,
 "qty_requested"=>33.04}

Create an inventory transfer line

POST /api/inventory/transfers/{{transfer_id}}/lines

Inventory Transfer Lines are created by POSTing a inventory transfer line record containing the required attributes to the /api/inventory/transfers/{{transfer_id}}/lines resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"transfer_id":102029,"qty_shipped":93.83,"qty_received":32.35,"qty_lost":75.19,"unit_cost":24.97,"qty_discrepant":65.87,"qty_over":91.05,"qty_short":76.81,"qty_requested":68.04}' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/lines"
client["inventory/transfers/{{transfer_id}}/lines"]
  .post({ "item_id"=>"123", "qty_shipped"=>"5" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/inventory/transfers/121050/lines/115467

Update an inventory transfer line

PUT /api/inventory/transfers/{{transfer_id}}/lines/{{line_id}}

Inventory Transfer Lines can be edited by PUTting an inventory transfer line record containing a valid subset of inventory transfer line attributes to the inventory transfer line's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"transfer_id":100469,"item_id":101658,"qty_shipped":66.29,"qty_received":58.96,"qty_lost":21.1,"unit_cost":96.79,"qty_discrepant":65.15,"qty_over":93.05,"qty_short":41.31,"created_by_user_id":106099,"updated_by_user_id":100726,"qty_requested":21.28}' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfer_lines/103753"
client["inventory/transfers/{{transfer_id}}/lines/{{line_id}}"]
  .put(my_inventory_transfer_line_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Update inventory transfer lines in bulk

PUT /api/inventory/transfers/{{transfer_id}}/lines

Inventory Transfer Lines can be edited in bulk by PUTting an inventory transfer line record containing a valid subset of inventory transfer line attributes and providing the list of transfer line ids to update to the inventory transfer lines resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"transfer_id":106064,"item_id":100524,"qty_shipped":23.23,"qty_received":76.33,"qty_lost":49.12,"unit_cost":40.11,"qty_discrepant":84.38,"qty_over":68.93,"qty_short":65.87,"created_by_user_id":102922,"updated_by_user_id":100543,"qty_requested":28.22}' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfer_lines/103797"
client["inventory/transfers/{{transfer_id}}/lines"]
  .put(my_inventory_transfer_line_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Delete an inventory transfer line

DELETE /api/inventory/transfers/{{transfer_id}}/lines/{{line_id}}

Inventory Transfer Lines can be deleted by sending a DELETE request to the inventory transfer line's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/lines/{{line_id}}"
client["inventory/transfers/{{transfer_id}}/lines/{{line_id}}"]
  .delete.status
Response:
200
200

Delete inventory transfer lines in bulk

DELETE /api/inventory/transfers/{{transfer_id}}/lines/{{line_id}}

Inventory Transfer Lines can be deleted in bulk by sending a DELETE request with transfer line ids to the to the transfer lines resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/lines/{{line_id}}"
client["inventory/transfers/{{transfer_id}}/lines/{{line_id}}"]
  .delete.status
Response:
200
200

Search inventory transfer lines with items

GET /api/inventory/transfers/{{transfer_id}}/transfer_lines

This endpoint exposes Inventory Transfer Lines with embedded items for each line.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/transfer_lines/?per_page=1"
client["inventory/transfers/{{transfer_id}}/transfer_lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 107757,
      "transfer_id": 100205,
      "item_id": 103950,
      "qty_shipped": 47.03,
      "qty_received": 54.21,
      "qty_lost": 23.85,
      "unit_cost": 97.87,
      "qty_discrepant": 18.95,
      "qty_over": 75.89,
      "qty_short": 68.07,
      "created_by_user_id": 105913,
      "updated_by_user_id": 109138,
      "qty_requested": 43.74
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>102503,
    "transfer_id"=>109063,
    "item_id"=>103543,
    "qty_shipped"=>59.67,
    "qty_received"=>15.47,
    "qty_lost"=>57.65,
    "unit_cost"=>73.31,
    "qty_discrepant"=>73.14,
    "qty_over"=>25.88,
    "qty_short"=>57.14,
    "created_by_user_id"=>106017,
    "updated_by_user_id"=>106708,
    "qty_requested"=>94.42},
   "..."]}

Update inventory transfer lines from shipment

PUT /api/inventory/transfers/{{transfer_id}}/transfer_lines

Inventory Transfer Lines can be updated in bulk by PUTting a specifically crafted collection where keys are transfer lines ids, and values are updates.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"transfer_lines":{"123":"{ 'qty_received' => 5 }","321":"{ 'qty_received' => 2 }"},"column_name":"qty_received","source_column_name":"qty_shipped"}' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfer_lines/bulk/updatings/104307"
client["inventory/transfers/{{transfer_id}}/transfer_lines"]
  .post({ "transfer_lines"=>{ "123"=>{"qty_received"=>5}, "321"=>{"qty_received"=>6}, } })
  .get.body
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Search inventory transfer events

GET /api/inventory/transfers/{{transfer_id}}/events

Inventory Transfer Events can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/events/?per_page=1"
client["inventory/transfers/{{transfer_id}}/events"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 106937,
      "transfer_id": 107048,
      "created_by_user_id": 104484,
      "updated_by_user_id": 109449,
      "local_created_at": "2013-08-05T07:22:24-04:00",
      "local_updated_at": "2013-08-05T07:22:38-04:00",
      "total_delta_qty_shipped": 29.82,
      "total_delta_qty_received": 33.29,
      "total_delta_qty_lost": 64.16,
      "total_qty_created": 94.5,
      "total_qty_added": 17.92
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>105383,
    "transfer_id"=>104250,
    "created_by_user_id"=>106310,
    "updated_by_user_id"=>108006,
    "local_created_at"=>"2013-08-05T07:22:24-04:00",
    "local_updated_at"=>"2013-08-05T07:22:38-04:00",
    "total_delta_qty_shipped"=>72.22,
    "total_delta_qty_received"=>48.65,
    "total_delta_qty_lost"=>92.14,
    "total_qty_created"=>32.74,
    "total_qty_added"=>14.31},
   "..."]}

Get an inventory transfer event

GET /api/inventory/transfers/{{transfer_id}}/events/{{event_id}}

Inventory Transfer Events can be fetched by GETting the inventory transfer event's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/events/{{event_id}}"
client["inventory/transfers/{{transfer_id}}/events/{{event_id}}"]
  .get.body
Response:
{
  "id": 100275,
  "transfer_id": 100216,
  "created_by_user_id": 106496,
  "updated_by_user_id": 102066,
  "local_created_at": "2013-08-05T07:22:24-04:00",
  "local_updated_at": "2013-08-05T07:22:38-04:00",
  "total_delta_qty_shipped": 69.9,
  "total_delta_qty_received": 41.24,
  "total_delta_qty_lost": 29.66,
  "total_qty_created": 46.28,
  "total_qty_added": 88.29
}
{"id"=>108958,
 "transfer_id"=>109962,
 "created_by_user_id"=>104481,
 "updated_by_user_id"=>108933,
 "local_created_at"=>"2013-08-05T07:22:24-04:00",
 "local_updated_at"=>"2013-08-05T07:22:38-04:00",
 "total_delta_qty_shipped"=>23.84,
 "total_delta_qty_received"=>14.79,
 "total_delta_qty_lost"=>17.34,
 "total_qty_created"=>91.33,
 "total_qty_added"=>43.15}

Search inventory transfer event lines

GET /api/inventory/transfers/{{transfer_id}}/event_lines

Inventory Transfer Event Lines can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/event_lines/?per_page=1"
client["inventory/transfers/{{transfer_id}}/event_lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 109165,
      "event_id": 107575,
      "transfer_line_id": 104679,
      "delta_qty_shipped": 54.01,
      "delta_qty_received": 79.12,
      "delta_qty_lost": 35.55,
      "adjustment_reason_id": 106426,
      "adjustment_id": 105828,
      "local_created_at": "2013-08-05T07:22:24-04:00",
      "local_updated_at": "2013-08-05T07:22:38-04:00",
      "qty_created": 23.94,
      "qty_added": 72.36
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>100371,
    "event_id"=>106879,
    "transfer_line_id"=>101800,
    "delta_qty_shipped"=>41.08,
    "delta_qty_received"=>81.09,
    "delta_qty_lost"=>23.49,
    "adjustment_reason_id"=>105950,
    "adjustment_id"=>101626,
    "local_created_at"=>"2013-08-05T07:22:24-04:00",
    "local_updated_at"=>"2013-08-05T07:22:38-04:00",
    "qty_created"=>59.15,
    "qty_added"=>57.72},
   "..."]}

Get an inventory transfer event line

GET /api/inventory/transfers/{{transfer_id}}/event_lines/{{line_id}}

Inventory Transfer Event Lines can be fetched by GETting the inventory transfer event line's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/event_lines/{{line_id}}"
client["inventory/transfers/{{transfer_id}}/event_lines/{{line_id}}"]
  .get.body
Response:
{
  "id": 100947,
  "event_id": 102250,
  "transfer_line_id": 104279,
  "delta_qty_shipped": 45.79,
  "delta_qty_received": 73.58,
  "delta_qty_lost": 65.75,
  "adjustment_reason_id": 101485,
  "adjustment_id": 103333,
  "local_created_at": "2013-08-05T07:22:24-04:00",
  "local_updated_at": "2013-08-05T07:22:38-04:00",
  "qty_created": 17.69,
  "qty_added": 85.68
}
{"id"=>108487,
 "event_id"=>104506,
 "transfer_line_id"=>104154,
 "delta_qty_shipped"=>43.3,
 "delta_qty_received"=>97.72,
 "delta_qty_lost"=>39.4,
 "adjustment_reason_id"=>108713,
 "adjustment_id"=>102652,
 "local_created_at"=>"2013-08-05T07:22:24-04:00",
 "local_updated_at"=>"2013-08-05T07:22:38-04:00",
 "qty_created"=>42.9,
 "qty_added"=>47.07}

Search inventory transfer event lines of an event

GET /api/inventory/transfers/{{transfer_id}}/events/{{event_id}}/lines

Inventory Transfer Event Lines can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/events/{{event_id}}/lines/?per_page=1"
client["inventory/transfers/{{transfer_id}}/events/{{event_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 106459,
      "event_id": 109179,
      "transfer_line_id": 106744,
      "delta_qty_shipped": 39.37,
      "delta_qty_received": 16.99,
      "delta_qty_lost": 24.79,
      "adjustment_reason_id": 108054,
      "adjustment_id": 104557,
      "local_created_at": "2013-08-05T07:22:24-04:00",
      "local_updated_at": "2013-08-05T07:22:38-04:00",
      "qty_created": 83.86,
      "qty_added": 24.09
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>101210,
    "event_id"=>105406,
    "transfer_line_id"=>107924,
    "delta_qty_shipped"=>98.59,
    "delta_qty_received"=>46.83,
    "delta_qty_lost"=>43.77,
    "adjustment_reason_id"=>101476,
    "adjustment_id"=>102031,
    "local_created_at"=>"2013-08-05T07:22:24-04:00",
    "local_updated_at"=>"2013-08-05T07:22:38-04:00",
    "qty_created"=>58.13,
    "qty_added"=>19.64},
   "..."]}

Get an inventory transfer event line of an event

GET /api/inventory/transfers/{{transfer_id}}/events/{{event_id}}/lines/{{line_id}}

Inventory Transfer Event Lines can be fetched by GETting the inventory transfer event line's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/events/{{event_id}}/lines/{{line_id}}"
client["inventory/transfers/{{transfer_id}}/events/{{event_id}}/lines/{{line_id}}"]
  .get.body
Response:
{
  "id": 101577,
  "event_id": 107718,
  "transfer_line_id": 108633,
  "delta_qty_shipped": 44.31,
  "delta_qty_received": 56.89,
  "delta_qty_lost": 26.57,
  "adjustment_reason_id": 103586,
  "adjustment_id": 100520,
  "local_created_at": "2013-08-05T07:22:24-04:00",
  "local_updated_at": "2013-08-05T07:22:38-04:00",
  "qty_created": 10.76,
  "qty_added": 70.15
}
{"id"=>107335,
 "event_id"=>105796,
 "transfer_line_id"=>105925,
 "delta_qty_shipped"=>46.9,
 "delta_qty_received"=>35.85,
 "delta_qty_lost"=>69.58,
 "adjustment_reason_id"=>102883,
 "adjustment_id"=>107706,
 "local_created_at"=>"2013-08-05T07:22:24-04:00",
 "local_updated_at"=>"2013-08-05T07:22:38-04:00",
 "qty_created"=>32.5,
 "qty_added"=>87.44}

Create an inventory transfer shipment

POST /api/inventory/transfers/{{transfer_id}}/shipments

Inventory Transfers Shipments are created by POSTing a inventory transfer shipment record containing the required attributes to the shipments resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d 'TBD' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfers/{{transfer_id}}/shipments"
client["inventory/transfers/{{transfer_id}}/shipments"]
  .post(TBD)
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/inventory/transfers/158715/shipments/196196

Sales

Sales APIs expose the ability to manage customers, sales orders, and promotions as well as exposing APIs to retrieve information about sales tickets, cash paid transactions, and sales history data.

Tickets

A sales ticket is a record that a POS sale, return, or exchange transaction.

Sales ticket APIs expose the ability to create, retrieve, update, and search for sales tickets. The sales ticket APIs make use of the sales ticket record.

In order to complete a ticket it must have payments sufficient to cover its balance.

Sales Ticket

id:
integer (auto-generated)
metadata:
text
type:
text (required)
customer_id:
integer
source_location_id:
integer
sales_rep:
text
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

public_id:
text
station_id:
integer
parent_transaction_id:
integer
recalculate:
boolean

When set to false, we do not calculate and apply any promotion, coupon, or tax rules

status:
text

Current status of the transaction

total:
numeric(10,2) (computed)
created_by_user_id:
integer (auto-generated)

The user who created this record

custom:
hash

An object that acts as a container for custom values defined in Heartland Retail as well as any arbitrary values stored by integrations or custom applications.

local_created_at:
DateTime

The date and time that this ticket was created with the location timezone applied

local_updated_at:
DateTime

The date and time that this ticket was last updated with the location timezone applied

metadata_private:
text (computed)

Internal store for custom data.

updated_by_user_id:
integer (auto-generated)

The most recent user who updated this record

completed_at:
DateTime

The date and time that this ticket was completed

affect_inventory:
boolean

Whether or not the ticket should affect inventory on completion. Must be set during ticket creation

coupon_id:
integer

ID of coupon to apply to the ticket

sales_rep_ids:
array<id>

An array of user IDs to be used as sales reps for this ticket

Sales ItemLine

id:
integer (auto-generated)
type:
text (required)
sales_transaction_id:
integer
description:
text
value:
numeric(10,2)
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

qty:
numeric(10,2)
adjusted_unit_price:
numeric(10,2)
unit_cost:
numeric(10,2)
original_unit_price:
numeric(10,2)
item_id:
integer (required)
action_id:
text
shipping_line_id:
integer
item_line_id:
integer
sales_transaction_line_id:
integer
address_id:
integer
shipping_method_id:
integer
manually_added:
boolean
reason_codes:
text
lookup_id:
integer
customer_id:
integer
loyalty_points:
integer
order_line_id:
integer
address_revision_id:
integer
order_discount_id:
integer
gift_card_id:
integer
tax_rule_id:
integer

Sales Transaction Payment

A payment for use in a sales transaction

id:
integer (auto-generated)
sales_transaction_id:
integer (auto-generated)
payment_id:
integer (auto-generated)
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

sales_order_payment_id:
integer (auto-generated)
status:
text

The payment's current status indicating whether or not it has been captured.

amount:
numeric(10,2) (required)

The amount of money to pay.

description:
text

The user friendly payment description

gateway_info:
object (computed)

Object containing the details received from the payment gateway

gateway_id:
integer (auto-generated)
details:
object (auto-generated)
type:
text (required)

The payment type

credit_card_id:
integer (auto-generated)
deposit_payment_id:
integer (auto-generated)
signature_required:
boolean (computed)
cardholder_name:
text (computed)

The display name for the credit card holder on credit card payments

active:
boolean
deposit:
boolean

Set to true to capture payment immediately, when set to false it captures payment on transaction complete

amount_tendered:
numeric(10,2) (required) (computed)

The amount of money that has been paid

gateway_connection_id:
integer (auto-generated)
reference_id:
text (auto-generated)

Payment reference ID

gateway_type:
text (computed)
manually_reconciled:
boolean (computed)
Sales Ticket Example:
{
  "id": 101438,
  "type": "Ticket",
  "customer_id": 104938,
  "source_location_id": 107523,
  "station_id": 107310,
  "parent_transaction_id": 105416,
  "status": "incomplete",
  "total": 73.51,
  "created_by_user_id": 108307,
  "local_created_at": "2013-08-05T09:22:24-04:00",
  "local_updated_at": "2013-08-05T09:22:24-04:00",
  "updated_by_user_id": 104995,
  "completed_at": "2013-08-05T09:22:24-04:00",
  "coupon_id": 101325,
  "sales_rep_ids": [
    100002,
    100003
  ]
}
Sales ItemLine Example:
{
  "id": 105749,
  "type": "ItemLine",
  "sales_transaction_id": 105306,
  "value": 83.81,
  "qty": 4.0,
  "adjusted_unit_price": 80.19,
  "unit_cost": 47.19,
  "original_unit_price": 42.45,
  "item_id": 100001,
  "shipping_line_id": 106520,
  "item_line_id": 103041,
  "sales_transaction_line_id": 107198,
  "address_id": 104176,
  "shipping_method_id": 100722,
  "lookup_id": 102328,
  "customer_id": 107328,
  "loyalty_points": 107445,
  "order_line_id": 106622,
  "address_revision_id": 103834,
  "order_discount_id": 100819,
  "gift_card_id": 100238,
  "tax_rule_id": 106144
}
Sales Transaction Payment Example:
{
  "id": 102683,
  "sales_transaction_id": 103770,
  "payment_id": 107150,
  "sales_order_payment_id": 108802,
  "amount": 29.73,
  "description": "Cash",
  "gateway_id": 109608,
  "type": "Payments::CashPayment",
  "credit_card_id": 106507,
  "deposit_payment_id": 101782,
  "cardholder_name": "John Doe",
  "active": true,
  "amount_tendered": 57.95,
  "gateway_connection_id": 107337
}

Create a ticket

POST /api/sales/tickets

Creating a sales ticket requires a station_id. The station_id is used to determine which location's inventory to alter as a result of the sales ticket.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"type":"Ticket"}' "https://{{subdomain}}.retail.heartland.us/api/sales/tickets"
client["sales/tickets"]
  .post({"type"=>"Ticket"})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/tickets/122083

Retrieve a ticket

GET /api/sales/tickets/{{ticket_id}}

A sales ticket is retrieved using its unique identifiers. This identifier can be found by searching for tickets, from references in other records, or from the Location header returned in response to the creation of a new sales tickets.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/tickets/{{ticket_id}}"
client["sales/tickets/{{ticket_id}}"].get.body
Response:
{
  "id": 103612,
  "type": "Ticket",
  "customer_id": 105991,
  "source_location_id": 100571,
  "station_id": 109626,
  "parent_transaction_id": 108803,
  "status": "incomplete",
  "total": 72.0,
  "created_by_user_id": 103193,
  "local_created_at": "2013-08-05T09:22:24-04:00",
  "local_updated_at": "2013-08-05T09:22:24-04:00",
  "updated_by_user_id": 105554,
  "completed_at": "2013-08-05T09:22:24-04:00",
  "coupon_id": 108705,
  "sales_rep_ids": [
    100002,
    100003
  ]
}
{"id"=>105279,
 "type"=>"Ticket",
 "customer_id"=>100923,
 "source_location_id"=>108961,
 "station_id"=>107677,
 "parent_transaction_id"=>100488,
 "status"=>"incomplete",
 "total"=>27.05,
 "created_by_user_id"=>109468,
 "local_created_at"=>"2013-08-05T09:22:24-04:00",
 "local_updated_at"=>"2013-08-05T09:22:24-04:00",
 "updated_by_user_id"=>105705,
 "completed_at"=>"2013-08-05T09:22:24-04:00",
 "coupon_id"=>106478,
 "sales_rep_ids"=>[100002, 100003]}

Retrieve a ticket's lines

GET /api/sales/tickets/{{ticket_id}}/lines

A sales ticket has zero or more associated lines. Lines can be any of the following types:

  • ItemLine - The sale or return of an item
  • TaxLine - Sales tax charge or refund
  • DiscountLine - Discount to another type of line
  • ShippingLine - Shipping charge, discount or refund

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/tickets/{{ticket_id}}/lines/?per_page=1"
client["sales/tickets/{{ticket_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 101755,
      "type": "ItemLine",
      "sales_transaction_id": 103715,
      "value": 15.56,
      "qty": 4.0,
      "adjusted_unit_price": 86.99,
      "unit_cost": 31.37,
      "original_unit_price": 95.09,
      "item_id": 100001,
      "shipping_line_id": 109941,
      "item_line_id": 102432,
      "sales_transaction_line_id": 100730,
      "address_id": 109193,
      "shipping_method_id": 107878,
      "lookup_id": 106139,
      "customer_id": 106513,
      "loyalty_points": 105156,
      "order_line_id": 106834,
      "address_revision_id": 100458,
      "order_discount_id": 106262,
      "gift_card_id": 106395,
      "tax_rule_id": 108283
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>101093,
    "type"=>"ItemLine",
    "sales_transaction_id"=>106332,
    "value"=>11.71,
    "qty"=>4.0,
    "adjusted_unit_price"=>21.21,
    "unit_cost"=>66.56,
    "original_unit_price"=>15.0,
    "item_id"=>100001,
    "shipping_line_id"=>107753,
    "item_line_id"=>101606,
    "sales_transaction_line_id"=>102968,
    "address_id"=>104011,
    "shipping_method_id"=>105136,
    "lookup_id"=>107912,
    "customer_id"=>102161,
    "loyalty_points"=>104754,
    "order_line_id"=>109287,
    "address_revision_id"=>109713,
    "order_discount_id"=>102612,
    "gift_card_id"=>100387,
    "tax_rule_id"=>103937},
   "..."]}

Add an item line to a ticket

POST /api/sales/tickets/{{ticket_id}}/item_lines

An item line indicates the sale or return of an item. This method can also be used to modify the quantity of an existing item line. Tickets are limited to 500 item lines per ticket. Attempting to add more than that will return an error.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"type":"ItemLine","item_id":100001}' "https://{{subdomain}}.retail.heartland.us/api/sales/tickets/{{ticket_id}}/item_lines"
client["sales/tickets/{{ticket_id}}/item_lines"]
  .post({"type"=>"ItemLine", "item_id"=>100001})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/tickets/121489/item_lines/166832

Add a payment to a ticket

POST /api/sales/tickets/{{ticket_id}}/payments

Adds a payment with the given amount and method to the ticket. See the payment data type for more details.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"amount":55.14,"type":"Payments::CashPayment","amount_tendered":36.08}' "https://{{subdomain}}.retail.heartland.us/api/sales/tickets/{{ticket_id}}/payments"
client["sales/tickets/{{ticket_id}}/payments"]
  .post({"amount"=>19.37, "type"=>"Payments::CashPayment", "amount_tendered"=>22.57})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/tickets/128367/payments/140046

Add a coupon to a ticket

PUT /api/sales/tickets/{{ticket_id}}

Adds a coupon to the ticket. See the coupon data type for more details.

Request:
client[:sales][:tickets][403992].put(coupon_id: 1).status
curl -v -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"coupon_id":"1"}' "https://{{subdomain}}.retail.heartland.us/api/sales/tickets/403993"
Response:
200 # success!
# ...
# Status: 200 OK
# ...

# No Content.

Update a ticket

PUT /api/sales/tickets/{{ticket_id}}

A sales ticket can be modified by sending a PUT request to the record's unique URL. The contents of the request must contain a valid subset of sales ticket record attribute. You can pass completed_at to set the specific completion date and time for the ticket (for example in the past). A sales ticket also accepts the affect_inventory flag that if set to false can be used to not perform inventory adjustment on ticket completion.

Request:
client[:sales][:tickets][403992].put(status: 'void').status
curl -v -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"status":"void"}' "https://{{subdomain}}.retail.heartland.us/api/sales/tickets/403993"
Response:
200 # success!
# ...
# Status: 200 OK
# ...

# No Content.

Search tickets

GET /api/sales/tickets

Sales tickets can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/tickets/?per_page=1"
client["sales/tickets"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100011,
      "type": "Ticket",
      "customer_id": 108339,
      "source_location_id": 105722,
      "station_id": 103265,
      "parent_transaction_id": 103554,
      "status": "incomplete",
      "total": 53.88,
      "created_by_user_id": 109573,
      "local_created_at": "2013-08-05T09:22:24-04:00",
      "local_updated_at": "2013-08-05T09:22:24-04:00",
      "updated_by_user_id": 100316,
      "completed_at": "2013-08-05T09:22:24-04:00",
      "coupon_id": 104477,
      "sales_rep_ids": [
        100002,
        100003
      ]
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>104279,
    "type"=>"Ticket",
    "customer_id"=>103739,
    "source_location_id"=>106082,
    "station_id"=>108935,
    "parent_transaction_id"=>102598,
    "status"=>"incomplete",
    "total"=>22.05,
    "created_by_user_id"=>109391,
    "local_created_at"=>"2013-08-05T09:22:24-04:00",
    "local_updated_at"=>"2013-08-05T09:22:24-04:00",
    "updated_by_user_id"=>102517,
    "completed_at"=>"2013-08-05T09:22:24-04:00",
    "coupon_id"=>106520,
    "sales_rep_ids"=>[100002, 100003]},
   "..."]}

Orders

A sales order is a record that documents an order placed by a customer. Sales orders are typically used for future pickup of items, special orders, or ecommerce orders. This record holds the items, sales prices, shipping method/fee, and the payment information for the order. (For POS sales transactions, see Tickets)

A sales order has four statuses; Pending, Open, Canceled, Closed. While an order is pending, no inventory for items on the order has been committed. Before an order can be moved to the Open status, you must have sufficent payments added to the order as well as a valid shipping/billing address. You can cancel an order as long as it does not have any completed invoices against it. Once all items on the order have been successfully invoiced, the order is automatically transitioned to Closed.

Sales order APIs expose the ability to create, retrieve, update, and search for sales orders. The sales order APIs make use of the sales order record

Sales Order

id:
integer (auto-generated)
customer_id:
integer (required)
station_id:
integer (required)
source_location_id:
integer (required)
status:
text

The status of the order. Valid options: "pending", "open", "canceled", "closed"

sales_rep:
text
recalculate:
boolean
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

shipping_method_id:
integer
shipping_charge:
numeric(10,2)
billing_address_id:
integer
shipping_address_id:
integer
gift_cards:
array

List of gift cards to add to the order

Sales OrderLine

id:
integer (auto-generated)
item_id:
integer (required)
description:
text
qty:
numeric(10,2) (required)
adjusted_unit_price:
numeric(10,2)
original_unit_price:
numeric(10,2)
unit_cost:
numeric(10,2)
total_tax:
numeric(10,2)

Extended tax amount to collect for the line

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

qty_open:
numeric(10,2)
qty_invoiced:
numeric(10,2)
order_id:
integer
ship_from_location_id:
integer
discounts:
array

List of Sales OrderLineDiscount to be applied

Sales OrderPayment

A payment for use in a sales order

id:
integer (auto-generated)
type:
text (required)

The payment type. Valid options: "CashPayment", "CreditCardPayment", "CheckPayment", "CustomPayment", "ExternalPayment"

status:
text

The payment's current status indicating whether or not it has been captured.

deposit:
boolean (required)

If true, the funds are captured immediately. Otherwise funds are captured when fulfilling the order.

amount:
numeric(10,2) (required)

The amount of money to pay.

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

Sales Order Example:
{
  "id": 100515,
  "customer_id": 103063,
  "station_id": 100441,
  "source_location_id": 105337,
  "status": "pending",
  "shipping_method_id": 106807,
  "shipping_charge": 57.08,
  "billing_address_id": 108653,
  "shipping_address_id": 103532,
  "gift_cards": [
    {
      "number": "GIFT-CARD-NUMBER",
      "value": 12.34
    }
  ]
}
Sales OrderLine Example:
{
  "id": 102289,
  "item_id": 100671,
  "qty": 2.0,
  "adjusted_unit_price": 79.16,
  "original_unit_price": 71.59,
  "unit_cost": 40.88,
  "total_tax": 12.5,
  "qty_open": 30.8,
  "qty_invoiced": 33.61,
  "order_id": 101217,
  "ship_from_location_id": 104182,
  "discounts": [
    {
      "description": "Discount",
      "amount": 12.34
    }
  ]
}
Sales OrderPayment Example:
{
  "id": 104814,
  "type": "CashPayment",
  "deposit": true,
  "amount": 73.52
}

Create a sales order

POST /api/sales/orders

Creating sales orders requires you to have a customer_id, a station_id and a source_location_id. The customer_id is used to determine which customers is placing the order. And the source location_id is which location will be credited for the sale once the order has been invoiced.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"customer_id":105125,"station_id":109089,"source_location_id":103005}' "https://{{subdomain}}.retail.heartland.us/api/sales/orders"
client["sales/orders"]
  .post({"customer_id"=>103205, "station_id"=>107081, "source_location_id"=>108831})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/orders/136177

Retrieve a sales order

GET /api/sales/orders/{{order_id}}

A sales order is retrieved using its unique identifiers. This identifier can be found by searching for orders, from references in other records, or from the Location header returned in response to the creation of a new sales order.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/orders/{{order_id}}"
client["sales/orders/{{order_id}}"].get.body
Response:
{
  "id": 101698,
  "customer_id": 108668,
  "station_id": 109965,
  "source_location_id": 108096,
  "status": "pending",
  "shipping_method_id": 102661,
  "shipping_charge": 41.27,
  "billing_address_id": 102566,
  "shipping_address_id": 102142,
  "gift_cards": [
    {
      "number": "GIFT-CARD-NUMBER",
      "value": 12.34
    }
  ]
}
{"id"=>100680,
 "customer_id"=>106822,
 "station_id"=>101414,
 "source_location_id"=>105556,
 "status"=>"pending",
 "shipping_method_id"=>104035,
 "shipping_charge"=>48.01,
 "billing_address_id"=>101603,
 "shipping_address_id"=>102523,
 "gift_cards"=>[{"number"=>"GIFT-CARD-NUMBER", "value"=>12.34}]}

Add an item to a sales order

POST /api/sales/orders/{{order_id}}/lines

An item line indicates the sale or return of an item. This method can also be used to modify the quantity of an existing item line.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"item_id":108936,"qty":2.0}' "https://{{subdomain}}.retail.heartland.us/api/sales/orders/{{order_id}}/lines"
client["sales/orders/{{order_id}}/lines"]
  .post({"item_id"=>104038, "qty"=>2.0})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/orders/145959/lines/177730

Add an item to a sales order with discounts

POST /api/sales/orders/{{order_id}}/lines

It's possible to embed order line discounts when adding an item to an order. This will make the price of the line drop the amount specified by the sum of discounts.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"item_id":101955,"qty":2.0,"discounts":[{"description":"Discount","amount":12.34}]}' "https://{{subdomain}}.retail.heartland.us/api/sales/orders/{{order_id}}/lines"
client["sales/orders/{{order_id}}/lines"]
  .post({"item_id"=>107444, "qty"=>2.0, "discounts"=>[{"description"=>"Discount", "amount"=>12.34}]})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/orders/128582/lines/12240

Retrieve a sales orders's lines

GET /api/sales/orders/{{order_id}}/lines

A sales order has zero or more associated item lines.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/orders/{{order_id}}/lines/?per_page=1"
client["sales/orders/{{order_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 108781,
      "item_id": 109108,
      "qty": 2.0,
      "adjusted_unit_price": 91.33,
      "original_unit_price": 11.77,
      "unit_cost": 48.84,
      "total_tax": 12.5,
      "qty_open": 48.25,
      "qty_invoiced": 17.21,
      "order_id": 107534,
      "ship_from_location_id": 108629,
      "discounts": [
        {
          "description": "Discount",
          "amount": 12.34
        }
      ]
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>104284,
    "item_id"=>105474,
    "qty"=>2.0,
    "adjusted_unit_price"=>33.4,
    "original_unit_price"=>84.92,
    "unit_cost"=>44.21,
    "total_tax"=>12.5,
    "qty_open"=>74.41,
    "qty_invoiced"=>75.6,
    "order_id"=>105653,
    "ship_from_location_id"=>100221,
    "discounts"=>[{"description"=>"Discount", "amount"=>12.34}]},
   "..."]}

Distribute an item line on a sales order

PUT /api/sales/orders/{{order_id}}/lines/{{line_id}}

Distributing an item line designates the location that item will be fulfilled from. You must specify the ship_from_location_id

Request:
client[:sales][:orders][403992][:lines][135225].put(ship_from_location_id: '100002')
curl -v -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"ship_from_location_id":"100002"}' "https://{{subdomain}}.retail.heartland.us/api/sales/orders/403993/lines/135225"
Response:
200 # success!
# ...
# Status: 200 OK
# ...

Add shipping to a sales order

PUT /api/sales/orders/{{order_id}}/

A sales order can record a shipping method and amount to charge for the shipment. To add a shipping method you need the shipping_method_id and the shipping_charge_amount.

Request:
client[:sales][:orders][403992].put(shipping_method_id: 100003, shipping_charge: 22.00)
curl -v -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"shipping_charge":100002,"shipping_method_id":22.00}' "https://{{subdomain}}.retail.heartland.us/api/sales/orders/403993/"
Response:
200 # success!
# ...
# Status: 200 OK
# ...

Add a payment to a sales order

POST /api/sales/orders/{{order_id}}/payments

Adds a payment with the given amount and method to the order. See the payment data type for more details. A sales order stores the payment information to be captured either immediately or upon shipment of the order (fulling the invoice). There must be sufficent payments added to the order before it can be moved to the Open status.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"type":"CashPayment","deposit":true,"amount":94.52}' "https://{{subdomain}}.retail.heartland.us/api/sales/orders/{{order_id}}/payments"
client["sales/orders/{{order_id}}/payments"]
  .post({"type"=>"CashPayment", "deposit"=>true, "amount"=>61.55})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/orders/148199/payments/183496

Update a sales order

PUT /api/sales/orders/{{order_id}}

A sales order can be modified by sending a PUT request to the record's unique URL. The contents of the request must contain a valid subset of sales order record attribute

Request:
client[:sales][:orders][403992].put(status: 'open').status
curl -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"status":"open"}' "https://{{subdomain}}.retail.heartland.us/api/sales/orders/403993"
Response:
200 # success!
# ...
# Status: 200 OK
# ...

Search sales orders

GET /api/sales/orders

Sales orders can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/orders/?per_page=1"
client["sales/orders"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 106889,
      "customer_id": 100920,
      "station_id": 104961,
      "source_location_id": 103151,
      "status": "pending",
      "shipping_method_id": 100049,
      "shipping_charge": 47.04,
      "billing_address_id": 102264,
      "shipping_address_id": 103382,
      "gift_cards": [
        {
          "number": "GIFT-CARD-NUMBER",
          "value": 12.34
        }
      ]
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>100054,
    "customer_id"=>109610,
    "station_id"=>103054,
    "source_location_id"=>100479,
    "status"=>"pending",
    "shipping_method_id"=>105417,
    "shipping_charge"=>62.78,
    "billing_address_id"=>103895,
    "shipping_address_id"=>103784,
    "gift_cards"=>[{"number"=>"GIFT-CARD-NUMBER", "value"=>12.34}]},
   "..."]}

Invoices

A sales invoice is a record that documents the full or partial fulfillment of a sales order. (For POS sales transactions, see Tickets)

Sales invoice APIs expose the ability to create, retrieve, update, and search for sales invoices. The sales invoice APIs make use of the sales invoice record

Sales Invoice

id:
integer (auto-generated)
metadata:
text
type:
text (required)
customer_id:
integer
source_location_id:
integer
sales_rep:
text
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

public_id:
text
station_id:
integer
recalculate:
boolean

When set to false, we do not calculate and apply any promotion, coupon, or tax rules

status:
text

Current status of the transaction

order_id:
integer
custom:
hash

An object that acts as a container for custom values defined in Heartland Retail as well as any arbitrary values stored by integrations or custom applications.

completed_at:
DateTime

The date and time that this ticket was completed

affect_inventory:
boolean

Whether or not the ticket should affect inventory on completion. Must be set during ticket creation

billing_address_id:
integer

ID of customer address used for billing

Sales Invoice Example:
{
  "id": 101181,
  "type": "Invoice",
  "customer_id": 106678,
  "source_location_id": 102512,
  "station_id": 105254,
  "status": "incomplete",
  "order_id": 104688,
  "completed_at": "2013-08-05T09:22:24-04:00",
  "billing_address_id": 102659
}

Create an invoice

POST /api/sales/invoices

Creating sales invoices requires you to have a station id and a sales order id. The station id is used to determine which location's inventory to alter as a result of the sales invoice and the order id is used to determine what should be invoiced and which customer should receive it.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"type":"Invoice"}' "https://{{subdomain}}.retail.heartland.us/api/sales/invoices"
client["sales/invoices"]
  .post({"type"=>"Invoice"})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/invoices/121949

Retrieve an invoice

GET /api/sales/invoices/{{invoice_id}}

A sales invoice is retrieved using its unique identifiers. This identifier can be found by searching for invoices, from references in other records, or from the Location header returned in response to the creation of a new sales invoices.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/invoices/{{invoice_id}}"
client["sales/invoices/{{invoice_id}}"].get.body
Response:
{
  "id": 101023,
  "type": "Invoice",
  "customer_id": 100403,
  "source_location_id": 101851,
  "station_id": 108768,
  "status": "incomplete",
  "order_id": 104320,
  "completed_at": "2013-08-05T09:22:24-04:00",
  "billing_address_id": 100996
}
{"id"=>107545,
 "type"=>"Invoice",
 "customer_id"=>109989,
 "source_location_id"=>107547,
 "station_id"=>106635,
 "status"=>"incomplete",
 "order_id"=>107305,
 "completed_at"=>"2013-08-05T09:22:24-04:00",
 "billing_address_id"=>104540}

Retrieve an invoice's lines

GET /api/sales/invoices/{{invoice_id}}/lines

A sales invoice has zero or more associated lines. Lines can be any of the following types:

  • ItemLine - The sale or return of an item
  • TaxLine - Sales tax charge or refund
  • DiscountLine - Discount to another type of line
  • ShippingLine - Shipping charge, discount or refund

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/invoices/{{invoice_id}}/lines/?per_page=1"
client["sales/invoices/{{invoice_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 101572,
      "type": "ItemLine",
      "sales_transaction_id": 106009,
      "value": 51.64,
      "qty": 4.0,
      "adjusted_unit_price": 55.17,
      "unit_cost": 69.74,
      "original_unit_price": 45.06,
      "item_id": 100001,
      "shipping_line_id": 101261,
      "item_line_id": 106705,
      "sales_transaction_line_id": 106154,
      "address_id": 107882,
      "shipping_method_id": 105084,
      "lookup_id": 101482,
      "customer_id": 108602,
      "loyalty_points": 105123,
      "order_line_id": 108655,
      "address_revision_id": 100606,
      "order_discount_id": 100691,
      "gift_card_id": 107211,
      "tax_rule_id": 106851
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>106379,
    "type"=>"ItemLine",
    "sales_transaction_id"=>101167,
    "value"=>58.98,
    "qty"=>4.0,
    "adjusted_unit_price"=>75.17,
    "unit_cost"=>79.89,
    "original_unit_price"=>15.96,
    "item_id"=>100001,
    "shipping_line_id"=>108566,
    "item_line_id"=>102343,
    "sales_transaction_line_id"=>107713,
    "address_id"=>105074,
    "shipping_method_id"=>109480,
    "lookup_id"=>100988,
    "customer_id"=>106046,
    "loyalty_points"=>104612,
    "order_line_id"=>109836,
    "address_revision_id"=>103849,
    "order_discount_id"=>109265,
    "gift_card_id"=>105626,
    "tax_rule_id"=>108227},
   "..."]}

Update an invoice

PUT /api/sales/invoices/{{invoice_id}}

A sales invoice can be modified by sending a PUT request to the record's unique URL. The contents of the request must contain a valid subset of sales invoice record attribute

Request:
client[:sales][:invoices][403992].put(status: 'void').status
curl -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"status":"void"}' "https://{{subdomain}}.retail.heartland.us/api/sales/invoices/403993"
Response:
200 # success!
# ...
# Status: 200 OK
# ...

# No Content.

Search invoices

GET /api/sales/invoices

Sales invoices can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/invoices/?per_page=1"
client["sales/invoices"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 102589,
      "type": "Invoice",
      "customer_id": 102446,
      "source_location_id": 108384,
      "station_id": 103883,
      "status": "incomplete",
      "order_id": 106006,
      "completed_at": "2013-08-05T09:22:24-04:00",
      "billing_address_id": 106238
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>100719,
    "type"=>"Invoice",
    "customer_id"=>100905,
    "source_location_id"=>104189,
    "station_id"=>103867,
    "status"=>"incomplete",
    "order_id"=>104506,
    "completed_at"=>"2013-08-05T09:22:24-04:00",
    "billing_address_id"=>105733},
   "..."]}

Customers

Customer APIs expose the ability to create, retrieve, update, and search for customers. The customer APIs make use of the customer record.

Customer

id:
integer (auto-generated)
metadata:
text
public_id:
text

Unique ID string

first_name:
text

First name

last_name:
text

Last name

email:
text

Email address

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

address_id:
integer

ID of default address record

shipping_address_id:
integer

ID of address record used for shipping

billing_address_id:
integer

ID of address record used for billing

active:
boolean

Whether or not this record is currently active and being used

custom:
object

Custom field values

customer_import_batch_id:
integer (auto-generated)

ID of batch if this record was created as part of an import batch

name:
text (computed)

Full name

address:
object

Address record for primary address

loyalty_points_balance:
integer (auto-generated)
loyalty_points_total:
integer (auto-generated)

Address

id:
integer (auto-generated)
address_id:
integer (auto-generated)
current_revision_id:
integer (auto-generated)
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

type:
text
first_name:
text
last_name:
text
line_1:
text
line_2:
text
city:
text
state:
text

If the country is set to 'US' then 2 letter state acronym required

phone:
text
country:
text

Set to 2 letter country acronym. Set value to anything other than 'US' to use a non standard state/postal_code

postal_code:
text

If the country is set to 'US' then a 5 digit ZIP or ZIP+4 code is required

custom:
object

Custom field values

Customer Example:
{
  "id": 103588,
  "first_name": "Walter",
  "last_name": "White",
  "email": "walter@example.com",
  "address_id": 100102,
  "shipping_address_id": 102185,
  "billing_address_id": 108901,
  "custom": {
    "custom1": "Custom value 1",
    "custom2": "Custom value 2"
  },
  "customer_import_batch_id": 108876,
  "name": "Walter White",
  "loyalty_points_balance": 100845,
  "loyalty_points_total": 100012
}
Address Example:
{
  "id": 107756,
  "address_id": 102359,
  "current_revision_id": 108782,
  "first_name": "Bruce",
  "last_name": "Wayne",
  "line_1": "1007 Mountain Drive",
  "city": "Gotham",
  "state": "NJ",
  "phone": "212-555-5555",
  "country": "US",
  "postal_code": "10025",
  "custom": {
    "custom1": "Custom value 1",
    "custom2": "Custom value 2"
  }
}

Create a customer

POST /api/customers

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/customers"
client["customers"].post({}).headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/customers/132696

Retrieve a customer

GET /api/customers/{{customer_id}}

A Customer is retrieved using its unique identifiers. This identifier can be found by searching for customers, from references in other records, or from the Location header returned in response to the creation of a new customer.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/customers/{{customer_id}}"
client["customers/{{customer_id}}"].get.body
Response:
{
  "id": 103170,
  "first_name": "Walter",
  "last_name": "White",
  "email": "walter@example.com",
  "address_id": 103805,
  "shipping_address_id": 108023,
  "billing_address_id": 102294,
  "custom": {
    "custom1": "Custom value 1",
    "custom2": "Custom value 2"
  },
  "customer_import_batch_id": 107331,
  "name": "Walter White",
  "loyalty_points_balance": 103259,
  "loyalty_points_total": 101921
}
{"id"=>101832,
 "first_name"=>"Walter",
 "last_name"=>"White",
 "email"=>"walter@example.com",
 "address_id"=>104884,
 "shipping_address_id"=>106293,
 "billing_address_id"=>101528,
 "custom"=>{"custom1"=>"Custom value 1", "custom2"=>"Custom value 2"},
 "customer_import_batch_id"=>107377,
 "name"=>"Walter White",
 "loyalty_points_balance"=>100611,
 "loyalty_points_total"=>107767}

Update a customer

PUT /api/customers/{{customer_id}}

A customer can be modified by sending a PUT request to the record's unique URL. The contents of the request must contain a valid subset of customer record attribute

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"first_name":"Walter","last_name":"White","email":"walter@example.com","address_id":103008,"shipping_address_id":104509,"billing_address_id":109629,"custom":{"custom1":"Custom value 1","custom2":"Custom value 2"},"customer_import_batch_id":104498,"name":"Walter White","loyalty_points_balance":109027,"loyalty_points_total":103934}' "https://{{subdomain}}.retail.heartland.us/api/customers/102412"
client["customers/{{customer_id}}"]
  .put(my_customer_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Search customers

GET /api/customers

Customers can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/customers/?per_page=1"
client["customers"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 103564,
      "first_name": "Walter",
      "last_name": "White",
      "email": "walter@example.com",
      "address_id": 104738,
      "shipping_address_id": 103362,
      "billing_address_id": 102739,
      "custom": {
        "custom1": "Custom value 1",
        "custom2": "Custom value 2"
      },
      "customer_import_batch_id": 106124,
      "name": "Walter White",
      "loyalty_points_balance": 103164,
      "loyalty_points_total": 107067
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>101871,
    "first_name"=>"Walter",
    "last_name"=>"White",
    "email"=>"walter@example.com",
    "address_id"=>105543,
    "shipping_address_id"=>102964,
    "billing_address_id"=>108410,
    "custom"=>{"custom1"=>"Custom value 1", "custom2"=>"Custom value 2"},
    "customer_import_batch_id"=>101688,
    "name"=>"Walter White",
    "loyalty_points_balance"=>105703,
    "loyalty_points_total"=>104539},
   "..."]}

Merge customers

POST /api/customers/{{customer_id}}/merges

If you have duplicate customers and would like to combine them into one customer you can do so using the merges API. This will combine their sales history and customer data.

The base customer specified in the URL is considered the "master" customer. Include an array of slave_ids in the request body. These "slave" customers will be deleted after having their data combined into the master.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"slave_ids":[100002,100003]}' "https://{{subdomain}}.retail.heartland.us/api/customers/{{customer_id}}/merges"
client["customers/{{customer_id}}/merges"]
  .post({"slave_ids"=>[100002, 100003]})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/customers/15837/merges/119578

Create an address

POST /api/customers/{{customer_id}}/addresses

You are able to create multiple addresses per customer each with their own address_id that can be used to specify the customer's address preferences.

To assign an address to be the default, billing, or shipping address you must create or retrieve an address to get the address_id which can then be used to update the customer record. By specifying the address_id when updating the customer, you are able to set the default address. You are also able to specify a shipping_address_id or a billing_address_id to set the default specific address type for use in a sales order.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/customers/{{customer_id}}/addresses"
client["customers/{{customer_id}}/addresses"]
  .post({})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/customers/164653/addresses/153554

List customer addresses

GET /api/customers/{{customer_id}}/addresses

You can retrieve all addresses currently attached to a customer by using the customer's unique identifier. This identifier can be found by searching for customers, from references in other records, or from the Location header returned in response to the creation of a new customer.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/customers/{{customer_id}}/addresses"
client["customers/{{customer_id}}/addresses"]
  .get.body
Response:
{
  "id": 102451,
  "address_id": 104068,
  "current_revision_id": 108740,
  "first_name": "Bruce",
  "last_name": "Wayne",
  "line_1": "1007 Mountain Drive",
  "city": "Gotham",
  "state": "NJ",
  "phone": "212-555-5555",
  "country": "US",
  "postal_code": "10025",
  "custom": {
    "custom1": "Custom value 1",
    "custom2": "Custom value 2"
  }
}
{"id"=>109536,
 "address_id"=>100590,
 "current_revision_id"=>107338,
 "first_name"=>"Bruce",
 "last_name"=>"Wayne",
 "line_1"=>"1007 Mountain Drive",
 "city"=>"Gotham",
 "state"=>"NJ",
 "phone"=>"212-555-5555",
 "country"=>"US",
 "postal_code"=>"10025",
 "custom"=>{"custom1"=>"Custom value 1", "custom2"=>"Custom value 2"}}

Retrieve an address

GET /api/customers/{{customer_id}}/addresses/{{address_id}}

An address is retrieved using its unique identifier. This identifier can be found by searching for all addresses attached to a customer, from references in other records, or from the Location header returned in response to the creation of a new address.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/customers/{{customer_id}}/addresses/{{address_id}}"
client["customers/{{customer_id}}/addresses/{{address_id}}"]
  .get.body
Response:
{
  "id": 101106,
  "address_id": 107174,
  "current_revision_id": 107895,
  "first_name": "Bruce",
  "last_name": "Wayne",
  "line_1": "1007 Mountain Drive",
  "city": "Gotham",
  "state": "NJ",
  "phone": "212-555-5555",
  "country": "US",
  "postal_code": "10025",
  "custom": {
    "custom1": "Custom value 1",
    "custom2": "Custom value 2"
  }
}
{"id"=>102164,
 "address_id"=>102824,
 "current_revision_id"=>106156,
 "first_name"=>"Bruce",
 "last_name"=>"Wayne",
 "line_1"=>"1007 Mountain Drive",
 "city"=>"Gotham",
 "state"=>"NJ",
 "phone"=>"212-555-5555",
 "country"=>"US",
 "postal_code"=>"10025",
 "custom"=>{"custom1"=>"Custom value 1", "custom2"=>"Custom value 2"}}

Update an address

PUT /api/customers/{{customer_id}}/addresses/{{address_id}}

An address can be modified by sending a PUT request to the record's unique URL. The contents of the request must contain a valid subset of address record attributes

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"address_id":100601,"current_revision_id":100670,"first_name":"Bruce","last_name":"Wayne","line_1":"1007 Mountain Drive","city":"Gotham","state":"NJ","phone":"212-555-5555","country":"US","postal_code":"10025","custom":{"custom1":"Custom value 1","custom2":"Custom value 2"}}' "https://{{subdomain}}.retail.heartland.us/api/addresss/102515"
client["customers/{{customer_id}}/addresses/{{address_id}}"]
  .put(my_address_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Tax Jurisdictions

The tax jurisdictions resource exposes the ability to create and modify tax jurisdictions in the Heartland Retail system.

Tax Jurisdiction

id:
integer (auto-generated)

The id of the tax jurisdiction

name:
text

The name of the tax jurisdiction

type:
text

The type of the tax jurisdiction (either StateJurisdiction or PostalCodeJurisdiction)

country:
text
state:
text
postal_codes:
text

The postal codes of the tax jurisdiction (for PostalCodeJurisdiction)

tax_holiday_start:
date
tax_holiday_end:
date
Tax Jurisdiction Example:
{
  "id": 103992,
  "name": "MA",
  "type": "StateJurisdiction",
  "country": "US",
  "state": "MA"
}

Search tax jurisdictions

GET /api/sales/tax_jurisdictions

Tax Jurisdictions can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/tax_jurisdictions/?per_page=1"
client["sales/tax_jurisdictions"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 101812,
      "name": "MA",
      "type": "StateJurisdiction",
      "country": "US",
      "state": "MA"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>106867,
    "name"=>"MA",
    "type"=>"StateJurisdiction",
    "country"=>"US",
    "state"=>"MA"},
   "..."]}

Get a tax jurisdiction

GET /api/sales/tax_jurisdictions/{{jurisdiction_id}}

Tax Jurisdictions can be fetched by GETting the tax jurisdiction's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/tax_jurisdictions/{{jurisdiction_id}}"
client["sales/tax_jurisdictions/{{jurisdiction_id}}"]
  .get.body
Response:
{
  "id": 104796,
  "name": "MA",
  "type": "StateJurisdiction",
  "country": "US",
  "state": "MA"
}
{"id"=>104883,
 "name"=>"MA",
 "type"=>"StateJurisdiction",
 "country"=>"US",
 "state"=>"MA"}

Create a tax jurisdiction

POST /api/sales/tax_jurisdictions

Tax Jurisdictions are created by POSTing a tax jurisdiction record containing the required attributes to the /api/sales/tax_jurisdictions resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/sales/tax_jurisdictions"
client["sales/tax_jurisdictions"]
  .post({ "name"=>"MA", "type"=>"StateJurisdiction", "country"=>"US", "state"=>"MA" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/tax_jurisdictions/167991

Update a tax jurisdiction

PUT /api/sales/tax_jurisdictions/{{jurisdiction_id}}

Tax Jurisdictions can be edited in bulk by PUTting a tax jurisdiction record containing a valid subset of tax jurisdiction attributes to the tax jurisdiction's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"name":"MA","type":"StateJurisdiction","country":"US","state":"MA"}' "https://{{subdomain}}.retail.heartland.us/api/tax/jurisdictions/100434"
client["sales/tax_jurisdictions/{{jurisdiction_id}}"]
  .put(my_tax_jurisdiction_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Delete a tax jurisdiction

DELETE /api/sales/tax_jurisdictions/{{jurisdiction_id}}

Tax Jurisdictions can be deleted by sending a DELETE request to the tax jurisdiction's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/tax_jurisdictions/{{jurisdiction_id}}"
client["sales/tax_jurisdictions/{{jurisdiction_id}}"]
  .delete.status
Response:
200
200

Tax Rules

The tax rules resource exposes the ability to create and modify tax rules in the Heartland Retail system.

Tax Rule

id:
integer (auto-generated)

The id of the tax rule record

name:
text

The name of the tax rule

amount:
double precision

Tax percentage for "Percentage"-based tax or flat amount for "Flat Per Item"

minimum_price:
numeric(10,2)

Whether or not a certain price must be reached before tax is applied

liability_account_id:
integer

Financial account that you map to will be the account that is credited/debited when the journal entries are synced to a connected financial system.

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

jurisdiction_id:
integer

Which tax jurisdiction the rule is attributed to (globally if not set)

type:
text (required)

The type of the tax rule (either PercentageRule or FlatPerItemRule)

maximum_price:
numeric(10,2)

Whether items should not be taxed if they are above a certain price

tax_amount_below_minimum:
boolean (required)

Whether or not to tax the amount below the minimum_price

archived:
boolean (required)

Whether or not tax rule is archived

customer_filter:
string

Apply the rule only to particular customers (JSON-serialized)

item_filter:
string

Apply the rule only to particular items (JSON-serialized)

financial_error:
boolean (computed)

Whether the tax rule is configured in financial system correctly or not

Tax Rule Example:
{
  "id": 107423,
  "minimum_price": 53.14,
  "liability_account_id": 106782,
  "jurisdiction_id": 109018,
  "maximum_price": 18.58,
  "customer_filter": "{"$and":[{"custom@taxed":{"$eq":"true"}}]}",
  "item_filter": "{"$and":[{"custom@tax_category":{"$eq":"CLOTHING"}}]}"
}

Search tax rules

GET /api/sales/tax_rules

Tax Rules can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/sales/tax_rules/?per_page=1"
client["sales/tax_rules"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100645,
      "minimum_price": 25.79,
      "liability_account_id": 102297,
      "jurisdiction_id": 101367,
      "maximum_price": 95.84,
      "customer_filter": "{"$and":[{"custom@taxed":{"$eq":"true"}}]}",
      "item_filter": "{"$and":[{"custom@tax_category":{"$eq":"CLOTHING"}}]}"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>102347,
    "minimum_price"=>46.06,
    "liability_account_id"=>107586,
    "jurisdiction_id"=>105818,
    "maximum_price"=>98.83,
    "customer_filter"=>"{"$and":[{"custom@taxed":{"$eq":"true"}}]}",
    "item_filter"=>
     "{"$and":[{"custom@tax_category":{"$eq":"CLOTHING"}}]}"},
   "..."]}

Get a tax rule

GET /api/sales/tax_rules/{{rule_id}}

Tax Rules can be fetched by GETting the tax rule's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/tax_rules/{{rule_id}}"
client["sales/tax_rules/{{rule_id}}"].get.body
Response:
{
  "id": 104773,
  "minimum_price": 52.33,
  "liability_account_id": 107389,
  "jurisdiction_id": 104770,
  "maximum_price": 90.22,
  "customer_filter": "{"$and":[{"custom@taxed":{"$eq":"true"}}]}",
  "item_filter": "{"$and":[{"custom@tax_category":{"$eq":"CLOTHING"}}]}"
}
{"id"=>100987,
 "minimum_price"=>24.98,
 "liability_account_id"=>107740,
 "jurisdiction_id"=>102862,
 "maximum_price"=>31.34,
 "customer_filter"=>"{"$and":[{"custom@taxed":{"$eq":"true"}}]}",
 "item_filter"=>
  "{"$and":[{"custom@tax_category":{"$eq":"CLOTHING"}}]}"}

Create a tax rule

POST /api/sales/tax_rules

Tax Rules are created by POSTing a tax rule record containing the required attributes to the /api/sales/tax_rules resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/sales/tax_rules"
client["sales/tax_rules"]
  .post({ "name"=>"CA Sales Tax", "amount"=>"50", "item_filter"=>"{"$and":[{"custom@tax_category":{"$eq":"CLOTHING"}}]}" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/sales/tax_rules/154816

Update a tax rule

PUT /api/sales/tax_rules/{{rule_id}}

Tax Rules can be edited by PUTting a tax rule record containing a valid subset of tax rule attributes and providing the list of tax rules ids to update to the tax rules resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"minimum_price":71.73,"liability_account_id":108989,"jurisdiction_id":103761,"maximum_price":36.02,"customer_filter":"{"$and":[{"custom@taxed":{"$eq":"true"}}]}","item_filter":"{"$and":[{"custom@tax_category":{"$eq":"CLOTHING"}}]}"}' "https://{{subdomain}}.retail.heartland.us/api/tax/rules/102603"
client["sales/tax_rules/{{rule_id}}"]
  .put(my_tax_rule_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Update tax rules in bulk

PUT /api/sales/tax_rules

Tax Rules can be edited in bulk by PUTting a tax rule record containing a valid subset of tax rule attributes to the tax rule's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"transfer_id":100909,"item_id":106361,"qty_shipped":10.46,"qty_received":98.34,"qty_lost":90.54,"unit_cost":69.56,"qty_discrepant":45.95,"qty_over":33.79,"qty_short":76.23,"created_by_user_id":109648,"updated_by_user_id":100800,"qty_requested":50.03}' "https://{{subdomain}}.retail.heartland.us/api/inventory/transfer_lines/101112"
client["sales/tax_rules"]
  .put(my_inventory_transfer_line_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Delete a tax rule

DELETE /api/sales/tax_rules/{{rule_id}}

Tax Rules can be deleted by sending a DELETE request to the tax rule's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/tax_rules/{{rule_id}}"
client["sales/tax_rules/{{rule_id}}"]
  .delete.status
Response:
200
200

Delete tax rules in bulk

DELETE /api/sales/tax_rules

Tax Rules can be deleted in bulk by sending a DELETE request with tax rules ids to the tax rules resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/sales/tax_rules"
client["sales/tax_rules"].delete.status
Response:
200
200

Promotions

Heartland Retail includes a powerful rules-based promotion system. There are two ways to define promotions that can be used to apply discounts and special offers to a sale transaction: Promotion Rules and Coupons.

Promotion Rules and Coupons are each similarly structured and based on the concept of conditions and actions. This part of the documentation will focus on the similarities between these two promotions. For information about the specifics of each, see their respective sections.

Conditions

Conditions determine whether the given promotion's actions should be applied to the current sales transaction. These are transaction-level conditions specified in the condition_definition field.

Be careful not to confuse these with item-level conditions which some actions support. If your promotion needs to target only certain items but should apply to any transaction then you do not need to specify a condition_definition.

Actions

Actions define the effects the promotion will have on the sales transaction. A promotion must have one or more actions. Each action has a type which determines the effect on the transaction. Actions may have additional parameters depending on the type.

See Action Types for a list of available types and their parameters.

Example

Here's an example of a promotion rule. This rule would apply an employee discount of 30% off the original price of any item except those whose primary vendor's ID is 100003. This rule only applies if sales transaction has customer associated and that customer's "Is Employee" custom field is set to "Yes".

{
  "id": 1,
  "name": "Employee Discount",
  "start_at": "2015-01-21 00:00:00",
  "end_at": null,
  "rank": 1,
  "condition_definition": {
    "$and": [
      {
        "customer.custom.is_employee": {
          "$eq": "Yes"
        }
      }
    ]
  },
  "action_definition": [
    {
      "type": "DiscountItem",
      "params": {
        "discount": 0.3,
        "discount_type": "percent",
        "item_conditions": {
          "$and": [
            {
              "item_line.item_primary_vendor_id": {
                "$neq": "100003"
              }
            }
          ]
        },
        "item_price_attribute": "original_price"
      },
      "id": "8e5fd952-a186-11e4-8eee-bc764e2061ef"
    }
  ],
  "archived?": true,
  "disabled?": false,
  "created_at": "2015-01-21T15:59:07+00:00",
  "updated_at": "2015-01-21T16:02:08+00:00"
}

Promotion Rules

The promotion rules resource exposes the ability to create, retrieve, search, update and delete promotion rules in the Heartland Retail system.

A promotion rule is considered active if it is not archived, not disabled and the current date and time is within start_at and end_at.

See Filtering for details on the filter expression syntax of condition_definition.

The promotion rule APIs make use of the promotion rule record type:

Promotion Rule

A promotion rule is a record that represents a rule used in processing promotions and pricing.

id:
integer (auto-generated)
name:
text (required)

The name of this promotion.

start_at:
DateTime

The date and time this promotion starts.

end_at:
DateTime

The date and time this promotion ends.

rank:
integer

It determines the order in which promotions are applied. Promotions are applied from lowest to highest rank.

archived:
Boolean

Whether or not the promotion is archived.

disabled:
Boolean

Whether or not the promotion is disabled.

Promotion Action Definition:
action_definition

A filter expression.

Promotion Condition Definition:
condition_definition

A filter expression.

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

Promotion Rule Example:
{
  "id": 102310,
  "rank": 108084,
  "Promotion Action Definition": {
    "type": "DiscountItem",
    "params": {
      "discount": 5,
      "discount_type": "amount",
      "item_price_attribute": "price",
      "item_conditions": {
        "$and": [
          {
            "item_line.item_primary_vendor_id": "100001"
          }
        ]
      }
    }
  },
  "Promotion Condition Definition": {
    "$and": [
      {
        "customer.customer.rewards_level": {
          "$eq": "gold"
        }
      }
    ]
  }
}

Create a promotion rule

POST /api/promotion_rules

Promotion rules are created by POSTing a promotion rule record containing at least the required attributes to the /api/promotion_rules resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/promotion_rules"
client["promotion_rules"]
  .post({})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/promotion_rules/153121

Retrieve a promotion rule

GET /api/promotion_rules/{{promotion_rule_id}}

Promotion rules are retrieved via their unique id. The id can be found via a search.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/promotion_rules/{{promotion_rule_id}}"
client["promotion_rules/{{promotion_rule_id}}"]
  .get.body
Response:
{
  "id": 101958,
  "rank": 100420,
  "Promotion Action Definition": {
    "type": "DiscountItem",
    "params": {
      "discount": 5,
      "discount_type": "amount",
      "item_price_attribute": "price",
      "item_conditions": {
        "$and": [
          {
            "item_line.item_primary_vendor_id": "100001"
          }
        ]
      }
    }
  },
  "Promotion Condition Definition": {
    "$and": [
      {
        "customer.customer.rewards_level": {
          "$eq": "gold"
        }
      }
    ]
  }
}
{"id"=>100511,
 "rank"=>102023,
 "Promotion Action Definition"=>
  {"type"=>"DiscountItem",
   "params"=>
    {"discount"=>5,
     "discount_type"=>"amount",
     "item_price_attribute"=>"price",
     "item_conditions"=>
      {"$and"=>[{"item_line.item_primary_vendor_id"=>"100001"}]}}},
 "Promotion Condition Definition"=>
  {"$and"=>[{"customer.customer.rewards_level"=>{"$eq"=>"gold"}}]}}

Search promotion rules

GET /api/promotion_rules

Promotion rules can be searched by GETting the root of the promotion rules resource. This API call will result in a search result record containing zero or more promotion rule records in the results attribute. See Search Results for more information on search results.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/promotion_rules/?per_page=1"
client["promotion_rules"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 109156,
      "rank": 100437,
      "Promotion Action Definition": {
        "type": "DiscountItem",
        "params": {
          "discount": 5,
          "discount_type": "amount",
          "item_price_attribute": "price",
          "item_conditions": {
            "$and": [
              {
                "item_line.item_primary_vendor_id": "100001"
              }
            ]
          }
        }
      },
      "Promotion Condition Definition": {
        "$and": [
          {
            "customer.customer.rewards_level": {
              "$eq": "gold"
            }
          }
        ]
      }
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>107871,
    "rank"=>102692,
    "Promotion Action Definition"=>
     {"type"=>"DiscountItem",
      "params"=>
       {"discount"=>5,
        "discount_type"=>"amount",
        "item_price_attribute"=>"price",
        "item_conditions"=>
         {"$and"=>[{"item_line.item_primary_vendor_id"=>"100001"}]}}},
    "Promotion Condition Definition"=>
     {"$and"=>[{"customer.customer.rewards_level"=>{"$eq"=>"gold"}}]}},
   "..."]}

Update a promotion rule

PUT /api/promotion_rules/{{promotion_rule_id}}

Promotion rules can be edited by PUTting a promotion rule record containing a valid subset of promotion rule attributes to the promotion rule's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"rank":106580,"Promotion Action Definition":{"type":"DiscountItem","params":{"discount":5,"discount_type":"amount","item_price_attribute":"price","item_conditions":{"$and":[{"item_line.item_primary_vendor_id":"100001"}]}}},"Promotion Condition Definition":{"$and":[{"customer.customer.rewards_level":{"$eq":"gold"}}]}}' "https://{{subdomain}}.retail.heartland.us/api/promotion/rules/104070"
client["promotion_rules/{{promotion_rule_id}}"]
  .put(my_promotion_rule_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Delete a promotion rule

DELETE /api/promotion_rules/{{promotion_rule_id}}

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/promotion_rules/{{promotion_rule_id}}"
client["promotion_rules/{{promotion_rule_id}}"]
  .delete.status
Response:
200
200

Coupons

The Coupons resource exposes the ability to create, retrieve, search, update and delete Coupons in the Heartland Retail system.

A coupon is considered active if it is not archived, not disabled and the current date and time is within start_at and end_at.

See Filtering for details on the filter expression syntax of condition_definition.

The coupon APIs make use of the coupon record type:

Coupon

A coupon is a record that represents a rule used in processing coupons and pricing.

id:
integer (auto-generated)
name:
text (required)

The name of this coupon.

code:
text (required)

The code of this coupon.

start_at:
DateTime

The date and time this coupon starts.

end_at:
DateTime

The date and time this coupon ends.

archived:
Boolean

Whether or not the coupon is archived.

disabled:
Boolean

Whether or not the coupon is disabled.

Promotion Action Definition:
action_definition

A filter expression.

Promotion Condition Definition:
condition_definition

A filter expression.

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

Coupon Example:
{
  "id": 1,
  "name": "name",
  "code": "10new",
  "Promotion Action Definition": {
    "type": "DiscountItem",
    "params": {
      "discount": 5,
      "discount_type": "amount",
      "item_price_attribute": "price",
      "item_conditions": {
        "$and": [
          {
            "item_line.item_primary_vendor_id": "100001"
          }
        ]
      }
    }
  },
  "Promotion Condition Definition": {
    "$and": [
      {
        "customer.customer.rewards_level": {
          "$eq": "gold"
        }
      }
    ]
  }
}

Create a coupon

POST /api/coupons

Coupons are created by POSTing a coupon record containing at least the required attributes to the /api/coupons resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"name":"name","code":"10new"}' "https://{{subdomain}}.retail.heartland.us/api/coupons"
client["coupons"]
  .post({"name"=>"name", "code"=>"10new"}))
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
{"id"=>1, "name"=>"name", "code"=>"10new"}

Retrieve a coupon

GET /api/coupons/{{coupon_id}}

Coupons are retrieved via their unique id. The id can be found via a search.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/coupons/{{coupon_id}}"
client["coupons/{{coupon_id}}"].get.body
Response:
{
  "id": 104582,
  "name": "name",
  "code": "10new",
  "Promotion Action Definition": {
    "type": "DiscountItem",
    "params": {
      "discount": 5,
      "discount_type": "amount",
      "item_price_attribute": "price",
      "item_conditions": {
        "$and": [
          {
            "item_line.item_primary_vendor_id": "100001"
          }
        ]
      }
    }
  },
  "Promotion Condition Definition": {
    "$and": [
      {
        "customer.customer.rewards_level": {
          "$eq": "gold"
        }
      }
    ]
  }
}
{"id"=>1,
 "name"=>"name",
 "code"=>"10new",
 "Promotion Action Definition"=>
  {"type"=>"DiscountItem",
   "params"=>
    {"discount"=>5,
     "discount_type"=>"amount",
     "item_price_attribute"=>"price",
     "item_conditions"=>
      {"$and"=>[{"item_line.item_primary_vendor_id"=>"100001"}]}}},
 "Promotion Condition Definition"=>
  {"$and"=>[{"customer.customer.rewards_level"=>{"$eq"=>"gold"}}]}}

Search Coupons

GET /api/coupons

Coupons can be searched by GETting the root of the Coupons resource. This API call will result in a search result record containing zero or more coupon records in the results attribute. See Search Results for more information on search results.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/coupons/?per_page=1"
client["coupons"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 1,
      "name": "name",
      "code": "10new",
      "Promotion Action Definition": {
        "type": "DiscountItem",
        "params": {
          "discount": 5,
          "discount_type": "amount",
          "item_price_attribute": "price",
          "item_conditions": {
            "$and": [
              {
                "item_line.item_primary_vendor_id": "100001"
              }
            ]
          }
        }
      },
      "Promotion Condition Definition": {
        "$and": [
          {
            "customer.customer.rewards_level": {
              "$eq": "gold"
            }
          }
        ]
      }
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>1,
    "name"=>"name",
    "code"=>"10new",
    "Promotion Action Definition"=>
     {"type"=>"DiscountItem",
      "params"=>
       {"discount"=>5,
        "discount_type"=>"amount",
        "item_price_attribute"=>"price",
        "item_conditions"=>
         {"$and"=>[{"item_line.item_primary_vendor_id"=>"100001"}]}}},
    "Promotion Condition Definition"=>
     {"$and"=>[{"customer.customer.rewards_level"=>{"$eq"=>"gold"}}]}},
   "..."]}

Update a coupon

PUT /api/coupons/{{coupon_id}}

Coupons can be edited by PUTting a coupon record containing a valid subset of coupon attributes to the coupon's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"name":"name","code":"10new","Promotion Action Definition":{"type":"DiscountItem","params":{"discount":5,"discount_type":"amount","item_price_attribute":"price","item_conditions":{"$and":[{"item_line.item_primary_vendor_id":"100001"}]}}},"Promotion Condition Definition":{"$and":[{"customer.customer.rewards_level":{"$eq":"gold"}}]}}' "https://{{subdomain}}.retail.heartland.us/api/coupons/103370"
client["coupons/{{coupon_id}}"]
  .put({"name"=>"name", "code"=>"10new"})
  .get.body
Response:
# ...
# Status: 200 OK
# ...

# No Content
{"id"=>1, "name"=>"name", "code"=>"10new"}

Delete a coupon

DELETE /api/coupons/{{coupon_id}}

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/coupons/{{coupon_id}}"
client["coupons/{{coupon_id}}"].delete.status
Response:
200
200

Action Types

The following promotion action types may be used to specify promotion behaviors on either Promotion Rules or Coupons. See Promotions for usage details.

DiscountItem

Applies the given discount to item lines on the transaction that match the given item_conditions. If item_conditions are not specified, applies to any item.

type:
text (required)

Must be DiscountItem

discount:
float (required)

Amount of the discount. The value here is dependent upon the discount_type. If discount_type is percent value should be the percent off divided by 100 (e.g. 25% off = 0.25). If discount_type is amount value should be the amount to subtract from the item's unit price. (e.g. $12.34 off = 12.34) If discount_type is fixed_price value should be the amount to use as the item's unit price (e.g. $12.34 per item = 12.34)

discount_type:
string (required)

The type of discount to apply to the matching items. See discount for more details. Valid options are amount, percent, and fixed_price.

item_price_attribute:
string

The date and time this promotion starts.

item_conditions:
Filter Expression

Which items on the transaction should receive the discount. See filtering docs for more details. If omitted, discount will apply to any item.

DiscountSubtotal

Applies the given discount to the transaction.

type:
text (required)

Must be DiscountSubtotal

discount:
float (required)

Amount of the discount. The value here is dependent upon the discount_type. If discount_type is percent value should be the percent off divided by 100 (e.g. 25% off = 0.25). If discount_type is amount value should be the amount to subtract from the item's unit price. (e.g. $12.34 off = 12.34)

discount_type:
string (required)

The type of discount to apply to transaction. See discount for more details. Valid options are amount, percent.

DiscountItem Example:
{
  "type": "DiscountItem",
  "discount": 0.25,
  "discount_type": "percent",
  "item_price_attribute": "price",
  "item_conditions": {
    "$and": [
      {
        "item_line.price": {
          "$gt": 100
        }
      }
    ]
  }
}
DiscountSubtotal Example:
{
  "type": "DiscountSubtotal",
  "discount": 0.25,
  "discount_type": "percent"
}

Locations

Location related resources include physical locations, POS stations, and cash drawers

Locations

A location represents a place where sales and inventory transactions can occur. This can be a physical store or it can represent a virtual store like an e-commerce site.

Location APIs make use of the location record type:

Location

A location represents a physical space where sales transactions can take place.

id:
Integer (auto-generated)

unique identifier for the record

metadata:
Object

custom key/value information stored about this location

name:
String (required)

The name of the location

address_id:
Integer

The unique identifier for the address record associated with this location

public_id:
String

a unique identifier provided by the user for the purpose of coding information

address_revision_id:
Integer

unique identifier for the current revision of the address associated with this location

active:
boolean

Whether or not this record is currently active and being used

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

timezone_identifier_id:
Integer (auto-generated)

unique identifier for the timezone record

created_by_user_id:
integer (auto-generated)

The user who created this record

updated_by_user_id:
integer (auto-generated)

The most recent user who updated this record

uuid:
String (auto-generated)

Unique identifier for the location

custom:
hash

An object that acts as a container for custom values defined in Heartland Retail as well as any arbitrary values stored by integrations or custom applications.

price_list_id:
Integer (auto-generated)

unique identifier for the price list record

settings:
Object

key/value information stored about this locations settings

credit_cards_configured:
boolean

Whether the location has a credit card processor configured or not

Location Example:
{
  "id": 100001,
  "name": "Boston",
  "address_id": 100004,
  "public_id": "BOS",
  "address_revision_id": 100016,
  "timezone_identifier_id": 1,
  "created_by_user_id": 108275,
  "updated_by_user_id": 108094,
  "uuid": "d0a77755-ddfb-4276-a523-afc7bb959b2d",
  "price_list_id": 1,
  "credit_cards_configured": "false"
}

Search locations

GET /api/locations

Search for and list locations

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/locations/?per_page=1"
client["locations"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100001,
      "name": "Boston",
      "address_id": 100004,
      "public_id": "BOS",
      "address_revision_id": 100016,
      "timezone_identifier_id": 1,
      "created_by_user_id": 108910,
      "updated_by_user_id": 102107,
      "uuid": "d0a77755-ddfb-4276-a523-afc7bb959b2d",
      "price_list_id": 1,
      "credit_cards_configured": "false"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>100001,
    "name"=>"Boston",
    "address_id"=>100004,
    "public_id"=>"BOS",
    "address_revision_id"=>100016,
    "timezone_identifier_id"=>1,
    "created_by_user_id"=>104393,
    "updated_by_user_id"=>102177,
    "uuid"=>"d0a77755-ddfb-4276-a523-afc7bb959b2d",
    "price_list_id"=>1,
    "credit_cards_configured"=>"false"},
   "..."]}

Purchasing

Purchasing APIs expose the ability to manage purchase orders, receipts, and returns.

Purchase Order

A purchase order is a record of items that have been or will be ordered from a vendor.

In order to complete a purchase order, it must have a receipt against it for all items on order.

Purchasing Order

id:
integer (auto-generated)
public_id:
text
status:
text (required)
start_shipments_at:
Date
end_shipments_at:
Date
vendor_id:
integer (required)
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

created_by_user_id:
integer
description:
text
receive_at_location_id:
integer (required)
custom:
object
total_qty:
numeric(10,2)
total_cost:
numeric(10,2)
total_price:
numeric(10,2)
total_received_qty:
numeric(10,2)
total_received_cost:
numeric(10,2)
total_received_price:
numeric(10,2)
total_open_qty:
numeric(10,2)
total_open_cost:
numeric(10,2)
total_open_price:
numeric(10,2)
initial_margin_ratio:
numeric
po_import_batch_id:
integer

Purchasing OrderLine

id:
integer (auto-generated)
item_id:
integer (required)
order_id:
integer (required)
qty:
numeric(10,2) (required)
unit_cost:
numeric(10,2) (required)
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

qty_received:
integer (required)
received_cost:
numeric
open_cost:
numeric
qty_expected:
numeric
status:
text
Purchasing Order Example:
{
  "id": 107595,
  "vendor_id": 102661,
  "created_by_user_id": 107936,
  "receive_at_location_id": 107981,
  "total_qty": 22.5,
  "total_cost": 67.8,
  "total_price": 89.44,
  "total_received_qty": 61.92,
  "total_received_cost": 37.03,
  "total_received_price": 55.36,
  "total_open_qty": 35.7,
  "total_open_cost": 43.44,
  "total_open_price": 43.62,
  "po_import_batch_id": 109088
}
Purchasing OrderLine Example:
{
  "id": 109071,
  "item_id": 105637,
  "order_id": 106165,
  "qty": 20.68,
  "unit_cost": 38.74,
  "qty_received": 100745
}

Create a purchase order

POST /api/purchasing/orders

Creating a purchase order requires a vendor and the location id. The location id is used to determine where the order will be received.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"vendor_id":100206,"receive_at_location_id":108247}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/orders"
client["purchasing/orders"]
  .post({"vendor_id"=>106389, "receive_at_location_id"=>101218})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/purchasing/orders/18213

Retrieve a purchase order

GET /api/purchasing/orders/{{purchase_order_id}}

A purchase order is retrieved using its unique identifier. This identifier can be found by searching for purchase orders, from references in other records, or from the Location header returned in response to the creation of a new purchase order.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/orders/{{purchase_order_id}}"
client["purchasing/orders/{{purchase_order_id}}"]
  .get.body
Response:
{
  "id": 103899,
  "vendor_id": 108524,
  "created_by_user_id": 106558,
  "receive_at_location_id": 107292,
  "total_qty": 61.55,
  "total_cost": 62.41,
  "total_price": 52.42,
  "total_received_qty": 26.29,
  "total_received_cost": 73.99,
  "total_received_price": 13.0,
  "total_open_qty": 83.12,
  "total_open_cost": 16.23,
  "total_open_price": 69.59,
  "po_import_batch_id": 101353
}
{"id"=>108250,
 "vendor_id"=>102000,
 "created_by_user_id"=>108341,
 "receive_at_location_id"=>108223,
 "total_qty"=>64.5,
 "total_cost"=>35.2,
 "total_price"=>65.44,
 "total_received_qty"=>97.44,
 "total_received_cost"=>77.54,
 "total_received_price"=>74.66,
 "total_open_qty"=>57.13,
 "total_open_cost"=>98.52,
 "total_open_price"=>15.36,
 "po_import_batch_id"=>105052}

Retrieve a purchase orders's lines

GET /api/purchasing/orders/{{purchase_order_id}}/lines

A purchase order has zero or more associated lines.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/orders/{{purchase_order_id}}/lines/?per_page=1"
client["purchasing/orders/{{purchase_order_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100685,
      "item_id": 109046,
      "order_id": 107505,
      "qty": 55.33,
      "unit_cost": 80.64,
      "qty_received": 109294
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>101022,
    "item_id"=>106027,
    "order_id"=>100302,
    "qty"=>88.89,
    "unit_cost"=>78.11,
    "qty_received"=>100787},
   "..."]}

Add an item to a purchase order

POST /api/purchasing/orders/{{purchase_order_id}}/lines

Adds an item with the given qty to the purchase order. This method can also be used to increment the quantity of an existing item line.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"item_id":103852,"order_id":108468,"qty":27.47,"unit_cost":58.97,"qty_received":102067}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/orders/{{purchase_order_id}}/lines"
client["purchasing/orders/{{purchase_order_id}}/lines"]
  .post({"item_id"=>104577, "order_id"=>102879, "qty"=>79.67, "unit_cost"=>87.41, "qty_received"=>101037})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/purchasing/orders/135894/lines/119686

Purchase Receipt

A purchase receipt is a record that documents the full or partial fulfillment of a purchase order. (For purchase orders, see Purchase Order)

Purchasing receipt APIs expose the ability to create, retrieve, and update receipts.

Purchasing Receipt

id:
integer (auto-generated)
status:
text (required)
order_id:
integer
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

custom:
object
public_id:
text

Purchasing ReceiptLine

id:
integer (auto-generated)
item_id:
integer (required)
qty:
numeric(10,2) (required)
unit_cost:
numeric(10,2)
receipt_id:
integer (required)
order_line_id:
integer
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

qty_expected:
numeric
qty_unauthorized:
numeric
Purchasing Receipt Example:
{
  "id": 104739,
  "order_id": 104987
}
Purchasing ReceiptLine Example:
{
  "id": 105531,
  "item_id": 108713,
  "qty": 55.62,
  "unit_cost": 97.62,
  "receipt_id": 106698,
  "order_line_id": 104060
}

Create a receipt

POST /api/purchasing/receipts

Creating a purchase receipt requires a vendor and the location id. The location id is used to determine where the inventory is being received.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/receipts"
client["purchasing/receipts"]
  .post({})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/purchasing/receipts/14878

Retrieve a receipt

GET /api/purchasing/receipts/{{purchase_receipt_id}}

A receipt is retrieved using its unique identifier. This identifier can be found by searching for receipts, from references in other records, or from the Location header returned in response to the creation of a new purchase order.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/receipts/{{purchase_receipt_id}}"
client["purchasing/receipts/{{purchase_receipt_id}}"]
  .get.body
Response:
{
  "id": 101554,
  "order_id": 100774
}
{"id"=>104488, "order_id"=>109706}

Retrieve a receipt's lines

GET /api/purchasing/receipts/{{purchase_receipt_id}}/lines

A receipt has zero or more associated lines.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/receipts/{{purchase_receipt_id}}/lines/?per_page=1"
client["purchasing/receipts/{{purchase_receipt_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 102290,
      "item_id": 109040,
      "qty": 10.88,
      "unit_cost": 14.86,
      "receipt_id": 100327,
      "order_line_id": 105220
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>106707,
    "item_id"=>107978,
    "qty"=>13.76,
    "unit_cost"=>52.58,
    "receipt_id"=>101327,
    "order_line_id"=>108690},
   "..."]}

Add an item to a receipt

POST /api/purchasing/receipts/{{purchase_receipt_id}}/lines

Adds an item with the given qty to the receipt. This method can also be used to modify the quantity of an existing item line.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"item_id":104372,"qty":48.5,"receipt_id":109152}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/receipts/{{purchase_receipt_id}}/lines"
client["purchasing/receipts/{{purchase_receipt_id}}/lines"]
  .post({"item_id"=>107641, "qty"=>26.66, "receipt_id"=>109112})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/purchasing/receipts/166376/lines/191025

Purchase Return

A purchase return is a record of an item that has been or will be returned to a vendor.

Purchase return APIs expose the ability to create, retrieve, and update returns.

Purchasing Receipt

id:
integer (auto-generated)
status:
text (required)
order_id:
integer
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

custom:
object
public_id:
text

Purchasing ReceiptLine

id:
integer (auto-generated)
item_id:
integer (required)
qty:
numeric(10,2) (required)
unit_cost:
numeric(10,2)
receipt_id:
integer (required)
order_line_id:
integer
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

qty_expected:
numeric
qty_unauthorized:
numeric
Purchasing Receipt Example:
{
  "id": 101337,
  "order_id": 102437
}
Purchasing ReceiptLine Example:
{
  "id": 106918,
  "item_id": 107654,
  "qty": 97.2,
  "unit_cost": 98.73,
  "receipt_id": 107172,
  "order_line_id": 108266
}

Create a return

POST /api/purchasing/returns

Creating a purchase return requires a vendor and the location id. The location id is used to determine where the inventory is coming from.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"vendor_id":100354,"return_from_location_id":104365}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/returns"
client["purchasing/returns"]
  .post({"vendor_id"=>103254, "return_from_location_id"=>108964})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/purchasing/returns/190550

Retrieve a return

GET /api/purchasing/returns/{{purchase_return_id}}

A purchase return is retrieved using its unique identifier. This identifier can be found by searching for purchase return, from references in other records, or from the Location header returned in response to the creation of a new purchase return.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/returns/{{purchase_return_id}}"
client["purchasing/returns/{{purchase_return_id}}"]
  .get.body
Response:
{
  "id": 100324,
  "vendor_id": 103449,
  "return_from_location_id": 104994
}
{"id"=>108322, "vendor_id"=>103174, "return_from_location_id"=>101461}

Retrieve a return's lines

GET /api/purchasing/returns/{{purchase_return_id}}/lines

A purchase return has zero or more associated lines.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/returns/{{purchase_return_id}}/lines/?per_page=1"
client["purchasing/returns/{{purchase_return_id}}/lines"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 101758,
      "item_id": 102950,
      "return_id": 105934,
      "qty": 97.37,
      "unit_cost": 64.59
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>105787,
    "item_id"=>105009,
    "return_id"=>103760,
    "qty"=>35.55,
    "unit_cost"=>61.68},
   "..."]}

Add an item to a return

POST /api/purchasing/returns/{{purchase_return_id}}/lines

Adds an item with the given qty to the purchase return. This method can also be used to modify the quantity of an existing item line.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"item_id":107511,"return_id":103880,"qty":41.94,"unit_cost":58.59}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/returns/{{purchase_return_id}}/lines"
client["purchasing/returns/{{purchase_return_id}}/lines"]
  .post({"item_id"=>109515, "return_id"=>102183, "qty"=>19.43, "unit_cost"=>42.15})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/purchasing/returns/198750/lines/149041

Purchase Vendor

The purchase vendor resource exposes the ability to create and modify purchase vendors in the Heartland Retail system.

Purchasing Vendor

id:
integer (auto-generated)
name:
text (required)
address_id:
integer
created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

public_id:
text
active:
boolean

Whether or not this record is currently active and being used

vendor_import_batch_id:
integer
Purchasing Vendor Example:
{
  "id": 107745,
  "address_id": 105037,
  "vendor_import_batch_id": 109501
}

Create a vendor

POST /api/purchasing/vendors

Purchase vendors are created by POSTing a purchase vendor record containing the required attributes to the /api/purchasing/vendors resource. When successful, the response headers will contain a Location header that indicates the url at which the newly created purchase vendor can be found. The vendor's unique id will be the last portion of that URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/vendors"
client["purchasing/vendors"]
  .post({})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/purchasing/vendors/196513

Retrieve a purchase vendor

GET /api/purchasing/vendors/{{vendor_id}}

Purchase vendors are retrieved from the Heartland Retail API via their unique id. The id can be found via searches, references from other records, or from the Location header in a Create Purchase Vendor response.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/vendors/{{vendor_id}}"
client["purchasing/vendors/{{vendor_id}}"]
  .get.body
Response:
{
  "id": 101870,
  "address_id": 103552,
  "vendor_import_batch_id": 105431
}
{"id"=>102082, "address_id"=>108991, "vendor_import_batch_id"=>107238}

Update a purchase vendor

PUT /api/purchasing/vendors/{{vendor_id}}

Purchase vendors can be edited by PUTting a purchase vendor record containing a valid subset of purchase vendor attributes to the purchase vendor's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"address_id":103322,"vendor_import_batch_id":107907}' "https://{{subdomain}}.retail.heartland.us/api/purchasing/vendors/100946"
client["purchasing/vendors/{{vendor_id}}"]
  .put(my_purchasing_vendor_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Search purchase vendors

GET /api/purchasing/vendors

Purchase vendors can be searched by GETting the root of the purchase vendors resource /api/purchasing/vendors. This API call will result in a search result record containing zero or more purchase vendor records in the values attribute. See Search Results for more information on search results.

Purchase vendors can be filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/purchasing/vendors/?per_page=1"
client["purchasing/vendors"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 105223,
      "address_id": 107496,
      "vendor_import_batch_id": 105024
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>102837, "address_id"=>107463, "vendor_import_batch_id"=>100695},
   "..."]}

Webhooks

The Webhooks resource exposes the ability to create, retrieve, search, update and delete Webhook in the Heartland Retail system.

Webhooks

Webhooks are limited to 10 URLs per event. Attempting to register more than that will return an error indicating which event(s) exceed the limit.

Webhooks retry once per hour for up to 72 hours. A webhook is considered successful when the handler returns a 200 status code.

The webhook APIs make use of the webhook record type:

Webhook

id:
integer (auto-generated)
url:
string (required)
events:
array (required)

available events

created_by_user_id:
integer (auto-generated)

The user who created this record

updated_by_user_id:
integer (auto-generated)

The most recent user who updated this record

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

Webhook Example:
{
  "id": 108890,
  "url": "http://example.org",
  "created_by_user_id": 105529,
  "updated_by_user_id": 102923
}

Create a webhook

POST /api/webhooks

Webhooks are created by POSTing a webhook record containing at least the required attributes to the /api/webhooks resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"url":"http://example.org"}' "https://{{subdomain}}.retail.heartland.us/api/webhooks"
client["webhooks"]
  .post({"url"=>"http://example.com", "events"=>["webhook_registered"]}))
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
{"id"=>1, "url"=>"http://example.com", "events"=>["webhook_registered"]}

Retrieve a webhook

GET /api/webhooks/{{webhook_id}}

Webhooks are retrieved via their unique id. The id can be found via a search.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/webhooks/{{webhook_id}}"
client["webhooks/{{webhook_id}}"].get.body
Response:
{
  "id": 102681,
  "url": "http://example.org",
  "created_by_user_id": 103647,
  "updated_by_user_id": 101983
}
{"id"=>108788,
 "url"=>"http://example.org",
 "created_by_user_id"=>107496,
 "updated_by_user_id"=>105194}

Search Webhooks

GET /api/webhooks

Webhooks can be searched by GETting the root of the Webhooks resource. This API call will result in a search result record containing zero or more webhook records in the results attribute. See Search Results for more information on search results.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/webhooks/?per_page=1"
client["webhooks"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 102918,
      "url": "http://example.org",
      "created_by_user_id": 101969,
      "updated_by_user_id": 100565
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>103495,
    "url"=>"http://example.org",
    "created_by_user_id"=>106262,
    "updated_by_user_id"=>108127},
   "..."]}

Update a webhook

PUT /api/webhooks/{{webhook_id}}

Webhooks can be edited by PUTting a webhook record containing a valid subset of webhook attributes to the webhook's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"url":"http://example.org","created_by_user_id":109976,"updated_by_user_id":102861}' "https://{{subdomain}}.retail.heartland.us/api/webhooks/102270"
client["webhooks/{{webhook_id}}"]
  .put(my_webhook_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Delete a webhook

DELETE /api/webhooks/{{webhook_id}}

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/webhooks/{{webhook_id}}"
client["webhooks/{{webhook_id}}"].delete.status
Response:
200
200

Events

webhook_registered

Occurs whenever a webhook is created.

Payload:

{
  "webhook": {
    "id": 1234,
    "url": "https://example.com/target",
    "events": [
      "customer_created",
      "customer_merged"
    ]
  }
}

customer_created

Occurs whenever a customer is created. Describes a customer.

Payload:

{
  "id": 1,
  "first_name": "First Name",
  "last_name": "Last Name",
  ...
}

customer_updated

Occurs whenever a customer has changed. Describes a customer.

Payload:

{
  "id": 1,
  "first_name": "First Name",
  "last_name": "Last Name",
  ...
}

customer_merged

Occurs whenever customers have merged.

Payload:

{
  "old_customer_ids": [1, 2, 3, 4],
  "new_customer_id": 5
}

sales_transaction_customer_selected

Occurs whenever a customer has been selected in sale transaction. Describes a customer and a sale transaction.

Payload:

{
  "customer": {
    "id": 1,
    "first_name": "First Name",
    "last_name": "Last Name",
    ...
  },
  "sales_transaction": {
    "id": 101388,
    "customer_id": 102262,
    "source_location_id": 103683,
    "station_id": 108059,
    "parent_transaction_id": 108668,
    "order_id": 103520,
    "total": 22.81,
    "created_by_user_id": 107176
    ...
  }
}

sales_transaction_completed

Occurs whenever sale transaction is completed. Describes a sale transaction.

Payload:

{
  "id": 101388,
  "customer_id": 102262,
  "source_location_id": 103683,
  "station_id": 108059,
  "parent_transaction_id": 108668,
  "order_id": 103520,
  "total": 22.81,
  "created_by_user_id": 107176
  ...
}

item_created

Occurs whenever item is created. Describes an item.

Payload:

{
  "id": 108162,
  "cost": 92.68,
  "price": 47.01,
  "financial_class_id": 103307,
  "import_batch_id": 103994,
  "primary_vendor_id": 108158,
  ...
}

item_updated

Occurs whenever item has changed. Describes an item.

Payload:

{
  "id": 108162,
  "cost": 92.68,
  "price": 47.01,
  "financial_class_id": 103307,
  "import_batch_id": 103994,
  "primary_vendor_id": 108158,
  ...
}

### purchasing_vendor_created
Occurs whenever purchasing vendor is created. Describes a [purchase vendor](#resource-purchase_vendor).

Payload:

```json
{
  "id": 103504,
  "address_id": 104772,
  "vendor_import_batch_id": 103806,
  ...
}

purchasing_vendor_updated

Occurs whenever purchasing vendor has changed. Describes a purchase vendor.

Payload:

{
  "id": 103504,
  "address_id": 104772,
  "vendor_import_batch_id": 103806,
  ...
}

promotion_rule_created

Occurs whenever promotion rule is created. Describes a promotion rule.

Payload:

{
  "id": 105928,
  "rank": 102965,
  "action_definition": [
    {
      "type": "DiscountSubtotal",
      "params": {
        "discount": 20,
        "discount_type": "amount"
      }
    }
  ],
  "condition_definition": {
    "$and": [
      {
        "customer.customer.rewards_level": {
          "$eq": "gold"
        }
      }
    ]
  }
}

promotion_rule_updated

Occurs whenever promotion rule has changed. Describes a promotion rule.

Payload:

{
  "id": 105928,
  "rank": 102965,
  "action_definition": [
    {
      "type": "DiscountSubtotal",
      "params": {
        "discount": 20,
        "discount_type": "amount"
      }
    }
  ],
  "condition_definition": {
    "$and": [
      {
        "customer.customer.rewards_level": {
          "$eq": "gold"
        }
      }
    ]
  }
}

Traffic

Traffic APIs expose the ability to create, retrieve, and update for traffic counters and counts. The traffic APIs make use of the traffic counter and traffic count records.

Traffic Counters

Traffic counters recognize shapes and count them as visitors. These counters can be set up on the entrances to the store or within the store. Traffic counters represent devices that could be assigned to locations.

TrafficCounter

id:
integer (auto-generated)
location_id:
integer

Location of the traffic counter

name:
text (required)

Counter name

original_name:
text (required)

Original device name (coming from integrations)

entrance:
boolean (required)

Is this a store entrance traffic counter?

zone:
text (required)

If not the entrance, the name of the zone

custom:
hash

An object that acts as a container for any arbitrary values stored by integrations or custom applications.

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

TrafficCounter Example:
{
  "id": 106213,
  "location_id": 103885
}

Create a counter

POST /api/traffic_counters

Creating a traffic counter requires a name, original_name (could be the same as name), entrance and zone. If you pass the location_id, the counter will be assigned to the location.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/traffic_counters"
client["traffic_counters"]
  .post({})
  .headers['Location']
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/traffic_counters/123450

Update a counter

PUT /api/traffic_counters/{{counter_id}}

A traffic counter can be modified by sending a PUT request to the record's unique URL. The contents of the request must contain a valid subset of traffic counter record attribute.

Request:
client[:traffic_counters][123].put(name: 'Boston').status
curl -v -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"name":"Boston"}' "https://{{subdomain}}.retail.heartland.us/api/traffic_counters/123"
Response:
200 # success!
# ...
# Status: 200 OK
# ...

# No Content.

Search counters

GET /api/traffic_counters

Traffic counters can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/traffic_counters/?per_page=1"
client["traffic_counters"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 103783,
      "location_id": 103682
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>[{"id"=>104624, "location_id"=>101721}, "..."]}

Traffic Counts

A traffic count is number of visitors for the given counter and datetime.

TrafficCounter

id:
integer (auto-generated)
location_id:
integer

Location of the traffic counter

name:
text (required)

Counter name

original_name:
text (required)

Original device name (coming from integrations)

entrance:
boolean (required)

Is this a store entrance traffic counter?

zone:
text (required)

If not the entrance, the name of the zone

custom:
hash

An object that acts as a container for any arbitrary values stored by integrations or custom applications.

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

TrafficCounter Example:
{
  "id": 107712,
  "location_id": 105799
}

Create a count

PUT /api/traffic_counts

Creating a traffic count requires a traffic_counter_id, datetime and value.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"traffic_counter_id":106389,"value":109081,"year":109759,"month":107370,"week":105495,"hour":104147,"date_id":102405,"time_id":100407}' "https://{{subdomain}}.retail.heartland.us/api/traffic_counts/104661"
client["traffic_counts"]
  .put(my_traffic_count_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Retrieve a count

GET /api/traffic_counts/{{count_id}}

A traffic count is retrieved using its unique identifier. This identifier can be found by searching for counts, from references in other records, or from the response to the creation of a new count.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/traffic_counts/{{count_id}}"
client["traffic_counts/{{count_id}}"].get.body
Response:
{
  "id": 101581,
  "traffic_counter_id": 102258,
  "value": 105296,
  "year": 103229,
  "month": 109945,
  "week": 106475,
  "hour": 102789,
  "date_id": 101095,
  "time_id": 106036
}
{"id"=>101852,
 "traffic_counter_id"=>101719,
 "value"=>102873,
 "year"=>109748,
 "month"=>106831,
 "week"=>102622,
 "hour"=>101469,
 "date_id"=>107022,
 "time_id"=>109176}

Search counts

GET /api/traffic_counts

Traffic counts can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/traffic_counts/?per_page=1"
client["traffic_counts"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 102131,
      "traffic_counter_id": 104556,
      "value": 102953,
      "year": 103237,
      "month": 106555,
      "week": 108429,
      "hour": 109939,
      "date_id": 104471,
      "time_id": 108054
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>100901,
    "traffic_counter_id"=>102021,
    "value"=>108107,
    "year"=>102853,
    "month"=>108074,
    "week"=>104122,
    "hour"=>105207,
    "date_id"=>107910,
    "time_id"=>107084},
   "..."]}

Permissions

Permissions APIs expose the ability to retrieve the list of available permissions.

Permissions

A permission is a named authorization granted to do something.

Permission

id:
text (required)

The name of the permission

description:
text

Description of the permission

Permission Example:
{
  "id": "role.manage",
  "description": "Authorize users to manage roles records"
}

Search permissions

GET /api/permissions

Permissions can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/permissions/?per_page=1"
client["permissions"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": "role.manage",
      "description": "Authorize users to manage roles records"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>"role.manage",
    "description"=>"Authorize users to manage roles records"},
   "..."]}

Roles

Roles APIs expose the ability to manage permissions and alert typesas as well as exposing an API to add or remove users from the given role.

Roles Records

A role is a collection of permissions with a name assigned to one or more users, and subscribed to one or more alert types.

Role

id:
integer (auto-generated)

The ID of the role record

name:
text (required)

The name of the role

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

users_count:
integer (computed)

Count of users with the role

Role Example:
{
  "id": 102763,
  "users_count": 103174
}

Search roles

GET /api/roles

Roles can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/roles/?per_page=1"
client["roles"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 108125,
      "users_count": 103096
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>[{"id"=>104829, "users_count"=>108249}, "..."]}

Create role

POST /api/roles

Roles are created by POSTing a role record containing the required attributes to the /api/roles resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/roles"
client["roles"]
  .post({ "name"=>"Sales Associate" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/roles/149766

Update a role

PUT /api/roles/{{role_id}}

Roles can be edited by PUTting a role record containing a valid subset of role attributes to the role's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"users_count":109525}' "https://{{subdomain}}.retail.heartland.us/api/roles/104020"
client["roles/{{role_id}}"]
  .put(my_role_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Get a role

GET /api/roles/{{role_id}}

Roles can be fetched by GETting the role's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}"
client["roles/{{role_id}}"].get.body
Response:
{
  "id": 104024,
  "users_count": 105640
}
{"id"=>108053, "users_count"=>106051}

Delete a role

DELETE /api/roles/{{role_id}}

Roles can be deleted by sending a DELETE request the role's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}"
client["roles/{{role_id}}"].delete.status
Response:
200
200

Roles Permissions

A role can authorize one ore more permissions and be assigned to one or multiple users. For more information on permissions see Permissions.

Permission

id:
text (required)

The name of the permission

description:
text

Description of the permission

Permission Example:
{
  "id": "role.manage",
  "description": "Authorize users to manage roles records"
}

Search permissions of the role

GET /api/roles/{{role_id}}/permissions

Roles permissions can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/permissions/?per_page=1"
client["roles/{{role_id}}/permissions"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": "role.manage",
      "description": "Authorize users to manage roles records"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>"role.manage",
    "description"=>"Authorize users to manage roles records"},
   "..."]}

Add a new permission to the role

PUT /api/roles/{{role_id}}/permissions

Permissions can be added to roles by PUTing their IDs to the role's permissions resource.

Request:
client["roles/123/permissions"].post({ "permission_ids"=>["customer.read", "role.manage"], "enabled"=>"true" }).get.body
curl -v -H "Authorization: Bearer {{Token}}" -X PUT -H "Content-Type: application/json" -d '{"permission_ids"=>["customer.read", "role.manage"], "enabled"=>"true"}' "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/permissions"
Response:
204 # No Content
# ...
# Status: 204 No Content
# ...

# No Content.

Get a permission of the role

GET /api/roles/{{role_id}}/permissions/{{permission_id}}

Role permissions can be fetched by GETting the role permission's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/permissions/{{permission_id}}"
client["roles/{{role_id}}/permissions/{{permission_id}}"]
  .get.body
Response:
{
  "id": 101831,
  "description": "Authorize users to manage roles records"
}
{"id"=>"role.manage", "description"=>"Authorize users to manage roles records"}

Remove a permission from the role

DELETE /api/roles/{{role_id}}/permissions/{{permission_id}}

Remove a permission from the role by sending a DELETE request to the role permission's URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/permissions/{{permission_id}}"
client["roles/{{role_id}}/permissions/{{permission_id}}"]
  .delete.status
Response:
200
200

Roles Alert Types

A role can be subscribed to one or more alert types. All users with the role will see alert types their roles are subscribed to.

Alerts AllType

id:
integer (auto-generated)
type:
text

Type of the alert

description:
text

Description of the alert

category:
text

Category of the alert

Alerts AllType Example:
{
  "id": 103616,
  "type": "SalesOrdersDistributableAlertType",
  "description": "Distributable Sales Orders",
  "category": "sales"
}

Search alert types of the role

GET /api/roles/{{role_id}}/alert_types

Roles alert types can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/alert_types/?per_page=1"
client["roles/{{role_id}}/alert_types"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100911,
      "type": "SalesOrdersDistributableAlertType",
      "description": "Distributable Sales Orders",
      "category": "sales"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>101951,
    "type"=>"SalesOrdersDistributableAlertType",
    "description"=>"Distributable Sales Orders",
    "category"=>"sales"},
   "..."]}

Subscribe the role to a new alert type

POST /api/roles/{{role_id}}/alert_types

Alert types can be added to roles by POSTing their IDs to the role's alert types resource.

When successful, the response headers will contain a Location header that indicates the url at which the newly created alert subscription can be found. The alert subscription's unique id will be the last portion of that URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/alert_types"
client["roles/123/alert_types"]
  .post({ "alert_type_id"=>"321" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/roles/118015/alert_types/193788

Get an alert type of the role

GET /api/roles/{{role_id}}/alert_types/{{alert_type_id}}

Role alert type can be fetched by GETting the role alert type's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/alert_types/{{alert_type_id}}"
client["roles/{{role_id}}/alert_types/{{alert_type_id}}"]
  .get.body
Response:
{
  "id": 104974,
  "type": "SalesOrdersDistributableAlertType",
  "description": "Distributable Sales Orders",
  "category": "sales"
}
{"id"=>105642,
 "type"=>"SalesOrdersDistributableAlertType",
 "description"=>"Distributable Sales Orders",
 "category"=>"sales"}

Unsubscribe the role from an alert type

DELETE /api/roles/{{role_id}}/alert_types/{{alert_type_id}}

Alert types can be removed from roles by sending a DELETE request to the role alert type's resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/alert_types/{{alert_type_id}}"
client["roles/{{role_id}}/alert_types/{{alert_type_id}}"]
  .delete.status
Response:
200
200

Roles Users

A role can be assigned to one or more users. For more information on managing users see Users.

User

id:
integer (auto-generated)

The ID of the user record

login:
text (required)

The unique username for the user

first_name:
text

First name of the user

last_name:
text

Last name of the user

email:
text (required)

Email address

phone:
text

Phone number

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

public_id:
text

The unique public identifier for the user

all_locations:
boolean

Whether the user has access to all locations or not

active:
boolean

Whether or not this record is currently active and being used

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

is_admin:
boolean

Whether the user is admin or not

is_account_owner:
boolean (required)

Whether the user is account owner or not

is_account_admin:
boolean (required)

(Deprecated) Whether the user is account admin or not

uuid:
uuid (auto-generated)

The UUID of the user record

sales_rep:
boolean

Whether the user is a sales representative or not

name:
string (computed)

First name and Last name of the user (or login if they are not set)

User Example:
{
  "id": 109045
}

Search users of the role

GET /api/roles/{{role_id}}/users

Roles users can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/users/?per_page=1"
client["roles/{{role_id}}/users"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100919
    },
    "..."
  ]
}
{"total"=>42, "pages"=>5, "results"=>[{"id"=>104952}, "..."]}

Add the role to users

POST /api/roles/{{role_id}}/users

Users can be added to roles by POSTing their IDs to the role's users resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/users"
client["roles/123/users"]
  .post({ "users"=>["222","333"] })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/roles/179233/users/199012

Remove the role from users

DELETE /api/roles/{{role_id}}/users

Users can be removed from roles by sending a DELETE request with their IDs to the role users resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/roles/{{role_id}}/users"
client["roles/{{role_id}}/users"].delete.status
Response:
200
200

Users

Users APIs expose the ability to manage users, roles, and permissions as well as exposing an API to retrieve alerts available for the given user.

Users Records

A user is a record storing information about end users of the system. Users can't be deleted because they are tied to other resources across the application. However, they can be marked as inactive when necessary.

User

id:
integer (auto-generated)

The ID of the user record

login:
text (required)

The unique username for the user

first_name:
text

First name of the user

last_name:
text

Last name of the user

email:
text (required)

Email address

phone:
text

Phone number

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

public_id:
text

The unique public identifier for the user

all_locations:
boolean

Whether the user has access to all locations or not

active:
boolean

Whether or not this record is currently active and being used

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

is_admin:
boolean

Whether the user is admin or not

is_account_owner:
boolean (required)

Whether the user is account owner or not

is_account_admin:
boolean (required)

(Deprecated) Whether the user is account admin or not

uuid:
uuid (auto-generated)

The UUID of the user record

sales_rep:
boolean

Whether the user is a sales representative or not

name:
string (computed)

First name and Last name of the user (or login if they are not set)

User Example:
{
  "id": 105167
}

Search users

GET /api/users

Users can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/users/?per_page=1"
client["users"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 106561
    },
    "..."
  ]
}
{"total"=>42, "pages"=>5, "results"=>[{"id"=>106418}, "..."]}

Create user

POST /api/users

Users are created by POSTing a user record containing the required attributes to the /api/users resource. The password is required and stored encrypted in the database.

When successful, the response headers will contain a Location header that indicates the url at which the newly created user can be found. The user's unique id will be the last portion of that URL.

You can also optionally set the users roles and locations with the create user request. To set roles, you can include role_ids with an array of Role ID's, or include is_admin with true as the value to grant the user full admin access. To set locations, you can pass location_ids with an array of Location ID's, or include all_locations with true as the value to give the user access to all locations.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/users"
client["users"]
  .post({ "first_name"=>"John", "last_name"=>"Doe", "login"=>"johndoe", "email"=>"john@doe.com", "password"=>"password1", "sales_rep"=>"true", "role_ids"=>["111","222"], "location_ids"=>["1111","2222"] })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/users/142378

Update a user

PUT /api/users/{{user_id}}

Users can be edited by PUTting a user record containing a valid subset of user attributes to the user's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/users/100852"
client["users/{{user_id}}"]
  .put(my_user_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Update current user

PUT /api/users/profile

Update the current user profile by PUTting a user record containing a valid subset of user attributes to the /profile resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/users/104411"
client["users/profile"].put(my_user_object).status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Get a user

GET /api/users/{{user_id}}

Users can be fetched by GETting the user's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}"
client["users/{{user_id}}"].get.body
Response:
{
  "id": 103611
}
{"id"=>108535}

Roles and Permissions

A user has one or more roles assigned to it. Each role grants at least one permission. For more information on managing roles see Roles.

Role

id:
integer (auto-generated)

The ID of the role record

name:
text (required)

The name of the role

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

users_count:
integer (computed)

Count of users with the role

User Permission

id:
integer (auto-generated)
role_id:
integer (required)
permission_id:
text (required)

Permission Identifier

user_id:
integer (required)
Role Example:
{
  "id": 107732,
  "users_count": 102283
}
User Permission Example:
{
  "id": 100846,
  "role_id": 108864,
  "user_id": 104100
}

Search roles of the user

GET /api/users/{{user_id}}/roles

Users roles can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/roles/?per_page=1"
client["users/{{user_id}}/roles"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 101885,
      "users_count": 104570
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>[{"id"=>103962, "users_count"=>102102}, "..."]}

Add a new role to the user

POST /api/users/{{user_id}}/roles

Users can be granted roles by POSTing them to the user's roles resource.

When successful, the response headers will contain a Location header that indicates the url at which the newly created role can be found. The role's unique id will be the last portion of that URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{}' "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/roles"
client["users/123/roles"]
  .post({ "role_id"=>"321" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/users/131897/roles/168472

Get a role of the user

GET /api/users/{{user_id}}/roles/{{role_id}}

User roles can be fetched by GETting the user role's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/roles/{{role_id}}"
client["users/{{user_id}}/roles/{{role_id}}"]
  .get.body
Response:
{
  "id": 104678,
  "users_count": 109421
}
{"id"=>101772, "users_count"=>104656}

Remove a role from the user

DELETE /api/users/{{user_id}}/roles/{{role_id}}

Remove a role from the user by sending a DELETE request to the user location's URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/roles/{{role_id}}"
client["users/{{user_id}}/roles/{{role_id}}"]
  .delete.status
Response:
200
200

Search permissions of the user

GET /api/users/{{user_id}}/permissions

Users permissions can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/permissions/?per_page=1"
client["users/{{user_id}}/permissions"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 101049,
      "role_id": 102486,
      "user_id": 104615
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>[{"id"=>106751, "role_id"=>103979, "user_id"=>108951}, "..."]}

User Locations

A user can have access to one or more locations. Only data attributed to those locations is accessible by the user. For more information on managing locations see Locations.

Location

A location represents a physical space where sales transactions can take place.

id:
Integer (auto-generated)

unique identifier for the record

metadata:
Object

custom key/value information stored about this location

name:
String (required)

The name of the location

address_id:
Integer

The unique identifier for the address record associated with this location

public_id:
String

a unique identifier provided by the user for the purpose of coding information

address_revision_id:
Integer

unique identifier for the current revision of the address associated with this location

active:
boolean

Whether or not this record is currently active and being used

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

timezone_identifier_id:
Integer (auto-generated)

unique identifier for the timezone record

created_by_user_id:
integer (auto-generated)

The user who created this record

updated_by_user_id:
integer (auto-generated)

The most recent user who updated this record

uuid:
String (auto-generated)

Unique identifier for the location

custom:
hash

An object that acts as a container for custom values defined in Heartland Retail as well as any arbitrary values stored by integrations or custom applications.

price_list_id:
Integer (auto-generated)

unique identifier for the price list record

settings:
Object

key/value information stored about this locations settings

credit_cards_configured:
boolean

Whether the location has a credit card processor configured or not

Location Example:
{
  "id": 100001,
  "name": "Boston",
  "address_id": 100004,
  "public_id": "BOS",
  "address_revision_id": 100016,
  "timezone_identifier_id": 1,
  "created_by_user_id": 108077,
  "updated_by_user_id": 106282,
  "uuid": "d0a77755-ddfb-4276-a523-afc7bb959b2d",
  "price_list_id": 1,
  "credit_cards_configured": "false"
}

Search locations of the user

GET /api/users/{{user_id}}/locations

Users locations can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/locations/?per_page=1"
client["users/{{user_id}}/locations"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 100001,
      "name": "Boston",
      "address_id": 100004,
      "public_id": "BOS",
      "address_revision_id": 100016,
      "timezone_identifier_id": 1,
      "created_by_user_id": 101033,
      "updated_by_user_id": 108908,
      "uuid": "d0a77755-ddfb-4276-a523-afc7bb959b2d",
      "price_list_id": 1,
      "credit_cards_configured": "false"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>100001,
    "name"=>"Boston",
    "address_id"=>100004,
    "public_id"=>"BOS",
    "address_revision_id"=>100016,
    "timezone_identifier_id"=>1,
    "created_by_user_id"=>108954,
    "updated_by_user_id"=>103035,
    "uuid"=>"d0a77755-ddfb-4276-a523-afc7bb959b2d",
    "price_list_id"=>1,
    "credit_cards_configured"=>"false"},
   "..."]}

Get a location of the user

GET /api/users/{{user_id}}/locations/{{location_id}}

User locations can be fetched by GETting the user location's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/locations/{{location_id}}"
client["users/{{user_id}}/locations/{{location_id}}"]
  .get.body
Response:
{
  "id": 100630,
  "name": "Boston",
  "address_id": 100004,
  "public_id": "BOS",
  "address_revision_id": 100016,
  "timezone_identifier_id": 1,
  "created_by_user_id": 104943,
  "updated_by_user_id": 108265,
  "uuid": "d0a77755-ddfb-4276-a523-afc7bb959b2d",
  "price_list_id": 1,
  "credit_cards_configured": "false"
}
{"id"=>100001,
 "name"=>"Boston",
 "address_id"=>100004,
 "public_id"=>"BOS",
 "address_revision_id"=>100016,
 "timezone_identifier_id"=>1,
 "created_by_user_id"=>106062,
 "updated_by_user_id"=>108313,
 "uuid"=>"d0a77755-ddfb-4276-a523-afc7bb959b2d",
 "price_list_id"=>1,
 "credit_cards_configured"=>"false"}

Add a new location to the user

POST /api/users/{{user_id}}/locations

Users can be granted access to locations by POSTing them to the user's locations resource.

When successful, the response headers will contain a Location header that indicates the url at which the newly created user location can be found. The user location's unique id will be the last portion of that URL.

If you want to grant access to all locations update the user record with all_locations=true flag instead.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"name":"Boston"}' "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/locations"
client["users/123/locations"]
  .post({ "location_id"=>"321" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/users/155255/locations/134348

Remove a location from the user

DELETE /api/users/{{user_id}}/locations/{{location_id}}

Remove access to a location from the user by sending a DELETE request to the user location's URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -X DELETE -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/locations/{{location_id}}"
client["users/{{user_id}}/locations/{{location_id}}"]
  .delete.status
Response:
200
200

Alerts

Alerts represents the events that require the user's attention. Each alert is marked with a color to represent its severity: green, yellow, red.

Alert

type:
text (required)

Type of the alert

color:
text (required)

The severity of the alert. Can be red, yellow or green

message:
text (required)

Human-readable message of the alert

info:
object (required)

Additional information related to the alert

count:
integer (required)

Count of times the alert has been triggered

Alert Example:
{
  "count": 102570
}

Get alerts of the user

GET /api/users/{{user_id}}/alerts

Users alerts can be fetched by querying the user alerts' URL and providing the location_id parameter.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/users/{{user_id}}/alerts/?per_page=1"
client["users/{{user_id}}/alerts"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "count": 101862
    },
    "..."
  ]
}
{"total"=>42, "pages"=>5, "results"=>[{"count"=>106095}, "..."]}

Payment Types

Payment Types APIs expose the ability to manage payment types.

Payment Types

A payment type is a record storing information about payment method.

Payment Type APIs make use of the payment_type record type:

PaymentType

id:
integer (auto-generated)
public_id:
text

The unique public identifier for this payment type. This can be used to provide your own naming scheme to your payment types.

name:
text (required)

Name of the payment type

payment_account_id:
integer

Financial account that you map to will be the account that is debited/credited when the journal entries are synced to a connected financial system.

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

kind:
text

Kind of the payment type (PaymentType by default or GiftCardPaymentType for gift card payments)

description:
text

Description of the payment type

custom_field_group:
text (auto-generated)

Name of the custom fields group

key:
text (auto-generated)

Key of the payment type

accept_on_sales_order:
boolean

Whether the payment type is accepted on sales order or not

default_to_amount_due:
boolean

Whether the payment amounts of this type should be defaulted to balance due or not

builtin:
boolean (auto-generated)

Whether the payment type is builtin or not

active:
boolean

Whether or not this record is currently active and being used

payment_process_type:
text

Processing type of the payment type (either manual, webhooks, heartland, or big_commerce). Manual means that the payment is processed with Heartland Retail.

check_balance_url:
text

URL to check the balance for webhooks payment types

capture_url:
text

URL to capture payments for webhooks payment types

refund_url:
text

URL to refund payments for webhooks payment types

void_url:
text

URL to void payments for webhooks payment types

deposit_account_id:
integer

Financial account that you map to will be the account that is credited/debited when the journal entries are synced to a connected financial system.

max_refund_amount:
numeric(10,2)

Maximum amount of allowed refund for the payment type

financial_error:
boolean (computed)

Whether the payment type is configured in financial system correctly or not

expiration_account_id:
integer

(Only for gift card payment types) Financial account that you map to will be the account that is credited/debited when the journal entries of gift card adjustments are synced to a connected financial system.

PaymentType Example:
{
  "id": 109963,
  "public_id": "cash",
  "name": "Cash",
  "payment_account_id": 104526,
  "kind": "PaymentType",
  "description": "Cash",
  "custom_field_group": "payment_type.cash",
  "key": "cash",
  "deposit_account_id": 106265,
  "max_refund_amount": 49.28,
  "expiration_account_id": 103578
}

Search payment types

GET /api/payment_types

Payment Types can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/payment_types/?per_page=1"
client["payment_types"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 107265,
      "public_id": "cash",
      "name": "Cash",
      "payment_account_id": 107494,
      "kind": "PaymentType",
      "description": "Cash",
      "custom_field_group": "payment_type.cash",
      "key": "cash",
      "deposit_account_id": 103035,
      "max_refund_amount": 94.03,
      "expiration_account_id": 102408
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>101820,
    "public_id"=>"cash",
    "name"=>"Cash",
    "payment_account_id"=>107387,
    "kind"=>"PaymentType",
    "description"=>"Cash",
    "custom_field_group"=>"payment_type.cash",
    "key"=>"cash",
    "deposit_account_id"=>105485,
    "max_refund_amount"=>50.19,
    "expiration_account_id"=>109064},
   "..."]}

Create payment type

POST /api/payment_types

Payment types are created by POSTing a payment type record containing the required attributes to the /api/payment_types resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"name":"Cash"}' "https://{{subdomain}}.retail.heartland.us/api/payment_types"
client["payment_types"]
  .post({ "name"=>"Custom Payment Type" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/payment_types/138991

Update a payment type

PUT /api/payment_types/{{payment_type_id}}

Payment types can be edited by PUTting a payment type record containing a valid subset of payment type attributes to the payment type's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"public_id":"cash","name":"Cash","payment_account_id":108670,"kind":"PaymentType","description":"Cash","custom_field_group":"payment_type.cash","key":"cash","deposit_account_id":105054,"max_refund_amount":51.64,"expiration_account_id":100881}' "https://{{subdomain}}.retail.heartland.us/api/payment_types/103741"
client["payment_types/{{payment_type_id}}"]
  .put(my_payment_type_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Get a payment type

GET /api/payment_types/{{payment_type_id}}

Payment types can be fetched by GETting the payment type's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/payment_types/{{payment_type_id}}"
client["payment_types/{{payment_type_id}}"]
  .get.body
Response:
{
  "id": 103612,
  "public_id": "cash",
  "name": "Cash",
  "payment_account_id": 106153,
  "kind": "PaymentType",
  "description": "Cash",
  "custom_field_group": "payment_type.cash",
  "key": "cash",
  "deposit_account_id": 102624,
  "max_refund_amount": 52.74,
  "expiration_account_id": 100955
}
{"id"=>108900,
 "public_id"=>"cash",
 "name"=>"Cash",
 "payment_account_id"=>100636,
 "kind"=>"PaymentType",
 "description"=>"Cash",
 "custom_field_group"=>"payment_type.cash",
 "key"=>"cash",
 "deposit_account_id"=>106367,
 "max_refund_amount"=>62.8,
 "expiration_account_id"=>109247}

Shipping

Shipping APIs expose the ability to manage shipping methods, carriers and shipments themselves.

Shipping Methods

The shipping methods resource exposes the ability to create and modify shipping methods in the Heartland Retail system.

Shipping Method

id:
integer (auto-generated)

The id of the shipping method record

metadata:
text

Custom key/value information stored about this shipping method

name:
text (required)

The name of the shipping method

active:
boolean

Whether or not this record is currently active and being used

income_account_id:
integer

Financial account that you map to will be the account that is debited/credited when the journal entries are synced to a connected financial system.

amount:
numeric(10,2) (required)

The cost of the shipping method that will be charged to the customer when this shipping method is applied to a Sales Order (if no amount is specified on the order)

uuid:
uuid (auto-generated)
financial_error:
boolean (computed)

Whether the shipping method is configured in financial system correctly or not

Shipping Method Example:
{
  "id": 102533,
  "name": "USPS",
  "income_account_id": 103899,
  "amount": 9.99
}

Search shipping methods

GET /api/shipping/methods

Shipping Methods can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/shipping/methods/?per_page=1"
client["shipping/methods"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 108962,
      "name": "USPS",
      "income_account_id": 101915,
      "amount": 9.99
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>103561, "name"=>"USPS", "income_account_id"=>102329, "amount"=>9.99},
   "..."]}

Get a shipping method

GET /api/shipping/methods/{{method_id}}

Shipping Methods can be fetched by GETting the shipping method's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/shipping/methods/{{method_id}}"
client["shipping/methods/{{method_id}}"].get.body
Response:
{
  "id": 104482,
  "name": "USPS",
  "income_account_id": 105623,
  "amount": 9.99
}
{"id"=>101114, "name"=>"USPS", "income_account_id"=>100606, "amount"=>9.99}

Create a shipping method

POST /api/shipping/methods

Shipping Methods are created by POSTing a shipping method record containing the required attributes to the /api/shipping/methods resource.

The amount specified on a shipping method is the default amount if no amount is specified on the order.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"name":"USPS","amount":9.99}' "https://{{subdomain}}.retail.heartland.us/api/shipping/methods"
client["shipping/methods"]
  .post({ "name"=>"USPS", "amount"=>"50" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/shipping/methods/143108

Update a shipping method

PUT /api/shipping/methods/{{method_id}}

Shipping Methods can be edited by PUTting an shipping method record containing a valid subset of shipping method attributes to the shipping method's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -X PUT -w "%{http_code}" -d '{"name":"USPS","income_account_id":106748,"amount":9.99}' "https://{{subdomain}}.retail.heartland.us/api/shipping/methods/101313"
client["shipping/methods/{{method_id}}"]
  .put(my_shipping_method_object)
  .status
Response:
# ...
# Status: 200 OK
# ...

# No Content
=> 200

Reason Codes

Reason Codes APIs expose the ability to manage reason codes.

Gift Card Adjustment Reasons

GiftCardAdjustmentReason

id:
integer (auto-generated)

The id of the adjustment record

name:
text (required)

The name of the reason

description:
text

The description of the reason

account_id:
integer

Financial account that you map to will be the account that is credited/debited when the journal entries are synced to a connected financial system.

active:
boolean

Whether or not this record is currently active and being used

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

builtin:
boolean (auto-generated)

Whether the reason is builtin or not

financial_error:
boolean (computed)

Whether the reason is configured in financial system correctly or not

GiftCardAdjustmentReason Example:
{
  "id": 100510,
  "account_id": 108491
}

Search reason codes

GET /api/reason_codes/gift_card_adjustment_reasons

Gift Card Adjustment Reasons can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/reason_codes/gift_card_adjustment_reasons/?per_page=1"
client["reason_codes/gift_card_adjustment_reasons"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 105942,
      "account_id": 100154
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>[{"id"=>108950, "account_id"=>104782}, "..."]}

Gift Card

Gift Card APIs expose the ability to manage gift cards.

Gift Cards

The gift cards resource exposes the ability to create and modify gift cards in the Heartland Retail system.

GiftCard

id:
integer (auto-generated)

The id of the gift card record

number:
text (required)

The number of the gift card (case insensitive alphanumeric with no special characters)

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

updated_at:
DateTime (auto-generated)

The date and time that this record was last updated (in ISO8601 format)

expires_at:
date

The date after which the gift card may no longer be used

uuid:
uuid (auto-generated)

The uuid of the gift card record

balance:
number (computed)

The current balance of the gift card

GiftCard Example:
{
  "id": 108830,
  "number": "GC12345",
  "expires_at": "2025-08-05"
}

Search gift cards

GET /api/gift_cards

Gift Cards can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/gift_cards/?per_page=1"
client["gift_cards"].query(per_page: 1).get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 103431,
      "number": "GC12345",
      "expires_at": "2025-08-05"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>101593, "number"=>"GC12345", "expires_at"=>"2025-08-05"}, "..."]}

Get a gift card by its number

GET /api/gift_cards/{{gift_card_number}}

Gift Cards can be fetched by GETting the gift card number's URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/gift_cards/{{gift_card_number}}"
client["gift_cards/{{gift_card_number}}"].get.body
Response:
{
  "id": 100026,
  "number": "GC12345",
  "expires_at": "2025-08-05"
}
{"id"=>106536, "number"=>"GC12345", "expires_at"=>"2025-08-05"}

Create a gift card

POST /api/gift_cards

Gift Cards are created by POSTing a gift card record containing the required attributes to the /api/gift_cards resource.

When successful, the response headers will contain a Location header that indicates the url at which the newly created gift card can be found. The gift card's unique number will be the last portion of that URL.

For more information on available adjustment reasons see Gift Card Adjustment Reasons.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"number":"GC12345"}' "https://{{subdomain}}.retail.heartland.us/api/gift_cards"
client["gift_cards"]
  .post({ "number"=>"GC123456", "reason_id"=>"1", "expires_at"=>"2025-08-05" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/gift_cards/1152

Adjustments

The adjustments resource exposes the ability to modify a gift card balance without a sales transaction.

For more information on available adjustment reasons see Gift Card Adjustment Reasons.

GiftCardAdjustment

id:
integer (auto-generated)

The id of the adjustment record

gift_card_id:
integer (required)

The id of the gift card record

reason_id:
integer (required)

The id of the Reason Code record

created_by_user_id:
integer

The id of the user that created the adjustment

delta_balance:
numeric(10,2) (required)

The amount of the adjustment

created_at:
DateTime (auto-generated)

The date and time that this record was created (in ISO8601 format)

local_created_at:
DateTime (auto-generated)

The date and time that this record was created in the location timezone (in ISO8601 format)

gift_card_number:
text (computed)

Gift Card Number

GiftCardAdjustment Example:
{
  "id": 107942,
  "gift_card_id": 103143,
  "reason_id": 103176,
  "created_by_user_id": 104597,
  "delta_balance": 50.34,
  "local_created_at": "2013-08-05T07:22:24-04:00"
}

Search gift card adjustments

GET /api/gift_card/adjustments

Gift Card Adjustments can be searched for, filtered and sorted by any of their properties. For more information on filtering search results see Filtering.

Request:
curl -H "Authorization: Bearer {{Token}}" "https://{{subdomain}}.retail.heartland.us/api/gift_card/adjustments/?per_page=1"
client["gift_card/adjustments"]
  .query(per_page: 1)
  .get.body
Response:
{
  "total": 42,
  "pages": 5,
  "results": [
    {
      "id": 108413,
      "gift_card_id": 106571,
      "reason_id": 104390,
      "created_by_user_id": 105448,
      "delta_balance": 72.58,
      "local_created_at": "2013-08-05T07:22:24-04:00"
    },
    "..."
  ]
}
{"total"=>42,
 "pages"=>5,
 "results"=>
  [{"id"=>108979,
    "gift_card_id"=>104882,
    "reason_id"=>107222,
    "created_by_user_id"=>100829,
    "delta_balance"=>38.14,
    "local_created_at"=>"2013-08-05T07:22:24-04:00"},
   "..."]}

Get a gift card adjustment

GET /api/gift_card/adjustments/{{adjustment_id}}

Gift Card Adjustments can be fetched by GETting the gift card adjustment's resource URL.

Request:
curl -H "Authorization: Bearer {{Token}}" -w "%{http_code}" "https://{{subdomain}}.retail.heartland.us/api/gift_card/adjustments/{{adjustment_id}}"
client["gift_card/adjustments/{{adjustment_id}}"]
  .get.body
Response:
{
  "id": 102162,
  "gift_card_id": 107105,
  "reason_id": 104291,
  "created_by_user_id": 107795,
  "delta_balance": 69.52,
  "local_created_at": "2013-08-05T07:22:24-04:00"
}
{"id"=>108734,
 "gift_card_id"=>100046,
 "reason_id"=>109948,
 "created_by_user_id"=>107265,
 "delta_balance"=>86.55,
 "local_created_at"=>"2013-08-05T07:22:24-04:00"}

Create a gift card adjustment

POST /api/gift_card/adjustments

Gift Card Adjustments are created by POSTing a gift card adjustment record containing the required attributes to the /api/gift_card/adjustments resource.

Request:
curl -H "Authorization: Bearer {{Token}}" -H "Content-Type: application/json" -w "%{http_code}" -d '{"gift_card_id":108504,"reason_id":101042,"delta_balance":49.71}' "https://{{subdomain}}.retail.heartland.us/api/gift_card/adjustments"
client["gift_card/adjustments"]
  .post({ "gift_card_id"=>"123456", "delta_balance"=>"50", "reason_id"=>"1" })
  .get.body
Response:
# ...
# Status: 201 Created
# ...

# No Content
/api/gift_card/adjustments/118415