{"id":"3d1d9c5f9fe059f65b74f132d1868fec4b96fef6487c6a90b2e1e5553adb7dee","pubkey":"d1678e7ef965374bbea308a1215609a78376dc158277a7d657680f9d5efd5c38","created_at":1782228503,"kind":30817,"tags":[["d","nut-24"],["title","NUT-24: HTTP 402 Payment Required"],["summary","How an HTTP server demands payment with a 402 response carrying a Cashu payment request."],["s","optional"],["t","cashu"],["t","ecash"],["t","nut"],["alt","A specification: NUT-24: HTTP 402 Payment Required"],["client","openspecs-import"],["published_at","1750937624"],["proxy","https://github.com/cashubtc/nuts/blob/a845dfc998abae501fc3419592d53dc995d34b12/24.md","web"],["x","a3e11aa90de774dbb0144e2cb2ec203b38b09a76317262fc1ebbd7bf18169be5"]],"content":"# NUT-24: HTTP 402 Payment Required\n\n`optional`\n\n`uses: NUT-12`\n\n`depends on: NUT-18, NUT-26`\n\n---\n\nThis NUT describes how Cashu tokens can be used with HTTP 402 Payment Required responses to enable payments for HTTP resources.\n\n### Server response\n\nHTTP servers may respond with the HTTP status code 402 and an `X-Cashu` header containing a payment request, encoded in either [NUT-18][18] `creqA` or [NUT-26][26] `creqB` formats. Wallets **MUST** support both formats.\n\nThe decoded payment request has the following fields:\n\n```\n{\n    \"a\": int,\n    \"u\": str,\n    \"m\": Array[str],\n    \"nut10\": NUT10Option <optional>\n}\n```\n\n- `a`: The amount required in the specified unit\n- `u`: The currency unit (e.g., \"sat\", \"usd\", \"api\")\n- `m`: Array of mint URLs that the server accepts tokens from\n- `nut10`: The required [NUT-10][10] locking condition\n\nNote: there is no transport field since we expect an in-band payment.\n\n### Client payment\n\nAfter receiving a 402 response with a `X-Cashu` header, the client may retry the request with a `cashuB` token in the `X-Cashu` header as payment.\n\nThe token MUST be from one of the mints listed in the `mints` array, and MUST be of the same `unit` and greater than or equal to the `amount`.\n\n## Payment response\n\nIf the server receives tokens from a mint that is not in the `mints` array, an incorrect `unit`, an insufficient amount of tokens, or with insufficient locking conditions, it should respond with a HTTP `400` status code.\n\n[10]: nostr:naddr1qvzqqqrcvypzp5t83el0jefhfwl2xz9py9tqnfurwmwptqnh5lt9w6q0n4006hpcqqrxuat595cnqx5tye7\n[12]: nostr:naddr1qvzqqqrcvypzp5t83el0jefhfwl2xz9py9tqnfurwmwptqnh5lt9w6q0n4006hpcqqrxuat595cnyf7fzky\n[18]: nostr:naddr1qvzqqqrcvypzp5t83el0jefhfwl2xz9py9tqnfurwmwptqnh5lt9w6q0n4006hpcqqrxuat595cnsn4ruvd\n[26]: nostr:naddr1qvzqqqrcvypzp5t83el0jefhfwl2xz9py9tqnfurwmwptqnh5lt9w6q0n4006hpcqqrxuat595ervnaz896\n","sig":"fa2b72ba7ea47acf5b57cd62d834bda0468602063929f4d139d95cc89b07296c1a05fd1af928c0fe26864004aea91f6e31ae620f82811a1e4aed180ab717c62f"}