# Gift cards

> Gift cards and store credit (D300, D364): issued, listed and deactivated; a code is never answered after its issue.

| Operation | Method and path | Scope |
|---|---|---|
| [List gift cards](https://docs.kaizenaflow.com/reference/admin-api/gift-cards#gift-cards-list) | `GET /gift-cards` | [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write) |
| [Get a gift card](https://docs.kaizenaflow.com/reference/admin-api/gift-cards#gift-cards-get) | `GET /gift-cards/{id}` | [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write) |
| [Issue a gift card](https://docs.kaizenaflow.com/reference/admin-api/gift-cards#gift-cards-issue) | `POST /gift-cards` | [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write) |
| [Deactivate a gift card](https://docs.kaizenaflow.com/reference/admin-api/gift-cards#gift-cards-disable) | `POST /gift-cards/{id}/disable` | [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write) |

## List gift cards {#gift-cards-list}

`GET https://kaizenaflow.com/api/admin/v1/gift-cards`

The store's gift cards and store credit, newest first, each with its balance; never a code.

- **Operation:** `gift_cards.list`
- **Scope:** [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write)
- **Answers:** `200`, a page: the rows under `data`, and `next` for the page after.
- **Pages:** at most 100 rows, 50 when `limit` is left out; give an answer's `next` as `?after=` for the page after.

### Query parameters {#gift-cards-list-query}

| Name | Type | Required | Description |
|---|---|---|---|
| `limit` | integer, 1 to 100 | no | Rows a page holds, at most 100; 50 when left out. A larger number gives 100. |
| `after` | string, at most 200 characters | no | The `next` cursor of the page before; the first page when left out. |
| `updated_after` | string (date-time) | no | Only what was made or changed after this time (ISO 8601 with its offset), for incremental sync. |
| `state` | one of `active`, `waiting`, `spent`, `expired`, `deactivated` | no | Only cards in this state. |

### Answer {#gift-cards-list-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].last4` | string or null | The code's last four characters, to tell cards apart. The code itself is never answered after it is issued. |
| `data[].currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data[].initial_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data[].balance_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data[].state` | one of `active`, `waiting`, `spent`, `expired`, `deactivated` | active, waiting (not delivered yet), spent, expired or deactivated. |
| `data[].source` | one of `order`, `staff`, `refund` | Bought with an order, issued by staff (or here), or store credit from a refund (D364). |
| `data[].test` | boolean | A card of the store's test mode, spent only in test mode. |
| `data[].issued_at` | string (date-time) |   |
| `data[].expires_at` | string (date-time) or null |   |
| `next` | string or null | The cursor of the next page, given as `?after=`; null on the last page. |

### Errors {#gift-cards-list-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#gift-cards-list-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/gift-cards' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/gift-cards", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/gift-cards",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Get a gift card {#gift-cards-get}

`GET https://kaizenaflow.com/api/admin/v1/gift-cards/{id}`

One gift card with its balance; never its code.

- **Operation:** `gift_cards.get`
- **Scope:** [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write)
- **Answers:** `200`, the answer under `data`.

### Path parameters {#gift-cards-get-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Answer {#gift-cards-get-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.last4` | string or null | The code's last four characters, to tell cards apart. The code itself is never answered after it is issued. |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.initial_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.balance_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.state` | one of `active`, `waiting`, `spent`, `expired`, `deactivated` | active, waiting (not delivered yet), spent, expired or deactivated. |
| `data.source` | one of `order`, `staff`, `refund` | Bought with an order, issued by staff (or here), or store credit from a refund (D364). |
| `data.test` | boolean | A card of the store's test mode, spent only in test mode. |
| `data.issued_at` | string (date-time) |   |
| `data.expires_at` | string (date-time) or null |   |

### Errors {#gift-cards-get-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#gift-cards-get-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/gift-cards/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/gift-cards/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/gift-cards/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Issue a gift card {#gift-cards-issue}

`POST https://kaizenaflow.com/api/admin/v1/gift-cards`

Issues a card by hand through the admin's own Issue: in one of the store's currencies, in its payment mode, emailed to `recipient_email` when given. Its code is answered this once: it is kept only as a hash, never answered again (a replay of the request answers it without), and never sent in a webhook.

- **Operation:** `gift_cards.issue`
- **Scope:** [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write)
- **Answers:** `201`, made: the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Body {#gift-cards-issue-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `currency` | string, matching `^[A-Z]{3}$` | yes | One of the store's currencies. |
| `amount_minor` | integer, 1 to 100,000,000 | yes | What it holds, in minor units. |
| `recipient_email` | string, at most 254 characters or null | no | Email the code to this address, as the admin's Issue does. |
| `recipient_name` | string, at most 120 characters or null | no |   |
| `message` | string, at most 500 characters or null | no | A message in its email. |
| `note` | string, at most 500 characters | no, default `"Issued over the API"` | Why, for the store's own record. |

### Answer {#gift-cards-issue-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.last4` | string or null | The code's last four characters, to tell cards apart. The code itself is never answered after it is issued. |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.initial_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.balance_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.state` | one of `active`, `waiting`, `spent`, `expired`, `deactivated` | active, waiting (not delivered yet), spent, expired or deactivated. |
| `data.source` | one of `order`, `staff`, `refund` | Bought with an order, issued by staff (or here), or store credit from a refund (D364). |
| `data.test` | boolean | A card of the store's test mode, spent only in test mode. |
| `data.issued_at` | string (date-time) |   |
| `data.expires_at` | string (date-time) or null |   |
| `data.code` | string or null | The card's code, this once. |
| `data.emailed` | one of `sent`, `failed`, `not_asked` |   |

### Errors {#gift-cards-issue-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#gift-cards-issue-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/gift-cards' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"currency":"NOK","amount_minor":1}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/gift-cards", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "currency": "NOK",
    "amount_minor": 1
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/gift-cards",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "currency": "NOK",
        "amount_minor": 1,
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Deactivate a gift card {#gift-cards-disable}

`POST https://kaizenaflow.com/api/admin/v1/gift-cards/{id}/disable`

Deactivates the card: what is left on it goes and it is never spent again; orders it paid keep their money.

- **Operation:** `gift_cards.disable`
- **Scope:** [`gift_cards:write`](https://docs.kaizenaflow.com/reference/scopes#gift-cards-write)
- **Answers:** `200`, the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Path parameters {#gift-cards-disable-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Body {#gift-cards-disable-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `reason` | string, 1 to 500 characters | no, default `"Deactivated over the API"` | Why, for the card's history. |

### Answer {#gift-cards-disable-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.last4` | string or null | The code's last four characters, to tell cards apart. The code itself is never answered after it is issued. |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.initial_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.balance_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.state` | one of `active`, `waiting`, `spent`, `expired`, `deactivated` | active, waiting (not delivered yet), spent, expired or deactivated. |
| `data.source` | one of `order`, `staff`, `refund` | Bought with an order, issued by staff (or here), or store credit from a refund (D364). |
| `data.test` | boolean | A card of the store's test mode, spent only in test mode. |
| `data.issued_at` | string (date-time) |   |
| `data.expires_at` | string (date-time) or null |   |

### Errors {#gift-cards-disable-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#gift-cards-disable-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/gift-cards/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/disable' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Deactivated over the API"}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/gift-cards/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/disable", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "reason": "Deactivated over the API"
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/gift-cards/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/disable",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "reason": "Deactivated over the API",
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

---

https://docs.kaizenaflow.com/reference/admin-api/gift-cards · made from the API contract 1.57
