Create an invoice payment link
POST /api/v2/billing/invoices/{id}/actions/generate-payment-link
Get a link to a payment page for an unpaid invoice, to share with whoever pays it. The page needs no login. It shows the invoice lines and offers card, Swish or Alipay where the invoice allows them. A new link is valid for 30 days. While a link is still active, you get the same link back. It keeps its first expiry date. invoice.amount is the invoice total, not the amount left to pay. The amount left is totals.outstanding on GET /api/v2/billing/invoices/{id}. Use GET /api/v2/billing/invoices/{id}/payment-link to read the current link without creating one.
Authentication: An API key with the scope write:billing. About keys and scopes
Request
Path parameters
idstringrequiredGET /api/v2/billing/invoices (inv_…).Example
curl -X POST "https://cloud.hostup.se/api/v2/billing/invoices/inv_01hxa3b4c5d6e7f8g9h0j1k2m3/actions/generate-payment-link" \ -H "Authorization: Bearer $HOSTUP_API_KEY" \ -H "Content-Type: application/json"Responses
200 The payment link.
{ "paymentUrl": "https://cloud.hostup.se/billing/pay/550e8400-e29b-41d4-a716-446655440000", "expiresAt": "2026-05-27T12:00:00.000Z", "invoice": { "id": "inv_01hxa3b4c5d6e7f8g9h0j1k2m3", "number": "202600001", "amount": 159, "currencyCode": "SEK", "dueAt": "2026-05-11T23:59:59.000Z", "status": "unpaid", "paymentUrl": "https://cloud.hostup.se/billing/pay/550e8400-e29b-41d4-a716-446655440000" }}Response fields
paymentUrlstringexpiresAtstring or nullinvoiceobjectidstringnumberstring or nullamountnumber or nulltotals.outstanding on GET /api/v2/billing/invoices/{id}.currencyCodestringdueAtstring or nullstatusstringpaymentUrlstring or nullpaymentUrl.Errors
Errors are Problem Details with a stable code. Branch on the code, not on the text.
| 400 | Invalid request. The response body is an RFC 7807 Problem Details document. |
| 401 | Unauthorized. Authentication is required. |
| 403 | forbidden: the API key lacks write:billing. requiredScopes names it. The same code comes back when the account is not active. |
| 404 | Not found. The resource does not exist or is not owned by the caller; code is invoice_not_found. |
| 409 | The invoice cannot be paid. invoice_already_paid: it is already paid. invoice_not_payable: it is not unpaid or has nothing left to pay. An invoice in debt collection shows as unpaid on GET /api/v2/billing/invoices/{id}. This call refuses it with invoice_not_payable and invoice.status collections. |
| 429 | Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers. |
| 500 | Internal error. Retry later or contact support if the issue persists. |
| 502 | Upstream failure. A dependent provider request failed; the Problem Details code is upstream_failed. Retry later or contact support if the issue persists. |