{
  "openapi": "3.1.0",
  "info": {
    "title": "PaidNow shop API",
    "version": "1.0.0",
    "summary": "Accept Apple Pay, Google Pay and card payments. The money arrives as USDC on Polygon directly in your wallet.",
    "description": "Public and shop endpoints of PaidNow. Shop calls send a Bearer API key from the PaidNow app. Money is always a decimal string with up to 6 places. All times are ISO 8601 UTC. PaidNow never holds the seller's money. The integration guide is at https://paidnow.io/llms-full.txt and https://paidnow.io/developers/."
  },
  "servers": [
    {
      "url": "https://api.paidnow.io/v1",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Links",
      "description": "Payment links and checkouts."
    },
    {
      "name": "Orders",
      "description": "Order status."
    },
    {
      "name": "Public",
      "description": "Open reads without a key."
    },
    {
      "name": "Invoices",
      "description": "Invoices with a PDF and one link to view, download and pay."
    },
    {
      "name": "Account",
      "description": "Seller profile and logo (signed-in app session)."
    },
    {
      "name": "Payments",
      "description": "Payments received, with fees, net amount and payout status."
    }
  ],
  "externalDocs": {
    "description": "Integration guide",
    "url": "https://paidnow.io/llms-full.txt"
  },
  "paths": {
    "/links": {
      "post": {
        "tags": [
          "Links"
        ],
        "operationId": "createLink",
        "summary": "Create a payment link",
        "description": "Creates a link that pays out to the wallet of the key's account. Add webhook_url and reference to receive a signed webhook when the payment is confirmed.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLinkRequest"
              },
              "examples": {
                "fixedAmount": {
                  "summary": "One order with a fixed amount",
                  "value": {
                    "kind": "link",
                    "amount": "25.00",
                    "currency": "EUR",
                    "title": "Order 1042",
                    "reference": "order-1042",
                    "webhook_url": "https://shop.example.com/paidnow/webhook"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "link"
                  ],
                  "properties": {
                    "link": {
                      "$ref": "#/components/schemas/Link"
                    }
                  }
                },
                "example": {
                  "link": {
                    "id": "k3J9xQ2mWp",
                    "url": "https://paidnow.io/l/k3J9xQ2mWp",
                    "kind": "link",
                    "amount": "25.00",
                    "currency": "EUR",
                    "title": "Order 1042",
                    "active": true
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/links/{id}": {
      "get": {
        "tags": [
          "Links"
        ],
        "operationId": "getLink",
        "summary": "Read the public fields of a link",
        "description": "The wallet is never returned in full.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Link id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public fields.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "$ref": "#/components/schemas/PublicLink"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "tags": [
          "Links"
        ],
        "operationId": "updateLink",
        "summary": "Change a link",
        "description": "Owner only. expires_at must be in the future and is refused on paid or cancelled links. A cancelled link cannot be switched on again (409 link_cancelled).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Link id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean"
                  },
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "amount": {
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/Decimal"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "expires_at": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time",
                    "description": "ISO time in the future, or null to remove the expiry."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "$ref": "#/components/schemas/Link"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "link_paid or link_cancelled."
          }
        }
      }
    },
    "/links/{id}/checkout": {
      "post": {
        "tags": [
          "Links"
        ],
        "operationId": "createCheckout",
        "summary": "Open a checkout for a link",
        "description": "Opens one order and returns the checkout address. Send the customer to checkout_url. Rate limited per IP and per link: call it when the customer clicks pay.",
        "security": [
          {},
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Link id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CheckoutRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The order and where to send the customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CheckoutResponse"
                },
                "example": {
                  "order_id": "ord_5h2k9m",
                  "checkout_url": "https://pay.paidnow.io/pay?order=ord_5h2k9m"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "link_paid: a single-use link that was paid already.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "The link no longer takes payments. Error code link_cancelled, link_expired or link_inactive.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/orders/{id}": {
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "getOrder",
        "summary": "Read the status of an order",
        "description": "Public. Holds no wallet and no transaction ids. Use it when a webhook did not arrive.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Order id from the checkout answer.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Order status.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Order"
                },
                "example": {
                  "status": "paid",
                  "amount": "25.000000",
                  "currency": "EUR",
                  "paid_at": "2026-11-21T18:42:07.000Z"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/config": {
      "get": {
        "tags": [
          "Public"
        ],
        "operationId": "getConfig",
        "summary": "Read the public configuration",
        "description": "Cached for 60 seconds.",
        "responses": {
          "200": {
            "description": "Configuration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Config"
                },
                "example": {
                  "brand": "PaidNow",
                  "site_url": "https://paidnow.io",
                  "bot_username": null,
                  "coins": [
                    "USDC@polygon"
                  ],
                  "limits": {
                    "min": "10.000000",
                    "max": "5000.000000"
                  },
                  "fees": {
                    "markup": "0.02",
                    "upstream": "0.01"
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/me/profile": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getProfile",
        "summary": "Read the seller profile",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "The profile.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "profile": {
                      "$ref": "#/components/schemas/Profile"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "put": {
        "tags": [
          "Account"
        ],
        "operationId": "putProfile",
        "summary": "Update the seller profile",
        "description": "Partial update: send only the fields that change. Invoices need business_name and business_address.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Profile"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The profile after the change.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "profile": {
                      "$ref": "#/components/schemas/Profile"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/me/logo": {
      "put": {
        "tags": [
          "Account"
        ],
        "operationId": "putLogo",
        "summary": "Upload the logo",
        "description": "PNG or JPEG, checked by content, at most 100 KB.",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "image"
                ],
                "properties": {
                  "image": {
                    "type": "string",
                    "description": "Data URL, for example data:image/png;base64,..."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The profile with the new logo.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "profile": {
                      "$ref": "#/components/schemas/Profile"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "413": {
            "description": "The image is larger than 100 KB."
          }
        }
      },
      "delete": {
        "tags": [
          "Account"
        ],
        "operationId": "deleteLogo",
        "summary": "Remove the logo",
        "security": [
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "profile": {
                      "$ref": "#/components/schemas/Profile"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/links/{id}/cancel": {
      "post": {
        "tags": [
          "Links"
        ],
        "operationId": "cancelLink",
        "summary": "Cancel an unpaid link",
        "description": "Owner only. Sets cancelled_at and switches the link off. Cancelling an invoice link cancels the invoice. Answers 409 link_paid when the link is already paid.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Link id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The cancelled link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "$ref": "#/components/schemas/Link"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "link_paid: the link was paid already."
          }
        }
      }
    },
    "/links/{id}/logo": {
      "get": {
        "tags": [
          "Public"
        ],
        "operationId": "getLinkLogo",
        "summary": "The seller's logo of a business or invoice link",
        "description": "Public. 404 for other links or when no logo is stored. Cached for 5 minutes.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Link id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Logo image bytes.",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "image/jpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/links/{id}/invoice.pdf": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "getInvoicePdf",
        "summary": "The invoice as a PDF",
        "description": "Public by link id. Shows the open version, or the paid version with the payment date once the invoice is paid. A cancelled invoice still renders and is marked Cancelled. 404 for links without an invoice. File name invoice-<number>.pdf.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Link id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "de",
                "en"
              ]
            },
            "description": "Default: the language of the invoice."
          },
          {
            "name": "download",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1"
              ]
            },
            "description": "1 adds content-disposition: attachment."
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "private, no-store"
                }
              },
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "File name; with download=1 the type is attachment."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/invoices": {
      "post": {
        "tags": [
          "Invoices"
        ],
        "operationId": "createInvoice",
        "summary": "Create an invoice",
        "description": "Creates the invoice and its payment link in one step. The number is <prefix>-<running number, 4 digits>. The seller details are copied from the profile at this moment and never change afterwards. 400 profile_incomplete (fields: missing) when business name or address is missing, 400 wallet_required without a payout wallet, and the total must be inside the payment limits.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "sessionCookie": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InvoiceCreate"
              },
              "example": {
                "customer": {
                  "name": "Anna Beispiel",
                  "email": "anna@example.com"
                },
                "items": [
                  {
                    "description": "Beratung",
                    "quantity": "1",
                    "unit_price": "100",
                    "tax_rate": "19"
                  }
                ],
                "due_date": "2026-12-31"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The invoice and its link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "invoice",
                    "link"
                  ],
                  "properties": {
                    "invoice": {
                      "$ref": "#/components/schemas/Invoice"
                    },
                    "link": {
                      "$ref": "#/components/schemas/PublicLink"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "listInvoices",
        "summary": "List your invoices",
        "description": "Newest first, at most 200.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "sessionCookie": []
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "invoices"
                  ],
                  "properties": {
                    "invoices": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invoice"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/invoices/{id}": {
      "get": {
        "tags": [
          "Invoices"
        ],
        "operationId": "getInvoice",
        "summary": "Read one invoice",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Invoice id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The invoice and its link.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "invoice",
                    "link"
                  ],
                  "properties": {
                    "invoice": {
                      "$ref": "#/components/schemas/Invoice"
                    },
                    "link": {
                      "$ref": "#/components/schemas/PublicLink"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/orders/{id}/receipt.pdf": {
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "getReceiptPdf",
        "summary": "The receipt of a paid order",
        "description": "Public. Paid orders only (409 not_paid otherwise). For an order of an invoice link the answer is the paid invoice PDF. The receipt confirms the payment and is not a tax invoice. It shows no wallet address and no transaction id. File name receipt-<order id>.pdf.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Order id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF.",
            "headers": {
              "Cache-Control": {
                "schema": {
                  "type": "string",
                  "example": "private, no-store"
                }
              },
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "description": "File name; with download=1 the type is attachment."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "not_paid: the order has not been paid."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/orders/{id}/email-copy": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "emailCopy",
        "summary": "E-mail me a copy",
        "description": "Public. Sends the receipt (or the paid invoice) as a PDF to the address. The same address again changes nothing and still answers ok. At most 3 different addresses per order (429 too_many). 409 not_paid, 503 mail_unavailable. In a preview deployment nothing is sent and the answer carries simulated: true.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Order id.",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_.-]{1,64}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "maxLength": 254
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "de",
                      "en"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Queued or sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "simulated": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "not_paid"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "502": {
            "description": "mail_failed: the e-mail could not be sent."
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/payments": {
      "get": {
        "tags": [
          "Payments"
        ],
        "operationId": "listPayments",
        "summary": "Payments you received",
        "description": "Newest first. Payment confirmed and payout are separate: payout.status is sent once a payout transaction is known. Amount paid, fees and net amount are in the coin that arrived (ticker).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "sessionCookie": []
          }
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of payments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "payments",
                    "next_cursor"
                  ],
                  "properties": {
                    "payments": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Payment"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    }
  },
  "webhooks": {
    "paymentConfirmed": {
      "post": {
        "tags": [
          "Links"
        ],
        "operationId": "onPaymentConfirmed",
        "summary": "payment.confirmed",
        "description": "Sent to the webhook_url of the link after a payment is confirmed. Up to three tries, 5 second timeout, no redirects. Any 2xx answer counts as delivered. The same payment id can arrive more than once: handle it once. Verify X-PaidNow-Signature on the raw body first: compute HMAC-SHA256 over \"<t>.<raw body>\" with the webhook secret of the key, compare the lower-case hex with v1 in constant time, and reject when t is more than 300 seconds from your clock.",
        "parameters": [
          {
            "name": "X-PaidNow-Signature",
            "in": "header",
            "required": true,
            "description": "t=<unix seconds>,v1=<hex HMAC-SHA256 of \"<t>.<raw body>\">",
            "schema": {
              "type": "string"
            },
            "example": "t=1700000000,v1=9371c4cc2f021772377d2fd5a35b0e39d0da1c887fe6d8c6c03894b6df88d114"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PaymentConfirmed"
              },
              "example": {
                "event": "payment.confirmed",
                "id": "b7e1c0a4d9f2",
                "link_id": "k3J9xQ2mWp",
                "order_id": "ord_5h2k9m",
                "reference": "order-1042",
                "amount": "25.00",
                "currency": "EUR",
                "coin": "USDC",
                "value_coin": "29.120000",
                "txid": "0x9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f9d1f",
                "paid_at": "2026-11-21T18:42:07.000Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Delivered. Any 2xx status counts."
          },
          "400": {
            "description": "Your endpoint refused the signature. PaidNow retries."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "pn_live_<12>_<43>",
        "description": "API key created in the PaidNow app. Server side only."
      },
      "sessionCookie": {
        "type": "apiKey",
        "in": "cookie",
        "name": "pn_session",
        "description": "Signed-in app session. State-changing calls also send the X-PN-CSRF header from the pn_csrf cookie."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The body or the parameters are wrong.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_json",
                "message": "The request body is not valid JSON."
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "The key is unknown or revoked.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_api_key",
                "message": "Invalid or revoked API key."
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "No such link or order.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "not_found",
                "message": "This endpoint does not exist."
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "rate_limited",
                "message": "Too many requests. Try again shortly."
              }
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait.",
            "schema": {
              "type": "integer"
            }
          }
        }
      },
      "Unavailable": {
        "description": "The service cannot take the request right now.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "temporarily_unavailable",
                "message": "Temporary error. Please try again."
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "snake_case code. Branch on this.",
                "examples": [
                  "invalid_api_key",
                  "rate_limited",
                  "not_found",
                  "invalid_json",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string",
                "description": "A plain sentence for people."
              }
            }
          }
        }
      },
      "Decimal": {
        "type": "string",
        "pattern": "^\\d{1,18}(\\.\\d{1,6})?$",
        "description": "Decimal string with up to 6 places. Never a float.",
        "examples": [
          "25.00"
        ]
      },
      "CreateLinkRequest": {
        "type": "object",
        "required": [
          "kind"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "link"
            ]
          },
          "amount": {
            "$ref": "#/components/schemas/Decimal",
            "description": "Fixed amount. Omit it and the customer enters the amount."
          },
          "currency": {
            "type": "string",
            "enum": [
              "EUR",
              "USD"
            ]
          },
          "title": {
            "type": "string",
            "description": "Shown on the pay page."
          },
          "description": {
            "type": "string"
          },
          "webhook_url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "description": "https only. No IP addresses, no localhost, no private or internal host names."
          },
          "reference": {
            "type": "string",
            "maxLength": 64,
            "description": "Your own order id. Returned in the webhook. With purpose business it is shown to the payer."
          },
          "wallet": {
            "type": "string",
            "description": "Leave it out. Links created with a key pay out to the wallet in your account."
          },
          "purpose": {
            "type": "string",
            "enum": [
              "request",
              "business"
            ],
            "description": "What the link is for. Needs a signed-in account."
          },
          "single_use": {
            "type": "boolean",
            "description": "Close the link after the first confirmed payment. Default true for request and business links."
          },
          "expires_in": {
            "type": "integer",
            "minimum": 3600,
            "maximum": 7776000,
            "description": "Seconds until the link expires. Leave out for no expiry."
          }
        }
      },
      "Link": {
        "description": "A link as its owner sees it (create, list, update, cancel): every public field plus the owner fields.",
        "allOf": [
          {
            "$ref": "#/components/schemas/PublicLink"
          },
          {
            "type": "object",
            "required": [
              "id",
              "url",
              "kind",
              "currency",
              "active"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri",
                "description": "Hosted pay page."
              },
              "kind": {
                "type": "string",
                "enum": [
                  "link",
                  "product",
                  "buy"
                ]
              },
              "amount": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/Decimal"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "currency": {
                "type": "string"
              },
              "title": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "active": {
                "type": "boolean"
              },
              "wallet_hint": {
                "type": "string"
              },
              "webhook_url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "paid_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "cancelled_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "PublicLink": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "link",
              "product",
              "buy"
            ]
          },
          "amount": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Decimal"
              },
              {
                "type": "null"
              }
            ]
          },
          "currency": {
            "type": "string"
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "active": {
            "type": "boolean"
          },
          "purpose": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "request",
              "business",
              "invoice",
              null
            ]
          },
          "status": {
            "$ref": "#/components/schemas/LinkStatus"
          },
          "single_use": {
            "type": "boolean"
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "recipient": {
            "$ref": "#/components/schemas/Recipient"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "The order reference of a business link."
          },
          "paid": {
            "type": "object",
            "description": "Only on a paid single-use link. amount and currency are those of the order that paid, not the link's current amount.",
            "properties": {
              "order_id": {
                "type": "string"
              },
              "paid_at": {
                "type": "string",
                "format": "date-time"
              },
              "amount": {
                "type": "string"
              },
              "currency": {
                "type": "string"
              }
            }
          },
          "invoice": {
            "$ref": "#/components/schemas/PublicInvoice"
          },
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Hosted pay page."
          },
          "wallet_hint": {
            "type": "string",
            "description": "First 6 and last 4 characters of the seller wallet."
          }
        }
      },
      "CheckoutRequest": {
        "type": "object",
        "properties": {
          "amount": {
            "$ref": "#/components/schemas/Decimal",
            "description": "Only for links without a fixed amount."
          },
          "method": {
            "type": "string",
            "description": "Leave empty and PaidNow picks the route."
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "The customer's e-mail address, if you have it."
          }
        }
      },
      "CheckoutResponse": {
        "type": "object",
        "required": [
          "order_id",
          "checkout_url"
        ],
        "properties": {
          "order_id": {
            "type": "string"
          },
          "checkout_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Order": {
        "type": "object",
        "required": [
          "status",
          "amount",
          "currency",
          "link_id",
          "mail",
          "emailed"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "open",
              "paid",
              "expired",
              "underpaid",
              "wrong_address",
              "wrong_coin",
              "late",
              "link_closed",
              "unverified"
            ],
            "description": "open, paid or expired; the other values are issues of an attempt that did not settle (the order stays unpaid). link_closed: the payment arrived after the seller cancelled the link or after it expired."
          },
          "amount": {
            "$ref": "#/components/schemas/Decimal"
          },
          "currency": {
            "type": "string"
          },
          "paid_at": {
            "type": "string",
            "format": "date-time",
            "description": "Present once the order is paid."
          },
          "id": {
            "type": "string"
          },
          "link_id": {
            "type": "string"
          },
          "purpose": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "request",
              "business",
              "invoice",
              null
            ]
          },
          "receipt_url": {
            "type": "string",
            "description": "Only when paid: the receipt PDF (for an invoice order the paid invoice PDF). API path starting with /v1/."
          },
          "invoice_number": {
            "type": "string",
            "description": "Only for an invoice order."
          },
          "mail": {
            "type": "boolean",
            "description": "true when Email me a copy can be offered."
          },
          "emailed": {
            "type": "boolean",
            "description": "true when the paid PDF already went to the billing address on file."
          }
        }
      },
      "Config": {
        "type": "object",
        "properties": {
          "brand": {
            "type": "string"
          },
          "site_url": {
            "type": "string",
            "format": "uri"
          },
          "bot_username": {
            "type": [
              "string",
              "null"
            ]
          },
          "coins": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "examples": [
              [
                "USDC@polygon"
              ]
            ]
          },
          "limits": {
            "type": "object",
            "properties": {
              "min": {
                "$ref": "#/components/schemas/Decimal"
              },
              "max": {
                "$ref": "#/components/schemas/Decimal"
              }
            }
          },
          "fees": {
            "type": "object",
            "properties": {
              "markup": {
                "type": "string"
              },
              "upstream": {
                "type": "string"
              }
            }
          },
          "mail": {
            "type": "boolean",
            "description": "true when the API can send e-mail (receipt and invoice copies)."
          }
        }
      },
      "Provider": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "minimum": {
            "type": [
              "number",
              "null"
            ]
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "type": "string"
          }
        }
      },
      "PaymentConfirmed": {
        "type": "object",
        "required": [
          "event",
          "id",
          "link_id",
          "order_id",
          "amount",
          "currency",
          "coin",
          "value_coin",
          "txid",
          "paid_at"
        ],
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "payment.confirmed"
            ]
          },
          "id": {
            "type": "string",
            "description": "Payment id. Use it to ignore duplicates."
          },
          "link_id": {
            "type": "string"
          },
          "order_id": {
            "type": "string"
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "The reference you set on the link."
          },
          "amount": {
            "$ref": "#/components/schemas/Decimal"
          },
          "currency": {
            "type": "string"
          },
          "coin": {
            "type": "string",
            "examples": [
              "USDC"
            ]
          },
          "value_coin": {
            "$ref": "#/components/schemas/Decimal"
          },
          "txid": {
            "type": "string"
          },
          "paid_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Recipient": {
        "type": "object",
        "required": [
          "name",
          "logo_url",
          "business"
        ],
        "description": "Who the payer pays.",
        "properties": {
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "API path starting with /v1/."
          },
          "business": {
            "type": "boolean"
          }
        }
      },
      "LinkStatus": {
        "type": "string",
        "enum": [
          "open",
          "paid",
          "cancelled",
          "expired",
          "off"
        ],
        "description": "Derived, first match wins in the order paid, cancelled, expired, off, open."
      },
      "InvoiceItemInput": {
        "type": "object",
        "required": [
          "description",
          "quantity",
          "unit_price",
          "tax_rate"
        ],
        "properties": {
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "quantity": {
            "type": "string",
            "description": "Decimal above 0, at most 3 places."
          },
          "unit_price": {
            "type": "string",
            "description": "Net price per unit, at most 2 places."
          },
          "tax_rate": {
            "type": "string",
            "description": "Percent, 0 to 30, at most 2 places. A small business always gets 0."
          }
        }
      },
      "InvoiceItem": {
        "allOf": [
          {
            "$ref": "#/components/schemas/InvoiceItemInput"
          },
          {
            "type": "object",
            "required": [
              "net"
            ],
            "properties": {
              "net": {
                "type": "string",
                "description": "quantity x unit_price, rounded half up to cents."
              }
            }
          }
        ]
      },
      "InvoiceTax": {
        "type": "object",
        "required": [
          "rate",
          "net",
          "tax"
        ],
        "properties": {
          "rate": {
            "type": "string"
          },
          "net": {
            "type": "string"
          },
          "tax": {
            "type": "string",
            "description": "Sum of the line nets of this rate x rate, rounded half up to cents."
          }
        }
      },
      "PublicInvoice": {
        "type": "object",
        "required": [
          "number",
          "status",
          "seller_name",
          "customer_name",
          "issue_date",
          "due_date",
          "items",
          "taxes",
          "currency",
          "net",
          "tax",
          "total",
          "note",
          "pdf_url",
          "paid_at"
        ],
        "properties": {
          "number": {
            "type": "string",
            "example": "RE-0001"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "paid",
              "cancelled",
              "expired"
            ]
          },
          "seller_name": {
            "type": "string"
          },
          "customer_name": {
            "type": "string"
          },
          "issue_date": {
            "type": "string",
            "format": "date"
          },
          "due_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceItem"
            }
          },
          "taxes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceTax"
            }
          },
          "currency": {
            "type": "string"
          },
          "net": {
            "type": "string"
          },
          "tax": {
            "type": "string"
          },
          "total": {
            "type": "string",
            "example": "119.00"
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "pdf_url": {
            "type": "string",
            "description": "The open or the paid PDF, whichever applies now. API path starting with /v1/."
          },
          "paid_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Invoice": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PublicInvoice"
          },
          {
            "type": "object",
            "required": [
              "id",
              "link_id",
              "url",
              "customer",
              "service_date",
              "locale",
              "created_at",
              "cancelled_at"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "link_id": {
                "type": "string"
              },
              "url": {
                "type": "string",
                "format": "uri",
                "description": "The one link to view, download and pay."
              },
              "customer": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "email": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "address": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "vat_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "service_date": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "locale": {
                "type": "string",
                "enum": [
                  "de",
                  "en"
                ]
              },
              "created_at": {
                "type": "string",
                "format": "date-time"
              },
              "cancelled_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      },
      "InvoiceCreate": {
        "type": "object",
        "required": [
          "customer",
          "items"
        ],
        "properties": {
          "customer": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "email": {
                "type": "string",
                "maxLength": 254,
                "description": "Billing address. When set, the paid PDF is e-mailed automatically."
              },
              "address": {
                "type": "string",
                "maxLength": 400
              },
              "vat_id": {
                "type": "string",
                "maxLength": 40
              }
            }
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 30,
            "items": {
              "$ref": "#/components/schemas/InvoiceItemInput"
            }
          },
          "currency": {
            "type": "string",
            "description": "One of the configured currencies."
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "Defaults to today (UTC)."
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "description": "Not before the issue date."
          },
          "service_date": {
            "type": "string",
            "maxLength": 60
          },
          "note": {
            "type": "string",
            "maxLength": 500
          },
          "locale": {
            "type": "string",
            "enum": [
              "de",
              "en"
            ]
          },
          "expires_in": {
            "type": "integer",
            "minimum": 3600,
            "maximum": 7776000,
            "description": "Seconds until the link expires."
          }
        }
      },
      "Profile": {
        "type": "object",
        "properties": {
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "business_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "business_address": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 400
          },
          "tax_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "vat_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 40
          },
          "contact_email": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 254
          },
          "small_business": {
            "type": "boolean",
            "description": "true: no tax on invoices."
          },
          "logo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Data URL of the stored logo."
          },
          "invoice_prefix": {
            "type": "string",
            "pattern": "^[A-Z0-9-]{1,8}$"
          },
          "invoice_next": {
            "type": "integer",
            "description": "The running number the next invoice gets."
          }
        }
      },
      "Payment": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "order_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "link_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "link_title": {
            "type": [
              "string",
              "null"
            ]
          },
          "amount": {
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": [
              "string",
              "null"
            ]
          },
          "coin": {
            "type": [
              "string",
              "null"
            ]
          },
          "value_coin": {
            "type": "string"
          },
          "value_forwarded_coin": {
            "type": [
              "string",
              "null"
            ]
          },
          "confirmed_at": {
            "type": "string",
            "format": "date-time"
          },
          "tx_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "purpose": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "request",
              "business",
              "invoice",
              null
            ]
          },
          "reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "invoice_number": {
            "type": [
              "string",
              "null"
            ]
          },
          "ticker": {
            "type": "string",
            "description": "The coin that really arrived, for example USDC."
          },
          "fees_coin": {
            "type": [
              "string",
              "null"
            ],
            "description": "value_coin minus net_coin; null while the net amount is not known."
          },
          "net_coin": {
            "type": [
              "string",
              "null"
            ],
            "description": "What reached the seller's wallet; null while not known."
          },
          "payout": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "sent",
                  "pending"
                ]
              },
              "reference": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "url": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Block explorer page of the payout transaction."
              }
            }
          },
          "receipt_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "API path starting with /v1/."
          },
          "issue": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the payment did not settle its order, for example link_closed (it arrived after the link was ended). Null when it did."
          }
        }
      }
    }
  }
}
