Issue a gift card
Returns the plaintext code EXACTLY ONCE. It is stored only as an HMAC and cannot be retrieved again by anyone, including this API — persist it from this response or deliver it. A note is required: issuing stored value with no stated reason is not auditable. Refused when gift cards are switched off for the store.
Admin API key (server-to-server). Issue via the dashboard at Settings → API keys. Plain-text key is shown once — store in a secret manager. Format: Authorization: Bearer brainerce_xxxxxxxxx.
In: header
Header Parameters
Client-supplied key (a UUID v4 is the recommended form, max 255 characters) that makes this mutation safe to retry.
- Replay window: 24 hours. The first response for a key is cached; a retry inside the window with the same request body returns the original status and body without re-running the handler.
- Reusing a key with a different body returns
409 Conflictwithcode: "IDEMPOTENCY_KEY_REUSED". The request fingerprint (method + path + body hash) is compared against the stored one; a mismatch is refused rather than served the old response. - Keys are scoped to the calling credential and store — two API keys may safely use the same key value.
- Error responses are cached too, so a retry of a request that failed validation returns the same 400 immediately.
- Sending this header on a
GETreturns400withcode: "IDEMPOTENCY_KEY_NOT_SUPPORTED"— GETs are already idempotent. - Support is per-route and this parameter is the authoritative signal: a key sent to a route that does not declare it is accepted and silently ignored.
length <= 255Amount to load onto the card, as a decimal string.
Why this card was issued. Required, and stored on the ledger row itself — issuing value with no stated reason is not auditable, and this is the entry a finance review will read a year from now.
3 <= length <= 500Link the card to a customer.
Expiry. Must be in the future. Leave unset for a card that does not expire.
Recipient email, for delivery.
emailRecipient name, for the delivery email.
length <= 200A message from the buyer to the recipient.
length <= 1000curl -X POST "https://api.brainerce.com/api/v1/gift-cards" \ -H "Idempotency-Key: string" \ -H "Content-Type: application/json" \ -d '{ "amount": "200.00", "note": "Goodwill for order ORD-20260902-0041, damaged in transit" }'{
"giftCardId": "clx1a2b3c4d5e6f7g8h9",
"plaintextCode": "ABCD-EFGH-JKLM-K7QX",
"last4": "K7QX"
}{
"statusCode": 400,
"code": "VALIDATION_FAILED",
"message": "name should not be empty, price must be a positive number",
"timestamp": "2026-08-23T10:15:00.000Z",
"path": "/api/v1/gift-cards"
}{
"statusCode": 401,
"code": "UNAUTHORIZED",
"message": "Invalid or expired credential",
"timestamp": "2026-08-23T10:15:00.000Z",
"path": "/api/v1/products/bulk/{jobId}"
}{
"statusCode": 403,
"code": "INSUFFICIENT_SCOPE",
"message": "API key does not have the required scope: products:write",
"timestamp": "2026-08-23T10:15:00.000Z",
"path": "/api/v1/gift-cards"
}{
"statusCode": 429,
"code": "RATE_LIMITED",
"message": "Too many requests",
"details": {
"retryAfterSeconds": 12
},
"timestamp": "2026-08-23T10:15:00.000Z",
"path": "/api/v1/store"
}