couponsby La Crypta
ApiRefresh

Swap a nonce for its replacement

This is the `refreshUrl` from the announcement. Burns `nonce` and mints a replacement in the same transaction, carrying the **same** benefit snapshot and the **same** `expiresAt`. Refresh is how a coupon changes hands: the nonce is the credential, so re-minting it is the transfer. `Idempotency-Key` is required. The key and the signed response are stored on the burned row, and a retry with the same key replays that response verbatim — never re-signed, because a different event `id` breaks a receiver that already stored the first one. Refuses anything not `minted` and unexpired. The burn is a conditional update, so two callers racing the same nonce produce exactly one replacement and one `409`.

POST/api/coupons/refresh

This is the refreshUrl from the announcement. Burns nonce and mints a replacement in the same transaction, carrying the same benefit snapshot and the same expiresAt. Refresh is how a coupon changes hands: the nonce is the credential, so re-minting it is the transfer.

Idempotency-Key is required. The key and the signed response are stored on the burned row, and a retry with the same key replays that response verbatim — never re-signed, because a different event id breaks a receiver that already stored the first one.

Refuses anything not minted and unexpired. The burn is a conditional update, so two callers racing the same nonce produce exactly one replacement and one 409.

Header Parameters

Idempotency-Key*string

Caller-chosen, opaque. Must not be derived from anything guessable: a third party who can predict it can claim the retry.

Length8 <= length <= 255

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/coupons/refresh" \  -H "Idempotency-Key: stringst" \  -H "Content-Type: application/json" \  -d '{    "nonce": "hcLPDzERvvHzS4Vn0OLbAQ"  }'
{  "couponId": "string",  "coupon": {    "type": "percent",    "percent": 0,    "productDs": [      "string"    ],    "cap": {      "amount": 1,      "currency": "ARS"    }  },  "name": "string",  "description": "string",  "npub": "string",  "image": "string",  "nonce": "string",  "expiresAt": 0,  "voucher": {    "id": "string",    "pubkey": "string",    "created_at": 0,    "kind": 0,    "tags": [      [        "string"      ]    ],    "content": "string",    "sig": "string"  }}