> For the complete documentation index, see [llms.txt](https://docs.alternativepayments.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alternativepayments.io/api-reference/invoices.md).

# Invoices

## List invoices

> Get a paginated list of invoices with optional filtering

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:read"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"PaginatedResponse-Invoice":{"properties":{"data":{"items":{"$ref":"#/components/schemas/Invoice"},"type":"array"},"end_cursor":{"type":"string"},"has_next_page":{"type":"boolean"},"has_previous_page":{"type":"boolean"},"start_cursor":{"type":"string"}},"type":"object"},"Invoice":{"properties":{"created_at":{"type":"string"},"currency":{"type":"string"},"customer_id":{"type":"string"},"due_date":{"type":"string"},"id":{"type":"string"},"invoice_number":{"type":"string"},"last_notification_at":{"type":"string"},"line_items":{"items":{"$ref":"#/components/schemas/InvoiceLineItem"},"type":"array"},"memo":{"type":"string"},"status":{"type":"string"},"sub_total":{"type":"number"},"total":{"type":"number"}},"type":"object"},"InvoiceLineItem":{"properties":{"amount":{"type":"number"},"description":{"type":"string"},"quantity":{"type":"integer"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"}}},"paths":{"/invoices":{"get":{"description":"Get a paginated list of invoices with optional filtering","operationId":"listInvoices","parameters":[{"schema":{"type":"integer","default":100},"description":"Number of items to return","in":"query","name":"limit"},{"schema":{"type":"string"},"description":"Specifies the cursor after which to start returning results. For the first page, this should be left empty. For subsequent pages, use the value of the end_cursor field from the previous response.","in":"query","name":"after"},{"schema":{"type":"string"},"description":"Specifies the cursor before which to return results. Use this to paginate backwards. For example, to load the previous page, provide the value of the start_cursor field from the last response.","in":"query","name":"before"},{"schema":{"type":"string"},"description":"Filter by creation date start (RFC3339 format)","in":"query","name":"created_at_start"},{"schema":{"type":"string"},"description":"Filter by creation date end (RFC3339 format)","in":"query","name":"created_at_end"},{"schema":{"type":"string"},"description":"Filter by due date start (RFC3339 format)","in":"query","name":"due_date_start"},{"schema":{"type":"string"},"description":"Filter by due date end (RFC3339 format)","in":"query","name":"due_date_end"},{"schema":{"type":"string"},"description":"Filter by customer ID","in":"query","name":"customer_id"},{"schema":{"type":"string"},"description":"Filter by invoice number","in":"query","name":"invoice_number"},{"schema":{"type":"string","enum":["UPCOMING","OVERDUE","RECEIVED","PAID","ARCHIVED"]},"description":"Filter by invoice status","in":"query","name":"status"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse-Invoice"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"List invoices","tags":["Invoices"]}}}}
```

## Create an invoice

> Create a new invoice with line items

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:write"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"Invoice":{"properties":{"created_at":{"type":"string"},"currency":{"type":"string"},"customer_id":{"type":"string"},"due_date":{"type":"string"},"id":{"type":"string"},"invoice_number":{"type":"string"},"last_notification_at":{"type":"string"},"line_items":{"items":{"$ref":"#/components/schemas/InvoiceLineItem"},"type":"array"},"memo":{"type":"string"},"status":{"type":"string"},"sub_total":{"type":"number"},"total":{"type":"number"}},"type":"object"},"InvoiceLineItem":{"properties":{"amount":{"type":"number"},"description":{"type":"string"},"quantity":{"type":"integer"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"CreateInvoiceInput":{"properties":{"customer_id":{"type":"string"},"due_date":{"description":"Due date in YYYY-MM-DD format. If omitted, defaults to the current date from invoice creation.","type":"string"},"exclude_from_autopay":{"description":"When true, this invoice is excluded from Autopay at creation time. Use this\nwhen your integration pays the invoice synchronously via API and you want to\nguarantee Autopay never charges the same invoice. Defaults to false.","type":"boolean"},"line_items":{"items":{"$ref":"#/components/schemas/InvoiceLineItem"},"type":"array"}},"type":"object"}}},"paths":{"/invoices":{"post":{"description":"Create a new invoice with line items","operationId":"createInvoice","responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"422":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"Create an invoice","tags":["Invoices"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateInvoiceInput"}}},"description":"Invoice information","required":true}}}}}
```

## Get an invoice

> Get invoice details by ID

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:read"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"Invoice":{"properties":{"created_at":{"type":"string"},"currency":{"type":"string"},"customer_id":{"type":"string"},"due_date":{"type":"string"},"id":{"type":"string"},"invoice_number":{"type":"string"},"last_notification_at":{"type":"string"},"line_items":{"items":{"$ref":"#/components/schemas/InvoiceLineItem"},"type":"array"},"memo":{"type":"string"},"status":{"type":"string"},"sub_total":{"type":"number"},"total":{"type":"number"}},"type":"object"},"InvoiceLineItem":{"properties":{"amount":{"type":"number"},"description":{"type":"string"},"quantity":{"type":"integer"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"}}},"paths":{"/invoices/{id}":{"get":{"description":"Get invoice details by ID","operationId":"getInvoice","parameters":[{"schema":{"type":"string"},"description":"Invoice ID","in":"path","name":"id","required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"Get an invoice","tags":["Invoices"]}}}}
```

## Archive an invoice

> Archive an invoice

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:write"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"Invoice":{"properties":{"created_at":{"type":"string"},"currency":{"type":"string"},"customer_id":{"type":"string"},"due_date":{"type":"string"},"id":{"type":"string"},"invoice_number":{"type":"string"},"last_notification_at":{"type":"string"},"line_items":{"items":{"$ref":"#/components/schemas/InvoiceLineItem"},"type":"array"},"memo":{"type":"string"},"status":{"type":"string"},"sub_total":{"type":"number"},"total":{"type":"number"}},"type":"object"},"InvoiceLineItem":{"properties":{"amount":{"type":"number"},"description":{"type":"string"},"quantity":{"type":"integer"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"}}},"paths":{"/invoices/{id}":{"delete":{"description":"Archive an invoice","operationId":"archiveInvoice","parameters":[{"schema":{"type":"string"},"description":"Invoice ID","in":"path","name":"id","required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"Archive an invoice","tags":["Invoices"]}}}}
```

## Get hosted payment link for invoice

> Get a payment link for the specified invoice

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:read"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"GetPaymentLinkData":{"properties":{"url":{"type":"string"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"}}},"paths":{"/invoices/{id}/payment-link":{"get":{"description":"Get a payment link for the specified invoice","operationId":"getInvoicePaymentLink","parameters":[{"schema":{"type":"string"},"description":"Invoice ID","in":"path","name":"id","required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPaymentLinkData"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"Get hosted payment link for invoice","tags":["Invoices"]}}}}
```

## Upload invoice PDF

> Upload the original invoice PDF (max 10 MB). Provide exactly one of \`content\` (base64-encoded bytes) or \`url\` (a public HTTPS link we download once, at upload time). Both variants behave identically once accepted: we store our own copy of the bytes and never read the link again, so the document keeps serving even if your host later goes away, and an unreachable link fails this request outright rather than degrading for a customer later. \*\*Updates are push-only:\*\* we never re-read the link or poll for changes, so a PDF updated in your system is not reflected here until you send this request again — with fresh \`content\`, or with the \`url\` (the same url is fine; we re-download it at that moment). Each upload replaces the previous PDF; last write wins. Only invoices synced from an accounting integration accept a PDF: an invoice created through \`POST /invoices\` has no original document from your system, and returns \`422 unsupported\_invoice\`.

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:write"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"UploadInvoicePdfReply":{"properties":{"path":{"description":"Path is the stored location of the PDF, for both the content and url\nvariants. It is an opaque identifier, not a downloadable link — to retrieve\nthe document, call GET /invoices/{id}/pdf-link for a signed URL.","type":"string"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"},"UploadInvoicePdfInput":{"description":"Invoice PDF upload request. Provide exactly one of content (base64-encoded bytes) or url (public HTTPS link to the PDF, downloaded once at upload time and stored). Either way we keep our own copy and never read the link again, so send the request again to publish an updated document.","properties":{"content":{"description":"The PDF document as standard base64 (RFC 4648). Must decode to a valid PDF\n(the file must start with the PDF header) of at most 10 MB. Mutually\nexclusive with url.","type":"string"},"url":{"description":"A public, absolute HTTPS link to the PDF. Fetched exactly once, at upload\ntime; we store our own copy and never read the link again — if the document\nbehind it changes, re-send this request to publish the new version. HTTP links,\nredirects to non-HTTPS locations, and links resolving to private addresses\nare rejected. The response must be a PDF of at most 10 MB. Mutually\nexclusive with content.","type":"string"}},"type":"object"}}},"paths":{"/invoices/{id}/pdf":{"post":{"description":"Upload the original invoice PDF (max 10 MB). Provide exactly one of `content` (base64-encoded bytes) or `url` (a public HTTPS link we download once, at upload time). Both variants behave identically once accepted: we store our own copy of the bytes and never read the link again, so the document keeps serving even if your host later goes away, and an unreachable link fails this request outright rather than degrading for a customer later. **Updates are push-only:** we never re-read the link or poll for changes, so a PDF updated in your system is not reflected here until you send this request again — with fresh `content`, or with the `url` (the same url is fine; we re-download it at that moment). Each upload replaces the previous PDF; last write wins. Only invoices synced from an accounting integration accept a PDF: an invoice created through `POST /invoices` has no original document from your system, and returns `422 unsupported_invoice`.","operationId":"uploadInvoicePdf","parameters":[{"schema":{"type":"string"},"description":"Invoice ID","in":"path","name":"id","required":true}],"responses":{"200":{"description":"`path` is the stored location of the PDF, for both variants. It is an opaque identifier — retrieve the document via GET /invoices/{id}/pdf-link","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadInvoicePdfReply"}}}},"400":{"description":"Invalid request: both or neither of `content`/`url` provided; `content` is not valid base64 or does not decode to a PDF; `url` is not HTTPS, redirects to a non-HTTPS location, is unreachable (non-2xx), resolves to a blocked address, exceeds the redirect limit, times out, or does not return a PDF","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"404":{"description":"Invoice not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"413":{"description":"The PDF exceeds the 10 MB limit (applies to both the decoded `content` bytes and the `url` response body)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"422":{"description":"The invoice is not synced from an accounting integration","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"Upload invoice PDF","tags":["Invoices"],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UploadInvoicePdfInput"}}},"description":"PDF to upload: exactly one of content (base64-encoded bytes) or url (public HTTPS link, downloaded once at upload time)","required":true}}}}}
```

## Get invoice PDF link

> Get a signed PDF URL for the specified invoice

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:read"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"GetPdfLinkData":{"properties":{"url":{"type":"string"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"}}},"paths":{"/invoices/{id}/pdf-link":{"get":{"description":"Get a signed PDF URL for the specified invoice","operationId":"getInvoicePdfLink","parameters":[{"schema":{"type":"string"},"description":"Invoice ID","in":"path","name":"id","required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GetPdfLinkData"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"Get invoice PDF link","tags":["Invoices"]}}}}
```

## Restore an invoice

> Restore an invoice

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.2.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"OAuth2ClientCredentials":["invoices:write"]}],"components":{"securitySchemes":{"OAuth2ClientCredentials":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"/oauth/token","scopes":{"read":"Read access","write":"Write access"}}}}},"schemas":{"Invoice":{"properties":{"created_at":{"type":"string"},"currency":{"type":"string"},"customer_id":{"type":"string"},"due_date":{"type":"string"},"id":{"type":"string"},"invoice_number":{"type":"string"},"last_notification_at":{"type":"string"},"line_items":{"items":{"$ref":"#/components/schemas/InvoiceLineItem"},"type":"array"},"memo":{"type":"string"},"status":{"type":"string"},"sub_total":{"type":"number"},"total":{"type":"number"}},"type":"object"},"InvoiceLineItem":{"properties":{"amount":{"type":"number"},"description":{"type":"string"},"quantity":{"type":"integer"}},"type":"object"},"HttpError":{"properties":{"code":{"type":"string"},"message":{"type":"string"},"validation_errors":{"additionalProperties":{"type":"string"},"type":"object"}},"type":"object"}}},"paths":{"/invoices/{id}/restore":{"post":{"description":"Restore an invoice","operationId":"restoreInvoice","parameters":[{"schema":{"type":"string"},"description":"Invoice ID","in":"path","name":"id","required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"404":{"description":"Not Found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HttpError"}}}}},"summary":"Restore an invoice","tags":["Invoices"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.alternativepayments.io/api-reference/invoices.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
