Developers

POS integration guide

Connect a till to OneCard with five HTTPS endpoints. The till sends what was sold, in pence; OneCard works out the points using the shop's own rules.

Overview

OneCard customers show a barcode (Code128) in the OneCard app. The barcode is the customer's membership code, for example OC-BK3E-D2BT. It contains no personal data.

There are two ways a till can work with OneCard:

  • Card at the till. The till's scanner reads the card, and the till sends the sale with the membership code. Points are awarded straight away and the till gets the new balance back.
  • Sale only. The till has no scanner, or the customer shows the card after paying. The till sends the sale without a code. It waits for up to 30 minutes until a member of staff scans the customer's card in the OneCard Shop app and picks the sale.

Either way the till never calculates points and staff never retype amounts.

Getting access

  1. Request access. The till supplier or the shop fills in the API access form.
  2. OneCard approves the shop for API access. We'll reply by email, usually within two working days.
  3. The shop owner creates a key in the OneCard Shop app: Settings → Till / POS connection → Create key. The key looks like oc_live_ followed by 32 letters and digits.
  4. The key is shown once. The owner enters it into the till's settings or sends it to you through a secure channel. OneCard stores only a hash; a lost key can't be recovered, only revoked and replaced.

Each key belongs to exactly one shop. A till supplier serving many shops holds one key per shop. Keep keys on the till or your server, never in a web page or mobile app that customers can download.

Basics

Base URLhttps://api.onecarduk.shop/api/v1
AuthAuthorization: Bearer oc_live_… (the shop's key)
FormatJSON in and out, UTF-8, HTTPS only
MoneyInteger pence, for example £12.50 is 1250
IdempotencySend an Idempotency-Key header (8 to 128 characters, unique per operation) on every POST
Rate limit120 requests a minute per key (60 a minute for refunds and redemptions)
TimesISO 8601 with offset, for example 2026-11-19T14:05:00Z

In the examples below $ONECARD_KEY holds the shop's key and $API is the base URL.

Till flows

OneCard till flows Flow A: the till scans the card, looks it up, sends the sale with the membership code and prints the new balance. Flow B: the till sends the sale without a card; staff scan the card in the OneCard Shop app within 30 minutes to award the points. Till / POS OneCard API OneCard Shop app A · CARD SCANNED AT THE TILL GET /pos/customers/{code} first name, balance, rewards first scan enrols the customer at this shop POST /pos/sales + membershipCode pointsAwarded, balance, unlocked print balance on receipt B · SALE ONLY, CARD SCANNED IN THE APP POST /pos/sales (no code) status: pending waits up to 30 minutes staff pick the sale + scan card points awarded
Flow A is fully automatic. Flow B needs no scanner on the till. A till can use both, for example when a customer forgets to show the card until after paying.

Endpoints

GET/pos/ping

Checks the key and returns the shop it belongs to. Call it when the key is entered in the till's settings and show the shop name so staff can confirm it.

curl -s "$API/pos/ping" -H "Authorization: Bearer $ONECARD_KEY"

{ "ok": true, "shop": { "id": "…", "name": "Dev Coffee House", "currency": "GBP" } }

GET/pos/customers/{code}

Call this when the till scans a OneCard. It returns what the till may show: the customer's first name, their balance at this shop and the rewards they can claim. The first time a shop looks up a card, the customer is enrolled at that shop (newlyEnrolled: true).

curl -s "$API/pos/customers/OC-BK3E-D2BT" -H "Authorization: Bearer $ONECARD_KEY"

{
  "firstName": "Emma",
  "membershipId": "OC-BK3E-D2BT",
  "balance": 120,
  "availableRewards": [
    { "offerId": "off_123", "title": "Free coffee", "pointsRequired": 100, "state": "unlocked" }
  ],
  "nextReward": { "offerId": "off_456", "title": "Free croissant", "pointsRequired": 200, "state": "locked" },
  "newlyEnrolled": false
}

Codes are checked with a check character, so a misread barcode returns 400 INVALID_MEMBERSHIP_CODE and a valid code that isn't a OneCard member returns 404 NOT_FOUND. In both cases ask the cashier to scan again or type the code.

POST/pos/sales

Send each completed sale once, after payment. receiptRef is your unique receipt or transaction number for this shop: OneCard will never award points twice for the same receipt.

FieldTypeNotes
amountMinorinteger, requiredTotal paid in pence, after discounts. Must be above 0.
receiptRefstring, required1 to 64 characters: letters, digits and . _ : / # -
membershipCodestring, optionalThe scanned card. Leave it out to create a waiting sale.
itemsarray, optionalUp to 200 of { sku, name?, qty, unitMinor? }
occurredAtdate-time, optionalWhen the sale happened. Defaults to now.

With a card: points awarded now

curl -s -X POST "$API/pos/sales" \
  -H "Authorization: Bearer $ONECARD_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: sale-R-000123" \
  -d '{
    "membershipCode": "OC-BK3E-D2BT",
    "amountMinor": 1250,
    "receiptRef": "R-000123",
    "items": [
      { "sku": "LATTE-L", "name": "Large latte", "qty": 2, "unitMinor": 375 },
      { "sku": "CROISSANT", "qty": 2, "unitMinor": 250 }
    ]
  }'

Response 201:

{
  "status": "awarded",
  "transactionId": "…",
  "receiptRef": "R-000123",
  "pointsAwarded": 12,
  "balance": 132,
  "unlockedRewards": [ … ],
  "newlyEnrolled": false,
  "replayed": false,
  "customer": { "firstName": "Emma", "balance": 132, "availableRewards": [ … ], "nextReward": { … } }
}

Without a card: a waiting sale

Leave out membershipCode. The sale appears in the OneCard Shop app for 30 minutes. When staff pick it and scan the customer's card, the points are awarded. If the till later sends the same receiptRef with a membershipCode, the waiting sale is settled instead.

curl -s -X POST "$API/pos/sales" \
  -H "Authorization: Bearer $ONECARD_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: sale-R-000124" \
  -d '{ "amountMinor": 640, "receiptRef": "R-000124" }'

{
  "status": "pending",
  "sale": {
    "id": "…", "receiptRef": "R-000124", "amountMinor": 640, "items": [],
    "status": "pending", "occurredAt": "2026-11-19T14:05:00.000Z",
    "expiresAt": "2026-11-19T14:35:00.000Z", "createdAt": "2026-11-19T14:05:00.000Z"
  },
  "replayed": false
}

POST/pos/sales/{receiptRef}/refund

Call this when a sale is refunded. If points were awarded they are taken back; if the sale was still waiting it is cancelled. Calling it again is safe and returns replayed: true. The body is optional.

curl -s -X POST "$API/pos/sales/R-000123/refund" \
  -H "Authorization: Bearer $ONECARD_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: refund-R-000123" \
  -d '{ "reason": "Customer returned items" }'

{ "status": "refunded", "receiptRef": "R-000123", "pointsReversed": 12, "balance": 120, "replayed": false }

A waiting sale returns { "status": "cancelled", "receiptRef": "R-000124" }. Partial refunds aren't supported yet: refund the sale and send a new one for the amount kept, with a new receiptRef.

POST/pos/redemptions

Redeem a reward the customer chose from availableRewards. The points are deducted and a reference code is returned to print on the receipt. Idempotency-Key is required.

curl -s -X POST "$API/pos/redemptions" \
  -H "Authorization: Bearer $ONECARD_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6f1c2b8e-0c7a-4c1e-9d55-2f7a1d2b9e10" \
  -d '{ "membershipCode": "OC-BK3E-D2BT", "offerId": "off_123" }'

{
  "redemption": { "id": "…", "code": "7KQ2M9XDPA", "offerTitle": "Free coffee", "pointsSpent": 100 },
  "balance": 32,
  "replayed": false
}

Errors & retries

Errors always have the same shape:

{ "error": { "code": "RECEIPT_ALREADY_AWARDED", "message": "Points were already awarded for this receipt", "details": null } }
StatusCodeWhat to do
400VALIDATION_ERRORFix the request. details lists each field problem.
400IDEMPOTENCY_KEY_REQUIRED, IDEMPOTENCY_KEY_INVALIDSend an Idempotency-Key of 8 to 128 characters.
400INVALID_MEMBERSHIP_CODEThe scanned code is not a OneCard code (often a misread). Scan again.
401UNAUTHENTICATEDThe key is missing, wrong or revoked. Ask the owner for a new key.
403FORBIDDENThe shop is not active or API access is not enabled for it.
404NOT_FOUNDUnknown card, sale or reward. Scan again or check the reference.
409RECEIPT_ALREADY_AWARDEDThis receipt already earned points. Treat as done; do not retry.
409RECEIPT_CONFLICTThe same receiptRef was sent with a different amount. Check your receipt numbering.
429RATE_LIMITEDWait and retry with back-off.
5xxRetry with the same Idempotency-Key.

Retrying safely

  • Use a timeout of about 10 seconds. On a timeout, network error, 429 or 5xx, retry with the same Idempotency-Key and body after 1 s, 2 s, 4 s and so on, up to about a minute.
  • A retried request that already succeeded returns the original result with replayed: true.
  • Never block the sale on OneCard. If OneCard can't be reached, finish the sale and send it later from a queue; the customer still gets the points within the 30-minute window or when staff attach it.

Printing on the receipt

After an awarded sale, print a short loyalty block using the response:

--------------------------------
OneCard  ·  Hi Emma
Points this visit:          +12
Balance at Dev Coffee House: 132
Free coffee is ready to claim!
--------------------------------
  • Print the first name only; never print the full membership code. If you print it at all, mask it: OC-••••-D2BT.
  • Use unlockedRewards for "ready to claim" lines and customer.nextReward for "88 points to a Free croissant".
  • For a waiting sale, print "Show your OneCard to staff within 30 minutes to collect your points".
  • For a redemption, print the reward title and the redemption.code.

Test checklist

Ask us for a test shop when you request access. Before going live, check each item:

  • GET /pos/ping shows the right shop name in your settings screen.
  • Scanning a OneCard barcode (Code128) in the app fills in the membership code, with or without dashes.
  • A sale with a card returns pointsAwarded and the balance is printed on the receipt.
  • The same sale sent twice (same receiptRef) does not award points twice.
  • A network failure mid-request is retried with the same Idempotency-Key.
  • A sale without a card appears in OneCard Shop under waiting till sales and can be claimed by scanning the card.
  • A refund takes the points back; refunding twice is harmless.
  • A reward from availableRewards can be redeemed and its code printed.
  • Amounts are in pence after discounts (a £12.50 sale is 1250).
  • A revoked key shows a clear "key not valid" message to staff.
  • The till keeps working when OneCard is unreachable.