# Conventions

Source: https://docs.globagift.io/docs/api/conventions
Description: How the Globagift API handles amounts, idempotent retries, errors, pagination, timestamps and rate limits.


## Requests and responses [#requests-and-responses]

- Requests and responses are JSON. Send `Content-Type: application/json` with a body.
- Identifiers are UUIDs.
- Timestamps are ISO 8601 in UTC, for example `2026-11-04T10:25:29.438Z`.
- Fields can be added to responses over time. Ignore fields you do not use.

## Amounts and currency [#amounts-and-currency]

Amounts are **integer minor units**: `1250` in EUR means EUR 12.50. Never send decimals. Currencies are three-letter ISO 4217 codes such as `EUR`.

Each card product has one currency and a minimum and maximum amount. Issuing outside that range returns `422` with code `invalid_amount`.

## Retries and idempotency [#retries-and-idempotency]

Networks fail, and a request can succeed even when its response never arrives. Each operation in the reference says how to retry it.

**Operations with an `Idempotency-Key` header** (issuing a card, redeeming and reserving float) are safe to retry:

- Send a unique key per logical action, such as your order or line id. Keys can be up to 255 characters.
- Repeating the request with the same key and the same body returns the original result. A replayed issue or redemption returns `200` instead of `201`.
- The same key with a different body returns `409` with code `idempotency_key_conflict`.
- A missing key returns `400` with code `idempotency_key_required`.

Retrying a **redemption** needs a new signature as well: keep the same `Idempotency-Key` and body, but use a fresh timestamp and nonce. Re-sending the identical signed request is refused, because each nonce works once.

One-time values are not repeated. A replayed issue or distributor capture returns the same card **without** the claim code, so store the claim code from the first success before you do anything else.

**Operations marked not idempotent** (for example creating an acceptance point, or suspending or voiding a card) should not be retried blindly. Read the current state first, then decide.

## Errors [#errors]

Errors use [RFC 9457 problem details](https://www.rfc-editor.org/rfc/rfc9457) with the `application/problem+json` media type:

```json
{
  "type": "about:blank",
  "status": 422,
  "code": "insufficient_balance",
  "title": "insufficient card balance"
}
```

Branch on `status` and `code`. `title` is for people and can change. New codes may be added, so handle unknown codes by their status.

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `validation_failed` | The request is malformed or a field is invalid |
| 400 | `idempotency_key_required` | The operation needs an `Idempotency-Key` header |
| 401 | `authentication_failed` | The API key is missing, malformed or revoked |
| 401 | `invalid_signature` | An acceptance-point signature was refused |
| 403 | `insufficient_scope` | The key does not have the scope this operation needs |
| 404 | `not_found` | Not found, or not visible to this key |
| 409 | `idempotency_key_conflict` | The key was already used with a different body |
| 409 | `state_conflict` | The resource is not in a state that allows this action |
| 422 | `invalid_amount` | The amount is outside the product's range |
| 422 | `insufficient_balance` | The card does not have enough balance |
| 422 | `card_not_redeemable` | The card cannot be redeemed, for example because it is suspended |
| 422 | `insufficient_float` | A distributor does not have enough available float |
| 429 | `rate_limited` | Too many requests; wait for the `Retry-After` header |
| 500 | `internal_error` | An unexpected error. Retry only if the operation is safe to retry |

### Not found means not found or not yours [#not-found-means-not-found-or-not-yours]

For anything you are not allowed to see, the API returns the same `404` as for something that does not exist. A card from another merchant, a merchant that has not granted a distributor, or another distributor's reservation all look like an unknown id. Do not use `404` to probe for what exists.

A voided card is treated the same way by the public balance and claim endpoints: they return `404`, not a zero balance.

## Pagination [#pagination]

Card, redemption and event lists use cursors:

- Pass `limit` (default 50, maximum 100).
- Each page includes `next_cursor`. Pass it back as `after_cursor` for the next page.
- `next_cursor` is `null` on the last page.

```bash
curl -s "$GG_BASE/v1/cards?limit=50&after_cursor=NEXT_CURSOR" -H "Authorization: Bearer $GG_KEY"
```

The product list uses `limit` and `offset` and returns a `total`.

## Rate limits [#rate-limits]

The public claim and balance endpoints are limited to 10 requests a minute from each client IP address. Over the limit, they return `429` with a `Retry-After` header in seconds.

These limits are designed for cardholders calling from their own devices. If your servers will call them on behalf of many cardholders, [talk to us](https://www.globagift.io/en/contact) first.
