Gift cards API
Every Gift cards action (11) and data model (3): endpoints, scopes, input, preconditions, events and examples.
Gift cards with a code, a balance, an expiry date and a full history.
Module code gift_cards · 11 actions · 3 data models · 7 events. A key or token never does more here than the person behind it can; row-level security applies exactly as in the app. Scopes: gift_cards (everything), gift_cards:read (read only) or gift_cards:<capability>.
Resources
| Resource | Table | List and read | POST | PATCH | DELETE |
|---|---|---|---|---|---|
gift_card_events | gift_card_event | /api/v1/gift_card_events | |||
gift_card_holds | gift_card_hold | /api/v1/gift_card_holds | |||
gift_cards | gift_card | /api/v1/gift_cards |
Lists take limit (up to 200), cursor, order (e.g. -created_at), fields and q; every other query parameter is a column filter: ?status=paid, ?total[gte]=100, ?id[in]=a,b, ?x=null.
Actions
| Action | Needs | What it does |
|---|---|---|
gift_cards.add_note | gift_cards:write | Add a note |
gift_cards.bulk_issue | gift_cards:write | Issue gift cards in bulk |
gift_cards.expire_due | gift_cards:manage | Deactivate expired cards |
gift_cards.issue | gift_cards:write | Issue a gift card |
gift_cards.redeem | gift_cards:write | Redeem a gift card |
gift_cards.refund | gift_cards:manage | Refund onto a gift card |
gift_cards.reset_balance | gift_cards:manage | Correct the balance |
gift_cards.send | gift_cards:write | Send to customer |
gift_cards.set_active | gift_cards:manage | Activate or deactivate |
gift_cards.set_expiry | gift_cards:manage | Change the expiry |
gift_cards.site_apply | gift_cards:write | Use a gift card (site) |
gift_cards.add_note
Add a note — A line in the card’s history.
Needs gift_cards:write · changes data
https://app.getera.io/api/v1/gift_card_events/actions/add_note- Canonical address:
POST /api/v1/actions/gift_cards.add_note
Input
| Field | Type | Required | Notes |
|---|---|---|---|
id | uuid | yes | Gift card · id of gift_card |
message | string | yes | Note · max 2000 |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_not_found | The card must exist. |
Events it publishes: gift_cards.updated
What it writes: gift_card_event (insert) — Records the note
curl -X POST https://app.getera.io/api/v1/gift_card_events/actions/add_note \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"id":"GIFT_CARD_ID","message":"Note"}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCardEvents.addNote({
id: "GIFT_CARD_ID",
message: "Note"
})era gift_card_events add_note \
--id "GIFT_CARD_ID" \
--message "Note"{
"name": "era__gift_cards__add_note",
"arguments": {
"id": "GIFT_CARD_ID",
"message": "Note"
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:write · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_not_found · 429 slow down
gift_cards.bulk_issue
Issue gift cards in bulk — Many cards with the same balance and expiry, each with its own code.
Needs gift_cards:write · changes data
https://app.getera.io/api/v1/gift_cards/actions/bulk_issue- Canonical address:
POST /api/v1/actions/gift_cards.bulk_issue
Input
| Field | Type | Required | Notes |
|---|---|---|---|
count | number | yes | How many |
amount | number (money) | yes | Balance |
currency | string | Currency · max 3 | |
expiryDate | date | Expires | |
isActive | boolean | Active straight away | |
note | string | Note · max 2000 |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
invalid_gift_card_count | Between 1 and 500 cards at a time. |
gift_card_amount_not_positive | A gift card is worth more than zero. |
invalid_currency | The currency must be an ISO-4217 code. |
gift_card_expiry_in_past | The expiry cannot already have passed. |
Events it publishes: gift_cards.issued
What it writes: gift_card (insert) — Issues the cards; gift_card_event (insert) — Records each issue
curl -X POST https://app.getera.io/api/v1/gift_cards/actions/bulk_issue \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"count":1,"amount":1}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.issued"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCards.bulkIssue({
count: 1,
amount: 1
})era gift_cards bulk_issue \
--count 1 \
--amount 1{
"name": "era__gift_cards__bulk_issue",
"arguments": {
"count": 1,
"amount": 1
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:write · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 invalid_gift_card_count, gift_card_amount_not_positive, invalid_currency, gift_card_expiry_in_past · 429 slow down
gift_cards.expire_due
Deactivate expired cards — Closes every active card whose expiry date has passed.
Needs gift_cards:manage · changes data
https://app.getera.io/api/v1/gift_card_events/actions/expire_due- Canonical address:
POST /api/v1/actions/gift_cards.expire_due
Input
| Field | Type | Required | Notes |
|---|---|---|---|
asOf | date | As of |
Events it publishes: gift_cards.status_changed
What it writes: gift_card (update) — Deactivates it; gift_card_event (insert) — Records why
curl -X POST https://app.getera.io/api/v1/gift_card_events/actions/expire_due \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"asOf":"2026-11-02"}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.status_changed"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCardEvents.expireDue({
asOf: "2026-11-02"
})era gift_card_events expire_due \
--as-of "2026-11-02"{
"name": "era__gift_cards__expire_due",
"arguments": {
"asOf": "2026-11-02"
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 429 slow down
gift_cards.issue
Issue a gift card — A new card with a balance, a code and an optional expiry.
Needs gift_cards:write · changes data
https://app.getera.io/api/v1/gift_cards/actions/issue- Canonical address:
POST /api/v1/actions/gift_cards.issue
Input
| Field | Type | Required | Notes |
|---|---|---|---|
amount | number (money) | yes | Balance |
currency | string | Currency · max 3 | |
code | string | Code · Left empty, a code is generated. · max 16 | |
expiryDate | date | Expires | |
customerId | uuid | Given to · id of customer | |
issuedToEmail | |||
note | string | Note · max 2000 | |
sourceModule | string | Bought in · max 40 | |
sourceRecordId | uuid | Source record |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_amount_not_positive | A gift card is worth more than zero. |
invalid_currency | The currency must be an ISO-4217 code. |
invalid_gift_card_code | A code is 8 to 16 letters, digits or dashes. |
gift_card_expiry_in_past | The expiry cannot already have passed. |
gift_card_code_taken | Codes are unique in the workspace. |
Events it publishes: gift_cards.issued
What it writes: gift_card (insert) — Issues the card; gift_card_event (insert) — Records the issue
curl -X POST https://app.getera.io/api/v1/gift_cards/actions/issue \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"amount":1}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.issued"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCards.issue({
amount: 1
})era gift_cards issue \
--amount 1{
"name": "era__gift_cards__issue",
"arguments": {
"amount": 1
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:write · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_amount_not_positive, invalid_currency, invalid_gift_card_code, gift_card_expiry_in_past, gift_card_code_taken · 429 slow down
gift_cards.redeem
Redeem a gift card — Spends from the balance. Idempotent: a retried redemption spends nothing twice.
Needs gift_cards:write · changes data
https://app.getera.io/api/v1/gift_cards/{id}/actions/redeem- Canonical address:
POST /api/v1/actions/gift_cards.redeem
Input
| Field | Type | Required | Notes |
|---|---|---|---|
code | string | Code · max 16 | |
giftCardId | uuid | Filled from the path {id} · Gift card · id of gift_card | |
amount | number (money) | yes | Amount |
currency | string | yes | Currency · max 3 |
sourceModule | string | Spent in · max 40 | |
sourceRecordId | uuid | Order or checkout | |
idempotencyKey | string | Idempotency key · max 512 |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_not_found | The card must exist. |
gift_card_inactive | A deactivated card is not redeemed. |
gift_card_expired | An expired card is not redeemed. |
gift_card_currency_mismatch | The card pays only in its own currency. |
gift_card_insufficient_balance | A redemption never exceeds the balance. |
Events it publishes: gift_cards.redeemed
What it writes: gift_card (update) — Lowers the balance; gift_card_event (insert) — Records the redemption
curl -X POST https://app.getera.io/api/v1/gift_cards/GIFT_CARD_ID/actions/redeem \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"amount":1,"currency":"Currency"}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.redeemed"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCards.redeem("GIFT_CARD_ID", {
amount: 1,
currency: "Currency"
})era gift_cards redeem GIFT_CARD_ID \
--amount 1 \
--currency "Currency"{
"name": "era__gift_cards__redeem",
"arguments": {
"giftCardId": "GIFT_CARD_ID",
"amount": 1,
"currency": "Currency"
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:write · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_not_found, gift_card_inactive, gift_card_expired, gift_card_currency_mismatch, gift_card_insufficient_balance · 429 slow down
gift_cards.refund
Refund onto a gift card — Puts money that was spent from the card back onto it.
Needs gift_cards:manage · removes or cannot be undone · asks a person to confirm when Era runs it
https://app.getera.io/api/v1/gift_cards/{id}/actions/refund- Canonical address:
POST /api/v1/actions/gift_cards.refund
Input
| Field | Type | Required | Notes |
|---|---|---|---|
id | uuid | yes | Filled from the path {id} · Gift card · id of gift_card |
amount | number (money) | yes | Amount |
sourceModule | string | Refunded from · max 40 | |
sourceRecordId | uuid | Order | |
reason | string | Reason · max 2000 | |
idempotencyKey | string | Idempotency key · max 512 |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_not_found | The card must exist. |
gift_card_refund_exceeds_spent | Only what was spent can come back. |
Events it publishes: gift_cards.refunded
What it writes: gift_card (update) — Raises the balance; gift_card_event (insert) — Records the refund
curl -X POST https://app.getera.io/api/v1/gift_cards/GIFT_CARD_ID/actions/refund \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"amount":1}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.refunded"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCards.refund("GIFT_CARD_ID", {
amount: 1
})era gift_cards refund GIFT_CARD_ID \
--amount 1{
"name": "era__gift_cards__refund",
"arguments": {
"id": "GIFT_CARD_ID",
"amount": 1
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_not_found, gift_card_refund_exceeds_spent · 429 slow down
gift_cards.reset_balance
Correct the balance — Sets the balance by hand, with the reason on the card’s history.
Needs gift_cards:manage · reaches outside (sends, publishes or charges) · asks a person to confirm when Era runs it
https://app.getera.io/api/v1/gift_cards/{id}/actions/reset_balance- Canonical address:
POST /api/v1/actions/gift_cards.reset_balance
Input
| Field | Type | Required | Notes |
|---|---|---|---|
id | uuid | yes | Filled from the path {id} · Gift card · id of gift_card |
balance | number (money) | yes | New balance · min 0 |
reason | string | yes | Reason · max 2000 |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_not_found | The card must exist. |
gift_card_amount_not_positive | A balance cannot be negative. |
Events it publishes: gift_cards.updated
What it writes: gift_card (update) — Writes the balance; gift_card_event (insert) — Records the correction
curl -X POST https://app.getera.io/api/v1/gift_cards/GIFT_CARD_ID/actions/reset_balance \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"balance":1,"reason":"Reason"}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCards.resetBalance("GIFT_CARD_ID", {
balance: 1,
reason: "Reason"
})era gift_cards reset_balance GIFT_CARD_ID \
--balance 1 \
--reason "Reason"{
"name": "era__gift_cards__reset_balance",
"arguments": {
"id": "GIFT_CARD_ID",
"balance": 1,
"reason": "Reason"
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_not_found, gift_card_amount_not_positive · 429 slow down
gift_cards.send
Send to customer — Emails the card through the notifications module; the card shows whether it went.
Needs gift_cards:write · reaches outside (sends, publishes or charges) · asks a person to confirm when Era runs it
https://app.getera.io/api/v1/gift_card_events/actions/send- Canonical address:
POST /api/v1/actions/gift_cards.send
Input
| Field | Type | Required | Notes |
|---|---|---|---|
id | uuid | yes | Gift card · id of gift_card |
to | string | Email · max 320 | |
message | string | Message · max 2000 |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_not_found | The card must exist. |
gift_card_inactive | A deactivated card is not sent. |
gift_card_expired | An expired card is not sent. |
gift_card_recipient_missing | There must be an address to send to. |
Events it publishes: gift_cards.send_requested
What it writes: gift_card_event (insert) — Records who it was sent to
curl -X POST https://app.getera.io/api/v1/gift_card_events/actions/send \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"id":"GIFT_CARD_ID"}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.send_requested"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCardEvents.send({
id: "GIFT_CARD_ID"
})era gift_card_events send \
--id "GIFT_CARD_ID"{
"name": "era__gift_cards__send",
"arguments": {
"id": "GIFT_CARD_ID"
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:write · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_not_found, gift_card_inactive, gift_card_expired, gift_card_recipient_missing · 429 slow down
gift_cards.set_active
Activate or deactivate — A deactivated card keeps its balance and cannot be spent.
Needs gift_cards:manage · changes data
https://app.getera.io/api/v1/gift_cards/{id}/actions/set_active- Canonical address:
POST /api/v1/actions/gift_cards.set_active
Input
| Field | Type | Required | Notes |
|---|---|---|---|
id | uuid | yes | Filled from the path {id} · Gift card · id of gift_card |
active | boolean | yes | Active |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_not_found | The card must exist. |
Events it publishes: gift_cards.status_changed
What it writes: gift_card (update) — Flips the card; gift_card_event (insert) — Records it
curl -X POST https://app.getera.io/api/v1/gift_cards/GIFT_CARD_ID/actions/set_active \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"active":true}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.status_changed"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCards.setActive("GIFT_CARD_ID", {
active: true
})era gift_cards set_active GIFT_CARD_ID \
--active true{
"name": "era__gift_cards__set_active",
"arguments": {
"id": "GIFT_CARD_ID",
"active": true
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_not_found · 429 slow down
gift_cards.set_expiry
Change the expiry — Moves or removes the expiry date.
Needs gift_cards:manage · changes data
https://app.getera.io/api/v1/gift_cards/{id}/actions/set_expiry- Canonical address:
POST /api/v1/actions/gift_cards.set_expiry
Input
| Field | Type | Required | Notes |
|---|---|---|---|
id | uuid | yes | Filled from the path {id} · Gift card · id of gift_card |
expiryDate | date | Expires |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
gift_card_not_found | The card must exist. |
gift_card_expiry_in_past | The expiry cannot already have passed. |
Events it publishes: gift_cards.updated
What it writes: gift_card (update) — Writes the expiry; gift_card_event (insert) — Records the change
curl -X POST https://app.getera.io/api/v1/gift_cards/GIFT_CARD_ID/actions/set_expiry \
-H "Authorization: Bearer $ERA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"expiryDate":"2026-11-02"}'{
"ok": true,
"result": "…",
"events": [
"gift_cards.updated"
]
}import { createEra } from "@getera/sdk"
const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.giftCards.setExpiry("GIFT_CARD_ID", {
expiryDate: "2026-11-02"
})era gift_cards set_expiry GIFT_CARD_ID \
--expiry-date "2026-11-02"{
"name": "era__gift_cards__set_expiry",
"arguments": {
"id": "GIFT_CARD_ID",
"expiryDate": "2026-11-02"
}
}Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 gift_card_not_found, gift_card_expiry_in_past · 429 slow down
gift_cards.site_apply
Use a gift card (site) — A visitor puts a gift card on their checkout or payment link: the part of what is due its balance covers is held for fifteen minutes and paid from the card at the pay step. An empty code takes it off.
Needs gift_cards:write · changes data · Also callable from a published site (visitor)
/api/site/v1/{siteId}, e.g. with @getera/storefront). With an API key or a token it is refused (403 site_only).https://app.getera.io/api/v1/gift_card_holds/actions/site_apply- Canonical address:
POST /api/v1/actions/gift_cards.site_apply
Input
| Field | Type | Required | Notes |
|---|---|---|---|
code | string | Gift card code · max 16 | |
basketToken | uuid | Basket | |
payToken | uuid | Payment link |
Preconditions
The action is refused with 409 and one of these codes:
| Code | Refused when |
|---|---|
basket_not_found | The basket must still be open. |
pay_link_invalid | The payment link names an open agreement of this business. |
nothing_due | Something is still owed. |
gift_card_not_found | The code must name a card. |
gift_card_inactive | A deactivated card pays nothing. |
gift_card_expired | An expired card pays nothing. |
gift_card_currency_mismatch | The card pays only in its own currency. |
gift_card_insufficient_balance | The card has free balance (not held by another checkout). |
Events it publishes: gift_cards.hold_changed
What it writes: gift_card_hold (insert) — Holds the part of the card that pays; gift_card_hold (update) — Lets go of an earlier hold on the same checkout
Errors: 401 no or expired credential · 403 the credential does not hold gift_cards:write · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 basket_not_found, pay_link_invalid, nothing_due, gift_card_not_found, gift_card_inactive, gift_card_expired, gift_card_currency_mismatch, gift_card_insufficient_balance · 429 slow down
Data models
GiftCardEvent
Table gift_card_event · Resource gift_card_events
GET /api/v1/gift_card_eventsGET /api/v1/gift_card_events/{id}
| Column | Type | Nullable | Allowed values | References |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
gift_card_id | string (uuid) · uuid | gift_card | ||
type | string · text | issued, bought, updated, activated, deactivated, balance_reset, expiry_date_updated, tags_updated, sent_to_customer, resent, note_added, used_in_order, refunded_in_order, send_requested | ||
currency | string · bpchar | max 3 | ||
amount | string (int64) · int8 | |||
balance_after | string (int64) · int8 | |||
source_module | string · text | yes | ||
source_record_id | string (uuid) · uuid | yes | ||
idempotency_key | string · text | yes | ||
message | string · text | yes | ||
parameters | object · jsonb | |||
actor_user_id | string (uuid) · uuid | yes | app_user | |
occurred_at | string (date-time) · timestamptz |
Primary key: id
Checks:
CHECK ((balance_after >= 0))CHECK ((currency ~ '^[A-Z]{3}$'::text))
GiftCardHold
Table gift_card_hold · Resource gift_card_holds
GET /api/v1/gift_card_holdsGET /api/v1/gift_card_holds/{id}
| Column | Type | Nullable | Allowed values | References |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
gift_card_id | string (uuid) · uuid | gift_card | ||
target_kind | string · text | checkout, agreement | ||
currency | string · bpchar | max 3 | ||
amount | string (int64) · int8 | |||
expires_at | string (date-time) · timestamptz | |||
redeemed_at | string (date-time) · timestamptz | yes | ||
released_at | string (date-time) · timestamptz | yes | ||
gift_card_event_id | string (uuid) · uuid | yes | gift_card_event | |
created_at | string (date-time) · timestamptz |
Primary key: id
Checks:
CHECK ((amount > 0))CHECK ((NOT ((redeemed_at IS NOT NULL) AND (released_at IS NOT NULL))))
GiftCard
Table gift_card · Resource gift_cards
GET /api/v1/gift_cardsGET /api/v1/gift_cards/{id}
| Column | Type | Nullable | Allowed values | References |
|---|---|---|---|---|
id | string (uuid) · uuid | |||
organization_id | string (uuid) · uuid | organization | ||
workspace_id | string (uuid) · uuid | workspace | ||
code | string · text | |||
is_active | boolean · bool | |||
currency | string · bpchar | max 3 | ||
initial_balance_amount | string (int64) · int8 | |||
current_balance_amount | string (int64) · int8 | |||
expiry_date | string (date) · date | yes | ||
customer_id | string (uuid) · uuid | yes | customer | |
issued_to_email | string · text | yes | ||
source_module | string · text | yes | ||
source_record_id | string (uuid) · uuid | yes | ||
note | string · text | yes | ||
last_used_at | string (date-time) · timestamptz | yes | ||
created_by_user_id | string (uuid) · uuid | yes | app_user | |
created_at | string (date-time) · timestamptz | |||
updated_at | string (date-time) · timestamptz |
Primary key: id
Checks:
CHECK (((length(code) >= 8) AND (length(code) <= 16)))CHECK ((currency ~ '^[A-Z]{3}$'::text))CHECK ((current_balance_amount >= 0))CHECK ((initial_balance_amount >= 0))
Events
Workflows and webhooks react to these events.
| Event | What happens | Payload |
|---|---|---|
gift_cards.hold_changed | A site checkout put a gift card on, or took it off (the part it pays is held). | id, kind, amount |
gift_cards.issued | A gift card was issued. | id, amount, currency, customerId |
gift_cards.redeemed | Money was spent from a gift card. | id, eventId, amount, currency, balance, sourceModule, sourceRecordId, codeTail |
gift_cards.refunded | Money went back onto a gift card. | id, amount, balance, sourceModule, sourceRecordId, idempotencyKey |
gift_cards.send_requested | A gift card was sent to somebody; notifications delivers it. | id, eventId, to |
gift_cards.status_changed | A gift card was activated or deactivated. | id, active |
gift_cards.updated | A gift card was changed. | id |