Requirements #
Activate WooCommerce REST API #
Path: WooCommerce > Settings > Advanced > REST API.
Our Invoicing plugin uses the WooCommerce REST API in order to provide REST API functionality.
Enable Invoice REST API option #
Path: WooCommerce > PDF Invoices > Pro, then scroll down to REST API > Enable.

REST API endpoints #
This can also be found in our Invoicing plugin.
Path: WooCommerce > Settings > Advanced.
Samples #
Compatible software | File |
Insomnia, Postman | rest-collection-v1.1.json |
Retrieve an order #
GET:
This API lets you retrieve and view a specific order. All document data is under the documents
field of the response.
http://your-site/wp-json/wc/v3/orders/<id>
JSON response example – retrieve an order: #
{ ... "documents": { "invoice": { "number": "1", "date": "2024-02-27T15:34:31", "date_timestamp": 1709048071 }, "proforma": { "number": 1, "date": "2024-02-23T13:25:50", "date_timestamp": 1708694750 }, "credit-note": [ { "number": 2, "date": "2024-02-28T10:34:31", "date_timestamp": 1735893084 }, { "number": 3, "date": "2024-02-28T10:34:32", "date_timestamp": 1735892964 } ] }, }
NOTE: Since an order can have multiple refunds, and therefore multiple credit notes, the Credit Note output will be an array of documents rather than a single document.
Create or regenerate a document #
This API lets you create or regenerate a document for a specific order and view its details. If the document is already created and the regenerate query parameter is false
, it’ll return the current document details.
POST:
http://your-site/wp-json/wc/v3/orders/<id>/documents
Query parameters – create or regenerate a document #
Parameter | Type | Description |
type | string | Required The document type. For example invoice . |
regenerate | boolean | If true , it regenerates the document if it already exists. The default is false . |
Body form-data – create or regenerate a document #
Parameter | Type | Description |
number | text | Sets the document number. |
date | text | Sets the document date. It should be in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. |
note | text | Sets the document note. |
JSON response example – create or regenerate a document: #
{ "number": "1078", "date": "2024-03-02T13:37:25", "date_timestamp": 1709386645 }
Download a document #
This API lets you download a PDF document for a specific order.
GET:
http://your-site/wp-json/wc/v3/orders/<id>/documents
Query parameters – download a document #
Parameter | Type | Description |
type | string | Required. The document type. For example invoice |
generate | boolean | If true , it generates the document if it doesn’t already exist. The default is false . |
Delete a document #
This API lets you delete a document.
Delete:
http://your-site/wp-json/wc/v3/orders/<id>/documents
Query parameters – delete a document #
Parameter | Type | Description |
type | string | Required. The document type. For example invoice . |
JSON response example – delete a document: #
{ "success": "Document deleted." }