Skip to content

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

idstringrequired
Public invoice ID from GET /api/v2/billing/invoices (inv_…).

Example

POST /api/v2/billing/invoices/{id}/actions/generate-payment-link
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.

Response 200
{
"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
paymentUrlstring
The link to pay the invoice. Send it to whoever pays. It offers card, Swish and the other methods available for the invoice.
expiresAtstring or null
When the link stops working. A link you get back again keeps its first expiry.
invoiceobject
idstring
numberstring or null
amountnumber or null
The invoice total, not the amount left to pay. The amount left is totals.outstanding on GET /api/v2/billing/invoices/{id}.
currencyCodestring
dueAtstring or null
statusstring
paymentUrlstring or null
The same link as paymentUrl.

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400Invalid request. The response body is an RFC 7807 Problem Details document.
401Unauthorized. Authentication is required.
403forbidden: the API key lacks write:billing. requiredScopes names it. The same code comes back when the account is not active.
404Not found. The resource does not exist or is not owned by the caller; code is invoice_not_found.
409The 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.
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.
502Upstream failure. A dependent provider request failed; the Problem Details code is upstream_failed. Retry later or contact support if the issue persists.