# Distribution

Source: https://docs.globagift.io/docs/api/reference/distribution
Description: Distributor keys: granted merchants, catalogues, reservations, capture and statements.


## List the merchants the authenticated distributor may currently sell for

`GET /v1/distribution/grants`

Authentication: Distributor key (`Authorization: Bearer ggd_...`)

Requires a distributor key with distribution:read or distribution:sell scope. Lists the merchants this distributor may currently sell for. Only active grants over active merchants are returned, so a revoked grant disappears immediately. Returns the merchant id and display name only.

Responses:

- 200: Granted merchants
- 401: Authentication failed
- 403: Key lacks distribution:read or distribution:sell scope
- default: Unexpected server error

## List a granted merchant's card products

`GET /v1/distribution/products`

Authentication: Distributor key (`Authorization: Bearer ggd_...`)

Requires a distributor key with distribution:read or distribution:sell scope. Returns a uniform 404, identical to a merchant that does not exist, when the distributor has no active grant for merchant_id. Only active products are returned; draft, paused and archived products are never disclosed to a distributor.

Parameters:

- `merchant_id` (query, required, string)

Responses:

- 200: Card products
- 400: merchant_id missing or malformed
- 401: Authentication failed
- 403: Key lacks distribution:read or distribution:sell scope
- 404: Unknown or ungranted merchant (uniform)
- default: Unexpected server error

## Hold float against a granted merchant's product ahead of issuance

`POST /v1/distribution/reservations`

Authentication: Distributor key (`Authorization: Bearer ggd_...`)

Requires a distributor key with distribution:sell scope and an Idempotency-Key header. Idempotency keys are scoped to the calling distributor. Retrying with the same key and payload returns the original reservation; the same key with a different payload returns 409 idempotency_key_conflict. Send your own order_reference so the sale can be looked up later. ttl_seconds is capped at 3600.

Parameters:

- `Idempotency-Key` (header, required, string)

Request body:

- `merchant_id` (string (uuid), required)
- `card_product_id` (string (uuid), required)
- `amount` (integer, required): Integer minor units; for example 1250 means EUR 12.50.
- `currency` (string, required)
- `order_reference` (string): Your own order or sale reference, unique per distributor. If omitted, a reference is generated.
- `ttl_seconds` (integer): How long the float stays held before it is released automatically.

Responses:

- 201: Reservation held
- 400: Missing Idempotency-Key header or invalid body
- 401: Authentication failed
- 403: Key lacks distribution:sell scope (checked before any grant lookup)
- 404: Unknown or ungranted merchant (uniform)
- 422: Insufficient distributor float
- default: Unexpected server error

## Look up the authenticated distributor's order by its own reference

`GET /v1/distribution/orders/{order_reference}`

Authentication: Distributor key (`Authorization: Bearer ggd_...`)

Requires distribution:read or distribution:sell scope. Returns the distributor's own reservation status, timestamps, amount, currency, reservation id and card id. Unknown references and references belonging to another distributor return the same uniform 404.

Parameters:

- `order_reference` (path, required, string)

Responses:

- 200: Distributor order reservation
- 401: Authentication failed
- 403: Key lacks distribution:read or distribution:sell scope
- 404: Unknown order reference or reference belonging to another distributor (uniform)
- default: Unexpected server error

## Capture a held reservation and issue the card

`POST /v1/distribution/reservations/{id}/capture`

Authentication: Distributor key (`Authorization: Bearer ggd_...`)

Requires distribution:sell scope. Unknown reservation ids, reservations belonging to another distributor, and reservations whose merchant grant has since been revoked all return the same uniform 404. Replayable: capturing an already-captured reservation returns 200 with the same reservation and card again, so a lost response is recoverable. The claim code is returned only on the first successful capture and is never returned again, so store it before acknowledging the sale.

Parameters:

- `id` (path, required, string)

Responses:

- 200: Reservation captured; card and claim code included. On a replayed capture the same card is returned without a claim code.
- 401: Authentication failed
- 403: Key lacks distribution:sell scope
- 404: Unknown reservation, reservation belonging to another distributor, or reservation whose merchant grant was revoked since it was reserved (uniform)
- 409: Reservation is released or expired, so it can never be captured (an already-captured reservation replays as a 200 instead)
- default: Unexpected server error

## Release a held reservation and return float to the distributor's available pocket

`DELETE /v1/distribution/reservations/{id}`

Authentication: Distributor key (`Authorization: Bearer ggd_...`)

Requires distribution:sell scope. Unknown reservation ids and reservations belonging to another distributor both return the same uniform 404.

Retries: not idempotent. After an unclear failure, read the current state before trying again.

Parameters:

- `id` (path, required, string)

Responses:

- 204: Reservation released
- 401: Authentication failed
- 403: Key lacks distribution:sell scope
- 404: Unknown reservation, or reservation belonging to another distributor (uniform)
- 409: Reservation is not in a releasable state
- default: Unexpected server error

## Ledger-derived statement of the authenticated distributor's own float activity

`GET /v1/distribution/statements`

Authentication: Distributor key (`Authorization: Bearer ggd_...`)

Requires distribution:read or distribution:sell scope. One row per ledger posting against the caller's own float in `currency`, oldest first, covering both the available and reserved balances. Only the calling distributor's own activity is returned. Each line names the balance it affected (`available` or `reserved`) and, where applicable, the reservation id and card id, so a reserve's two equal-and-opposite rows are distinguishable and every line ties back to a sale. A prefund has neither and reads null on both.

Parameters:

- `currency` (query, required, string)
- `from` (query, string (date-time)): Inclusive date/time boundary for the resource timestamp named by this parameter.
- `to` (query, string (date-time)): Inclusive date/time boundary for the resource timestamp named by this parameter.

Responses:

- 200: Statement lines
- 400: currency missing/malformed, or from/to outside the accepted ISO-8601 subset (YYYY-MM-DD, optionally THH:MM[:SS[.ffffff]] and Z or +/-HH:MM)
- 401: Authentication failed
- 403: Key lacks distribution:read or distribution:sell scope
- default: Unexpected server error
