API reference

Gift card endpoints

A gift card holds money. The shop sells it at its own till and makes it in Puntjes. The holder pays with it in one or more visits, until nothing is left. These endpoints let your till do what the counter phone does: read the gift card, take the amount of the sale off it or put it back, load a blank gift card that a customer buys, or undo that load.

The gift card code works like cash: whoever has it can spend it. So the code always goes in the JSON body, never in the URL, and the answers show only its last 4 characters. Do not write the code to your logs.

A gift card code is GIFT- and then 16 letters and digits, for example GIFT-7K2MQX4PR9TBWD3N. A till knows the scan of a gift card by GIFT- at the start. The QR code on a gift card holds the whole code, with GIFT-. The API also reads a code without GIFT-. Case, spaces and dashes do not count, so send the scan as it is.

Every endpoint answers 403 FEATURE_NOT_ENABLED until gift cards are switched on for the vendor. The lookup and the redeem keep working after the vendor's subscription ends: the customer already paid for the gift card. The undo of a redeem works then too. The load and its undo are part of the sale of a new gift card, so they answer 403 SUBSCRIPTION_EXPIRED then.


Read a gift card

POST /api/v1/gift-cards/lookup

Read what is left on a gift card without changing it. A gift card that can no longer be used still answers 200, with its status. An ended gift card can show an amount left that cannot be spent.

Request body

FieldTypeRequiredDescription
codestringYesThe gift card code as scanned or typed: GIFT- and then 16 characters. You can leave out GIFT-. Case, spaces and dashes do not count. At most 64 characters

Example request

{
    "code": "GIFT-7K2MQX4PR9TBWD3N"
}
curl -X POST https://puntjes.app/api/v1/gift-cards/lookup \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"code":"GIFT-7K2MQX4PR9TBWD3N"}'

Response

{
    "data": {
        "code_last4": "WD3N",
        "amount_left_cents": 3250,
        "ends_on": "2027-11-24",
        "status": "open",
        "vat_kind": "multi_purpose"
    }
}

Response fields

FieldDescription
code_last4The last 4 characters of the code, for the receipt
amount_left_centsWhat the gift card still holds, in cents
ends_onThe last day the gift card works (YYYY-MM-DD, Brussels time)
statusopen, used_up, ended or cancelled. Take an amount off only when it is open. More values can come: treat a value you do not know as not open
vat_kindsingle_purpose or multi_purpose: the VAT kind of the gift card. More values can come

Errors

CodeStatusDescription
FEATURE_NOT_ENABLED403Gift cards are not switched on for this vendor
GIFT_CARD_NOT_FOUND404No gift card of yours has this code. The code of another vendor gives this same answer

Take an amount off a gift card

POST /api/v1/gift-cards/redeem

Take the amount of the sale off the gift card. Send at most the amount_left_cents of the lookup: when the sale is more, the customer pays the rest another way. The answer is the gift card as it is now, in the same shape as the lookup. Keep the idempotency_key with the sale: when the sale does not go through, the undo of the redeem needs it.

Request body

FieldTypeRequiredDescription
codestringYesThe gift card code as scanned or typed: GIFT- and then 16 characters. You can leave out GIFT-. Case, spaces and dashes do not count. At most 64 characters
amount_centsintegerYesThe amount to take off, in cents. At least 1, at most what is left
idempotency_keystringYesYour own unique key for this payment, at most 255 characters. Send the same key again when you retry
branchstringNoYour own key for the branch of the sale: the external_id you gave it, at most 64 characters. Omit it to use the default branch of the API credential

Example request

{
    "code": "GIFT-7K2MQX4PR9TBWD3N",
    "amount_cents": 1750,
    "idempotency_key": "till-42-sale-981",
    "branch": "gent"
}
curl -X POST https://puntjes.app/api/v1/gift-cards/redeem \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"code":"GIFT-7K2MQX4PR9TBWD3N","amount_cents":1750,"idempotency_key":"till-42-sale-981","branch":"gent"}'

Response

{
    "data": {
        "code_last4": "WD3N",
        "amount_left_cents": 1500,
        "ends_on": "2027-11-24",
        "status": "open",
        "vat_kind": "multi_purpose"
    }
}

Retry with the same key

When the answer does not arrive (a timeout or a 5xx), send the same body with the same idempotency_key. The first payment counts once: the retry takes nothing more and answers 200 with the gift card as it is now. A 4xx answer took nothing, so you can send the same key again after you fix the cause. The key counts per gift card, so one sale that is paid with two gift cards can use one key for both.

After GIFT_CARD_AMOUNT_LEFT_TOO_LOW, read the gift card again and take at most amount_left_cents.

After the undo of a redeem, its key is spent. When the customer then pays again with the gift card, send that payment with a new key: the old key answers GIFT_CARD_REDEEM_UNDONE and takes nothing.

Errors

CodeStatusDescription
BRANCH_INACTIVE422The branch is deactivated. Activate it in the portal, or send another branch
BRANCH_NOT_FOUND422No branch of yours has this key
FEATURE_NOT_ENABLED403Gift cards are not switched on for this vendor
GIFT_CARD_AMOUNT_LEFT_TOO_LOW422The amount is more than the gift card holds, or the gift card is used up. Nothing was taken
GIFT_CARD_CANCELLED422The shop cancelled this gift card. Nothing was taken
GIFT_CARD_ENDED422The end date of the gift card is past. Nothing was taken
GIFT_CARD_NOT_FOUND404No gift card of yours has this code. The code of another vendor gives this same answer
GIFT_CARD_REDEEM_UNDONE422This idempotency_key belongs to a redeem that was taken back. Send the new payment with a new key. Nothing was taken
IDEMPOTENCY_KEY_CONFLICT422This idempotency_key was already used on this gift card for another amount

Put the amount of a redeem back on a gift card

POST /api/v1/gift-cards/redeem/undo

Put the amount of a redeem back when the sale does not go through: the cashier cancels the payment, deletes the gift card line, or the till cannot save the ticket. Send the code and the idempotency_key of the redeem. Only a client that knows that key can take the redeem back, and only within 10 minutes of the redeem. The whole amount of that redeem goes back, also on a gift card that the redeem used up: its status is open again. A gift card that ended after the redeem gets the amount back too, but stays ended. The answer is the gift card as it is now, in the same shape as the lookup.

A retry of the undo answers 200 again and puts nothing back twice. A redeem made on the counter phone or in the portal cannot be taken back through the API. The shop sees the redeem and its undo in the history of the gift card in the portal. A wallet pass that ended because the redeem used up the gift card stays ended. The customer can add the gift card to the wallet again.

Request body

FieldTypeRequiredDescription
codestringYesThe gift card code as scanned or typed: GIFT- and then 16 characters. You can leave out GIFT-. Case, spaces and dashes do not count. At most 64 characters
idempotency_keystringYesThe idempotency_key you sent with the redeem

Example request

{
    "code": "GIFT-7K2MQX4PR9TBWD3N",
    "idempotency_key": "till-42-sale-981"
}
curl -X POST https://puntjes.app/api/v1/gift-cards/redeem/undo \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"code":"GIFT-7K2MQX4PR9TBWD3N","idempotency_key":"till-42-sale-981"}'

Response

{
    "data": {
        "code_last4": "WD3N",
        "amount_left_cents": 5000,
        "ends_on": "2027-11-24",
        "status": "open",
        "vat_kind": "multi_purpose"
    }
}

Errors

CodeStatusDescription
FEATURE_NOT_ENABLED403Gift cards are not switched on for this vendor
GIFT_CARD_NOT_FOUND404No redeem of this till has this code and key. A wrong key, a redeem on the counter phone or in the portal, and a code of another vendor give this same answer
GIFT_CARD_REDEEM_UNDO_NOT_ALLOWED422More than 10 minutes went by since the redeem, or the shop cancelled the gift card. Nothing was put back

Load a blank gift card

POST /api/v1/gift-cards/load

A shop can print blank gift cards in advance. A blank card has a code but no amount yet. When a customer buys a gift card at your till, the cashier scans a blank card from the stack and your till loads it with the amount the customer paid. A loaded card cannot be loaded again.

The amount must be inside the gift card limits the shop set in the portal. The gift card works until ends_on. Leave ends_on out and the gift card works until exactly 2 years after today. The answer is the gift card, in the same shape as the lookup. With single_purpose, book the VAT at this sale; with multi_purpose, only when the gift card is used.

Request body

FieldTypeRequiredDescription
codestringYesThe gift card code as scanned or typed: GIFT- and then 16 characters. You can leave out GIFT-. Case, spaces and dashes do not count. At most 64 characters
amount_centsintegerYesThe amount the customer paid for the gift card, in cents. At least 1, and inside the gift card limits of the shop
idempotency_keystringYesYour own unique key for this load, at most 255 characters. Send the same key again when you retry, and with the undo
ends_onstringNoThe last day the gift card works (YYYY-MM-DD, Brussels time). At least 2 years after today. Leave it out for exactly 2 years after today
branchstringNoYour own key for the branch of the sale: the external_id you gave it, at most 64 characters. Omit it to use the default branch of the API credential

Example request

{
    "code": "GIFT-7K2MQX4PR9TBWD3N",
    "amount_cents": 2500,
    "idempotency_key": "till-42-load-7",
    "ends_on": "2028-11-25",
    "branch": "gent"
}
curl -X POST https://puntjes.app/api/v1/gift-cards/load \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"code":"GIFT-7K2MQX4PR9TBWD3N","amount_cents":2500,"idempotency_key":"till-42-load-7","ends_on":"2028-11-25","branch":"gent"}'

Response

{
    "data": {
        "code_last4": "WD3N",
        "amount_left_cents": 2500,
        "ends_on": "2028-11-25",
        "status": "open",
        "vat_kind": "multi_purpose"
    }
}

Retry with the same key

When the answer does not arrive, send the same body with the same idempotency_key. The card is loaded one time: the retry answers 200 with the same gift card. A 4xx answer loaded nothing. Keep the key with the sale on the ticket: the undo needs it.

Errors

CodeStatusDescription
BRANCH_INACTIVE422The branch is deactivated. Activate it in the portal, or send another branch
BRANCH_NOT_FOUND422No branch of yours has this key
FEATURE_NOT_ENABLED403Gift cards are not switched on for this vendor
GIFT_CARD_ALREADY_LOADED422The card is already loaded. Take another blank card. Nothing was loaded
GIFT_CARD_AMOUNT_OUT_OF_BOUNDS422The amount is outside the gift card limits of the shop. details.min_amount_cents and details.max_amount_cents give the limits. Nothing was loaded
GIFT_CARD_NOT_FOUND404No blank gift card of yours has this code. A gift card the shop did not make as a blank card, and a code of another vendor, give this same answer
IDEMPOTENCY_KEY_CONFLICT422This idempotency_key was already used for another load: another amount or another card

Undo the load of a gift card

POST /api/v1/gift-cards/load/undo

Take back a load when the cashier removes the gift card line from the ticket. Send the code and the idempotency_key of the load. Only a client that knows that key can take the load back, and only within 10 minutes of the load and before anybody uses the gift card. After the undo, the card is blank again and you can load it with a new key. One exception: when a wallet pass was already made for the gift card, the card stays stopped and cannot be loaded again. The answer has the gift card with status cancelled: the physical card is blank, the gift card itself is cancelled.

A retry of the undo answers 200 again and takes nothing back twice. A card that was loaded on the counter phone cannot be taken back through the API.

Request body

FieldTypeRequiredDescription
codestringYesThe gift card code as scanned or typed: GIFT- and then 16 characters. You can leave out GIFT-. Case, spaces and dashes do not count. At most 64 characters
idempotency_keystringYesThe idempotency_key you sent with the load

Example request

{
    "code": "GIFT-7K2MQX4PR9TBWD3N",
    "idempotency_key": "till-42-load-7"
}
curl -X POST https://puntjes.app/api/v1/gift-cards/load/undo \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"code":"GIFT-7K2MQX4PR9TBWD3N","idempotency_key":"till-42-load-7"}'

Response

{
    "data": {
        "code_last4": "WD3N",
        "amount_left_cents": 0,
        "ends_on": "2027-11-24",
        "status": "cancelled",
        "vat_kind": "multi_purpose"
    }
}

Errors

CodeStatusDescription
FEATURE_NOT_ENABLED403Gift cards are not switched on for this vendor
GIFT_CARD_NOT_FOUND404No load of this till has this code and key. A wrong key, a card loaded on the counter phone and a code of another vendor give this same answer
GIFT_CARD_UNDO_NOT_ALLOWED422More than 10 minutes went by since the load, somebody used the gift card, or the shop cancelled it. Nothing was taken back