API/API reference/Gateway/Create a payment

Create a payment

Request a Lightning payment for an operation using MPP or L402. The payment goes to your Phoenixd node.

POST/gateway/payments

Required scope: gateway:write.

Request fields

FieldDescription
nodeIdRequired. ID of a running node in your account.
amountSatRequired. Whole number of satoshis, from 1 to 9007199254740.
descriptionRequired. Non-blank description, up to 500 characters. Control characters are not accepted.
protocolOptional: mpp or l402. Defaults to mpp.

Request

curl "https://api.nodana.io/v1/gateway/payments" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "nodeId": "node-123",
    "amountSat": 100,
    "description": "Generate image"
  }'

For L402, include "protocol": "l402" in the request body.

Response

201 Created

{
  "id": "payment-123",
  "protocol": "mpp",
  "status": "payment_required",
  "challenge": "<MPP challenge returned by Nodana>"
}

For L402, protocol is l402 and challenge contains the L402 macaroon and invoice header value.

Keep id with the operation. Return HTTP 402 to the calling client and set its WWW-Authenticate header to challenge. Your API chooses the response body. See Accept payments for MPP and L402 examples.

Challenges expire after five minutes, or sooner if the invoice expires first. Each creation request creates a new payment; retain the returned ID for retries.

Errors

StatusCodeWhat to do
400bad_requestCheck the request fields and protocol.
401unauthorizedCheck your API key and gateway permissions.
404node_not_foundUse a node ID from the key's account.
502payment_service_unavailableMake sure the node is running and try again when it is ready.

See Error handling and Rate limiting for other errors and retry guidance.

On this page