Skip to content

NUT-24: HTTP 402 Payment Required

optional

uses: NUT-12

depends on: NUT-18


This NUT describes how Cashu tokens can be used with HTTP 402 Payment Required responses to enable payments for HTTP resources.

Server response

HTTP servers may respond with the HTTP status code 402 with a X-Cashu header containing an encoded NUT-18 payment request with the following fields:

{
    "a": int,
    "u": str,
    "m": Array[str],
    "nut10": NUT10Option <optional>
}
  • a: The amount required in the specified unit
  • u: The currency unit (e.g., "sat", "usd", "api")
  • m: Array of mint URLs that the server accepts tokens from
  • nut10: The required [NUT-10][10] locking condition

Client payment

After 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.

The 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.

[!IMPORTANT] The transport can be empty! If the transport is empty, we implicitly assume that the payment will be in-band. An example is X-Cashu where the payment is expected in the HTTP header of a request. We can only hope that the protocol you're using has a well-defined transport.

Payment response

If 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.