Search Documentation

Search for a documentation page...

Gift Cards API

REST API endpoints for issuing, reading, editing and deactivating gift cards.

A gift card is stored value behind a 16-character code. A shopper spends it at checkout as a payment, not a discount: the card pays the order total, tax and shipping included, and the shopper's payment method pays whatever is left. Each card holds one currency, set when it is issued, and is spent only on a cart in that currency.

A card is either issued by hand (in the admin, or with Issue Gift Card below) or bought by a shopper as a gift card product, in which case it is created once the order is paid. How refunds of orders paid with gift cards work is under Create Refund. For the merchant's side, see Sell and accept gift cards.

Every endpoint on this page, reads included, needs the catalog:write scope. An OAuth app or MCP client acting for a team member also needs that member's permission to edit the catalog.

The code is returned once. Issue Gift Card answers with the full code in code, and no other response ever carries it again. Every other response shows only lastCharacters, the code's last four characters. Store the code or hand it over when you issue the card.

The Gift Card object

FieldTypeDescription
idstringUUID
lastCharactersstringThe code's last four characters, e.g. 6789. The full code is never returned after the issue
currencystringISO 4217 code the card holds, e.g. USD
initialValuestringValue at issue, in the smallest unit of currency ("5000" = 50.00 USD)
balancestringWhat the card has left, in the smallest unit of currency. "0" once the card is deactivated
statusstringactive (can be spent), expired (its expiresAt has passed) or deactivated (permanently switched off). A deactivated card reads deactivated whatever its expiry
expiresAtstring | nullISO 8601 date-time the card stops working; null = never
deactivatedAtstring | nullISO 8601 date-time the card was deactivated, or null
customerIdstring | nullThe customer who bought the card; null for a card issued by hand
createdAtstringISO 8601 date-time the card was issued

Money is a string in the smallest currency unit, like orders and refunds. No response carries the code after the issue, nor the card's recipient.


List Gift Cards

GET /api/v1/gift-cards

Returns the store's gift cards, newest first.

Query Parameters

ParameterTypeDefaultDescription
limitnumber20Gift cards per page (1-100)
offsetnumber0Gift cards to skip
statusstringallactive, expired, deactivated or all
balancestringallfull (never spent), partial, empty or all
querystring–The last characters of a code (up to 4), or a whole code with or without spaces
curl \
-H "Authorization: Bearer your_api_key" \
"https://your-store.yns.store/api/v1/gift-cards?status=active&balance=partial"

Response

{
"data": [
{
"id": "0191abc0-1234-7def-8000-0000000000c1",
"lastCharacters": "6789",
"currency": "USD",
"initialValue": "5000",
"balance": "3500",
"status": "active",
"expiresAt": null,
"deactivatedAt": null,
"customerId": null,
"createdAt": "2026-11-01T09:00:00.000Z"
}
],
"meta": {
"count": 1,
"offset": 0,
"limit": 20
}
}

An unknown status or balance value returns 400.


Issue Gift Card

POST /api/v1/gift-cards

Issues a gift card by hand, with the same checks as Issue gift card in the admin.

Request Body

FieldTypeRequiredDescription
amountnumberYesThe card's value in units of currency, not cents (e.g. 25 or 25.50). Above 0 and at most 2,000
currencystringNoISO 4217 code: the store currency (the default) or one of the store's enabled currencies
expiresAtstring | nullNoISO 8601 date-time the card stops working, in the future. Omit it or send null for no expiry
notestringNoInternal note, up to 1,000 characters, never shown to the customer
sendToEmailstringNoEmail the card to this address right after issuing it (the "New gift card" email). The address becomes the card's recipient
curl -X POST \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"amount": 50, "note": "Sorry for the late parcel", "sendToEmail": "ana@example.com"}' \
https://your-store.yns.store/api/v1/gift-cards

Response (201)

The card, plus:

  • code: the full code, in groups of four. This is the only time the API returns it. It is matched case- and space-insensitively at checkout.
  • email: { to, sent } when sendToEmail was given, null otherwise. sent: false means the email did not go out; the card is issued either way, so hand the code over yourself.
{
"id": "0191abc0-1234-7def-8000-0000000000c1",
"lastCharacters": "6789",
"currency": "USD",
"initialValue": "5000",
"balance": "5000",
"status": "active",
"expiresAt": null,
"deactivatedAt": null,
"customerId": null,
"createdAt": "2026-11-12T10:00:00.000Z",
"code": "abcd 2345 efgh 6789",
"email": {
"to": "ana@example.com",
"sent": true
}
}

Errors (400)

A 400 issues nothing. It is returned for a missing amount, an amount of 0 or below, above 2,000, or that rounds to nothing in the currency, and for:

{ "error": "`currency` must be the store currency or one of its enabled currencies" }
{ "error": "`expiresAt` must be in the future" }
{ "error": "`sendToEmail` is not a valid email address" }

Get Gift Card

GET /api/v1/gift-cards/:id

Returns one card by UUID, with its history. Never the code.

curl \
-H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/gift-cards/0191abc0-1234-7def-8000-0000000000c1

Response

The card, plus:

FieldTypeDescription
sourcestringissued (by hand) or purchased (bought as a gift card product)
orderIdstring | nullThe order that bought the card, for a purchased card
notestring | nullThe internal note
sentAtstring | nullWhen the card was last emailed
transactionsobject[]The card's ledger, newest first. See below

Each transaction:

FieldTypeDescription
idstringUUID
typestringissue, redeem (spent on an order), refund (credited back by a refund), adjustment or deactivate (the balance given up on deactivation)
amountstringSigned, in the smallest currency unit: positive adds to the balance, negative takes from it
statusstringpending (held by a checkout in progress), posted or void (a hold that was let go)
orderIdstring | nullThe order, when the transaction belongs to one
orderNumbernumber | nullThat order's number
refundIdstring | nullThe refund, for a refund transaction
actorTypestringWho made it: user (a team member), customer, api or system
createdAtstringISO 8601 date-time
{
"id": "0191abc0-1234-7def-8000-0000000000c1",
"lastCharacters": "6789",
"currency": "USD",
"initialValue": "5000",
"balance": "3500",
"status": "active",
"expiresAt": null,
"deactivatedAt": null,
"customerId": null,
"createdAt": "2026-11-01T09:00:00.000Z",
"source": "issued",
"orderId": null,
"note": "Sorry for the late parcel",
"sentAt": "2026-11-01T10:00:00.000Z",
"transactions": [
{
"id": "0191abc0-1234-7def-8000-0000000000e2",
"type": "redeem",
"amount": "-1500",
"status": "posted",
"orderId": "0191abc0-1234-7def-8000-0000000000d1",
"orderNumber": 1042,
"refundId": null,
"actorType": "customer",
"createdAt": "2026-11-05T12:00:00.000Z"
},
{
"id": "0191abc0-1234-7def-8000-0000000000e1",
"type": "issue",
"amount": "5000",
"status": "posted",
"orderId": null,
"orderNumber": null,
"refundId": null,
"actorType": "user",
"createdAt": "2026-11-01T09:00:00.000Z"
}
]
}

A card that does not exist, or belongs to another store, returns 404.


Update Gift Card

PATCH /api/v1/gift-cards/:id

Changes the expiry and the internal note. Nothing else about a card can change: its value, currency and code are fixed at issue. Send at least one of the two fields.

Request Body

FieldTypeRequiredDescription
expiresAtstring | nullNoISO 8601 date-time the card stops working; null removes the expiry. An expired card can be given a new date
notestringNoInternal note, up to 1,000 characters, never shown to the customer. An empty string clears it
curl -X PATCH \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"expiresAt": "2027-12-31T23:59:59Z"}' \
https://your-store.yns.store/api/v1/gift-cards/0191abc0-1234-7def-8000-0000000000c1

Response (200)

The card with its transactions, as Get Gift Card returns it. An empty body returns 400; an unknown card 404.


Deactivate Gift Card

POST /api/v1/gift-cards/:id/deactivate

Deactivates the card for good. A deactivated card can never be spent, reactivated or reloaded. Its open checkout holds are released, and its remaining balance is given up: a deactivate transaction records it and balance reads "0". Deactivating a card that is already deactivated changes nothing and returns it as it is.

curl -X POST \
-H "Authorization: Bearer your_api_key" \
https://your-store.yns.store/api/v1/gift-cards/0191abc0-1234-7def-8000-0000000000c1/deactivate

Response (200)

{
"id": "0191abc0-1234-7def-8000-0000000000c1",
"lastCharacters": "6789",
"currency": "USD",
"initialValue": "5000",
"balance": "0",
"status": "deactivated",
"expiresAt": null,
"deactivatedAt": "2026-11-12T10:00:00.000Z",
"customerId": null,
"createdAt": "2026-11-01T09:00:00.000Z"
}

A card that does not exist returns 404.


Errors

StatusMeaning
400Invalid query parameters or body, or an issue the store refuses (see Issue Gift Card)
401Missing or invalid API key
403The key lacks the catalog:write scope, or the person behind an OAuth connection may not edit the catalog
404Gift card not found