Create Receipts

This section focuses on:

  • Structure of POST requests to the /receipts endpoint
  • Send receipt data to 7shifts

Creating sales data in 7shifts is handled through a POST request to the 7shifts /receipts endpoint.

Request URL

POST https://api.7shifts.com/v1/receipts

An example POST request to the /receipts endpoint to create a sales receipt looks as follows:

Request body

{
    "receipt": {
        "total": 4399,
        "open_date": "2020-07-01 10:00:15",
        "location_id": 12345,
        "external_id": "rec_98765"
    }
}

Here’s an explanation of each of the fields required in the request body:

Parameter

Type

Description

total

Numeric

The net total for the sales receipt in cents (pre-tax, pre-tips, post-discounts)

open_date

Text/Timestamp

The creation time of the receipt in your system in UTC timestamp

location_id

Numeric

The ID of the location in 7shifts that the receipt is for

external_id

Text

The ID of the sales receipt in your system (must be unique per 7shifts location)

Send receipts to 7shifts

Receipts need to be created in 7shifts as soon as they are opened in your system in order to ensure consistency between the two platforms.

As a result, as soon as a receipt is opened in your system, you will need to make a POST request to 7shifts’ /receipts endpoint in your system following the request structure described in the previous sub-section (POST structure for /receipts)

Errors

If an error message is returned stating "Duplicate receipt for this date/time" when trying to create a sales receipt, it could be because of one of the following scenarios:

  • The external_id specified is the same as another receipt for the same location.
  • The open_date specified has the exact same date, hour, minute & second as an existing receipt at the same location:
    • This error will only be seen at high-volume restaurant locations where multiple receipts are being opened in the same second.
    • If you face such an error, increment the second in the open_date by 1 and retry.
    • Have a 10-times retry limit in place so that the action doesn’t result in a deadlock.
    • If an open_date still can’t be found within a 10 second window, then grouping the two receipts together, sum up their total field values, and send them as one receipt.
    • Please bear in mind that updating such receipts would be tricky in the future, as one such 7shifts receipt would represent two or more receipts from your system.

Did this page help you?