ATUM REST API

Purchase order invoices

Purchase Orders PRO

The purchase order invoices API allows you to create, view, update, and delete individual, or a batch, of purchase order invoices. It's available when the Purchase Orders PRO add-on is active.

Every invoice is linked to a purchase order (po_id) and every invoice item is linked to one of the purchase order's items (po_item_id): a line item, a fee or a shipping cost. The invoices of a purchase order are also listed in its invoices property (see Purchase Orders PRO properties).

The invoices endpoints aren't nested under the purchase orders ones: they live at /wp-json/wc/v3/atum/invoice. To get the invoices of a specific purchase order, use the parent parameter when listing them.

Invoice properties

AttributeTypeDescription
idintegerUnique identifier for the resource. read-only
namestringThe invoice name.
document_numberstringThe document number of the invoice.
po_idintegerThe ID of the purchase order linked to the invoice. mandatory
date_createddate-timeThe date the invoice was created, in the site's timezone.
date_created_gmtdate-timeThe date the invoice was created, as GMT. read-only
totalstringThe invoice total, including taxes. read-only
filesarrayIDs of the media library attachments linked to the invoice. When sent, they replace the current files.
itemsarrayInvoice items. See Invoice - Items properties mandatory
author_idintegerID of the user that will be set as the invoice author. Only when updating an invoice. write-only

Currently, the invoice responses don't include the name, and they return date_created and date_created_gmt as null.

Invoice - Items properties

AttributeTypeDescription
idintegerInvoice item ID. Send it to update an existing item. Items sent without id are added to the invoice. read-only
namestringProduct name. read-only
po_item_idintegerID of the purchase order item (line item, fee or shipping cost) that is being invoiced. Required when adding an item.
typestringType of the purchase order item to add. Options: line_item (default; product and invoice_item are accepted as aliases), fee and shipping. write-only
quantitynumberInvoiced quantity. Required (and greater than 0) when adding any item, including fees and shipping costs.
qtynumberAlias of quantity, used by the admin UI. write-only
product_idintegerProduct ID. Send it as null to remove the item from the invoice.
variation_idintegerVariation ID, if applicable.
subtotalstringItem subtotal, excluding tax. read-only
subtotal_taxstringItem subtotal tax. read-only
totalstringItem total, excluding tax. read-only
total_taxstringItem total tax. read-only
taxesobjectItem taxes: the subtotal and total amounts, keyed by tax rate ID. read-only
deletebooleanSet to true to remove the item from the invoice. write-only

Only the product items are listed in items. The fees and shipping costs added to the invoice are included in its total, but they aren't returned in the response.

The item values that are stored as item meta (product_id, variation_id, po_item_id and quantity) are returned as strings.

Create an invoice

This API helps you to create a new invoice for a purchase order. The po_id and at least one valid item (with its po_item_id and a quantity greater than 0) are required. The item prices and taxes are taken from the purchase order items.

HTTP request

POST/wp-json/wc/v3/atum/invoice
curl -X POST https://example.com/wp-json/wc/v3/atum/invoice \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json" \
	-d '{
  "po_id": 2156,
  "name": "Invoice #1",
  "document_number": "INV-0001",
  "items": [
    {
      "po_item_id": 337,
      "quantity": 2
    },
    {
      "po_item_id": 338,
      "quantity": 1
    }
  ]
}'
JSON response example
{
    "id": 2161,
    "document_number": "INV-0001",
    "files": [],
    "total": "31.20",
    "items": [
        {
            "id": 350,
            "name": "Woo Single #1",
            "product_id": "93",
            "variation_id": "0",
            "po_item_id": "337",
            "quantity": "2",
            "subtotal": "6",
            "subtotal_tax": "1.2",
            "total": "6",
            "total_tax": "1.2",
            "taxes": {
                "subtotal": {
                    "1": "1.2"
                },
                "total": {
                    "1": "1.2"
                }
            }
        },
        {
            "id": 351,
            "name": "Ship Your Idea 2 - Black",
            "product_id": "22",
            "variation_id": "23",
            "po_item_id": "338",
            "quantity": "1",
            "subtotal": "20",
            "subtotal_tax": "4",
            "total": "20",
            "total_tax": "4",
            "taxes": {
                "subtotal": {
                    "1": "4"
                },
                "total": {
                    "1": "4"
                }
            }
        }
    ],
    "po_id": 2156,
    "date_created": null,
    "date_created_gmt": null,
    "_links": {
        "self": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice/2161"
            }
        ],
        "collection": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice"
            }
        ]
    }
}

Retrieve an invoice

This API lets you retrieve and view a specific invoice.

HTTP request

GET/wp-json/wc/v3/atum/invoice/<id>
curl https://example.com/wp-json/wc/v3/atum/invoice/2161 \
	-u consumer_key:consumer_secret
JSON response example
{
    "id": 2161,
    "document_number": "INV-0001",
    "files": [],
    "total": "31.20",
    "items": [
        {
            "id": 350,
            "name": "Woo Single #1",
            "product_id": "93",
            "variation_id": "0",
            "po_item_id": "337",
            "quantity": "2",
            "subtotal": "6",
            "subtotal_tax": "1.2",
            "total": "6",
            "total_tax": "1.2",
            "taxes": {
                "subtotal": {
                    "1": "1.2"
                },
                "total": {
                    "1": "1.2"
                }
            }
        },
        {
            "id": 351,
            "name": "Ship Your Idea 2 - Black",
            "product_id": "22",
            "variation_id": "23",
            "po_item_id": "338",
            "quantity": "1",
            "subtotal": "20",
            "subtotal_tax": "4",
            "total": "20",
            "total_tax": "4",
            "taxes": {
                "subtotal": {
                    "1": "4"
                },
                "total": {
                    "1": "4"
                }
            }
        }
    ],
    "po_id": 2156,
    "date_created": null,
    "date_created_gmt": null,
    "_links": {
        "self": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice/2161"
            }
        ],
        "collection": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice"
            }
        ]
    }
}

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
dpintegerNumber of decimal points to use in each resource. Default is the store's number of decimals.

List all invoices

This API helps you to view all the invoices.

HTTP request

GET/wp-json/wc/v3/atum/invoice
curl https://example.com/wp-json/wc/v3/atum/invoice?parent=2156 \
	-u consumer_key:consumer_secret
JSON response example
[
    {
        "id": 2161,
        "document_number": "INV-0001",
        "files": [],
        "total": "31.20",
        "items": [
            {
                "id": 350,
                "name": "Woo Single #1",
                "product_id": "93",
                "variation_id": "0",
                "po_item_id": "337",
                "quantity": "2",
                "subtotal": "6",
                "subtotal_tax": "1.2",
                "total": "6",
                "total_tax": "1.2",
                "taxes": {
                    "subtotal": {
                        "1": "1.2"
                    },
                    "total": {
                        "1": "1.2"
                    }
                }
            },
            {
                "id": 351,
                "name": "Ship Your Idea 2 - Black",
                "product_id": "22",
                "variation_id": "23",
                "po_item_id": "338",
                "quantity": "1",
                "subtotal": "20",
                "subtotal_tax": "4",
                "total": "20",
                "total_tax": "4",
                "taxes": {
                    "subtotal": {
                        "1": "4"
                    },
                    "total": {
                        "1": "4"
                    }
                }
            }
        ],
        "po_id": 2156,
        "date_created": null,
        "date_created_gmt": null,
        "_links": {
            "self": [
                {
                    "href": "https://example.com/wp-json/wc/v3/atum/invoice/2161"
                }
            ],
            "collection": [
                {
                    "href": "https://example.com/wp-json/wc/v3/atum/invoice"
                }
            ]
        }
    }
]

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
searchstringLimit results to the invoices whose name matches a string.
afterstringLimit response to resources published after a given ISO8601 compliant date.
beforestringLimit response to resources published before a given ISO8601 compliant date.
modified_afterstringLimit response to resources modified after a given ISO8601 compliant date.
modified_beforestringLimit response to resources modified before a given ISO8601 compliant date.
dates_are_gmtbooleanWhether to consider GMT post dates when limiting response by published or modified date. Default is false.
excludearrayEnsure result set excludes specific IDs.
includearrayLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderbystringSort collection by object attribute. Options: date, id, include, title, slug and modified. Default is date.
parentarrayLimit result set to the invoices of specific purchase order IDs.
parent_excludearrayLimit result set to all the invoices except those of specific purchase order IDs.
statusarrayLimit result set to invoices which have specific statuses. Options: any, publish and trash. Default is any.
dpintegerNumber of decimal points to use in each resource. Default is 2.

Update an invoice

This API lets you make changes to an invoice. Items sent with an id are updated, items sent without it are added from the linked purchase order (they need a po_item_id and a quantity), and items sent with delete set to true are removed.

HTTP request

PUT/wp-json/wc/v3/atum/invoice/<id>
curl -X PUT https://example.com/wp-json/wc/v3/atum/invoice/2161 \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json" \
	-d '{
  "document_number": "INV-0001-B",
  "files": [
    2175
  ]
}'
JSON response example
{
    "id": 2161,
    "document_number": "INV-0001-B",
    "files": [
        2175
    ],
    "total": "31.20",
    "items": [
        {
            "id": 350,
            "name": "Woo Single #1",
            "product_id": "93",
            "variation_id": "0",
            "po_item_id": "337",
            "quantity": "2",
            "subtotal": "6",
            "subtotal_tax": "1.2",
            "total": "6",
            "total_tax": "1.2",
            "taxes": {
                "subtotal": {
                    "1": "1.2"
                },
                "total": {
                    "1": "1.2"
                }
            }
        },
        {
            "id": 351,
            "name": "Ship Your Idea 2 - Black",
            "product_id": "22",
            "variation_id": "23",
            "po_item_id": "338",
            "quantity": "1",
            "subtotal": "20",
            "subtotal_tax": "4",
            "total": "20",
            "total_tax": "4",
            "taxes": {
                "subtotal": {
                    "1": "4"
                },
                "total": {
                    "1": "4"
                }
            }
        }
    ],
    "po_id": 2156,
    "date_created": null,
    "date_created_gmt": null,
    "_links": {
        "self": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice/2161"
            }
        ],
        "collection": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice"
            }
        ]
    }
}

Delete an invoice

This API helps you delete an invoice. Invoices don't support trashing, so they are always deleted permanently.

HTTP request

DELETE/wp-json/wc/v3/atum/invoice/<id>
curl -X DELETE https://example.com/wp-json/wc/v3/atum/invoice/2161 \
	-u consumer_key:consumer_secret
JSON response example
{
    "id": 2161,
    "document_number": "INV-0001",
    "files": [],
    "total": "31.20",
    "items": [
        {
            "id": 350,
            "name": "Woo Single #1",
            "product_id": "93",
            "variation_id": "0",
            "po_item_id": "337",
            "quantity": "2",
            "subtotal": "6",
            "subtotal_tax": "1.2",
            "total": "6",
            "total_tax": "1.2",
            "taxes": {
                "subtotal": {
                    "1": "1.2"
                },
                "total": {
                    "1": "1.2"
                }
            }
        },
        {
            "id": 351,
            "name": "Ship Your Idea 2 - Black",
            "product_id": "22",
            "variation_id": "23",
            "po_item_id": "338",
            "quantity": "1",
            "subtotal": "20",
            "subtotal_tax": "4",
            "total": "20",
            "total_tax": "4",
            "taxes": {
                "subtotal": {
                    "1": "4"
                },
                "total": {
                    "1": "4"
                }
            }
        }
    ],
    "po_id": 2156,
    "date_created": null,
    "date_created_gmt": null,
    "_links": {
        "self": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice/2161"
            }
        ],
        "collection": [
            {
                "href": "https://example.com/wp-json/wc/v3/atum/invoice"
            }
        ]
    }
}

Batch update invoices

This API helps you to batch create, update and delete multiple invoices.

Note: By default it's limited to up to 100 objects to be created, updated or deleted.

HTTP request

POST/wp-json/wc/v3/atum/invoice/batch
curl -X POST https://example.com/wp-json/wc/v3/atum/invoice/batch \
	-u consumer_key:consumer_secret \
	-H "Content-Type: application/json" \
	-d '{
  "create": [
    {
      "po_id": 2163,
      "document_number": "INV-0002",
      "items": [
        {
          "po_item_id": 360,
          "quantity": 1
        }
      ]
    }
  ],
  "update": [
    {
      "id": 2161,
      "document_number": "INV-0001-B"
    }
  ],
  "delete": [
    2152
  ]
}'
JSON response example
{
    "create": [
        {
            "id": 2173,
            "document_number": "INV-0002",
            "files": [],
            "total": "18.15",
            "items": [
                {
                    "id": 355,
                    "name": "Woo Single #2",
                    "product_id": "94",
                    "variation_id": "0",
                    "po_item_id": "360",
                    "quantity": "1",
                    "subtotal": "15",
                    "subtotal_tax": "3.15",
                    "total": "15",
                    "total_tax": "3.15",
                    "taxes": {
                        "subtotal": {
                            "1": "3.15"
                        },
                        "total": {
                            "1": "3.15"
                        }
                    }
                }
            ],
            "po_id": 2163,
            "date_created": null,
            "date_created_gmt": null,
            "_links": {
                "self": [
                    {
                        "href": "https://example.com/wp-json/wc/v3/atum/invoice/2173"
                    }
                ],
                "collection": [
                    {
                        "href": "https://example.com/wp-json/wc/v3/atum/invoice"
                    }
                ]
            }
        }
    ],
    "update": [
        {
            "id": 2161,
            "document_number": "INV-0001-B",
            "files": [],
            "total": "31.20",
            "items": [
                {
                    "id": 350,
                    "name": "Woo Single #1",
                    "product_id": "93",
                    "variation_id": "0",
                    "po_item_id": "337",
                    "quantity": "2",
                    "subtotal": "6",
                    "subtotal_tax": "1.2",
                    "total": "6",
                    "total_tax": "1.2",
                    "taxes": {
                        "subtotal": {
                            "1": "1.2"
                        },
                        "total": {
                            "1": "1.2"
                        }
                    }
                },
                {
                    "id": 351,
                    "name": "Ship Your Idea 2 - Black",
                    "product_id": "22",
                    "variation_id": "23",
                    "po_item_id": "338",
                    "quantity": "1",
                    "subtotal": "20",
                    "subtotal_tax": "4",
                    "total": "20",
                    "total_tax": "4",
                    "taxes": {
                        "subtotal": {
                            "1": "4"
                        },
                        "total": {
                            "1": "4"
                        }
                    }
                }
            ],
            "po_id": 2156,
            "date_created": null,
            "date_created_gmt": null,
            "_links": {
                "self": [
                    {
                        "href": "https://example.com/wp-json/wc/v3/atum/invoice/2161"
                    }
                ],
                "collection": [
                    {
                        "href": "https://example.com/wp-json/wc/v3/atum/invoice"
                    }
                ]
            }
        }
    ],
    "delete": [
        {
            "id": 2152,
            "document_number": "INV-0098",
            "files": [],
            "total": "36.30",
            "items": [
                {
                    "id": 331,
                    "name": "Woo Single #3",
                    "product_id": "95",
                    "variation_id": "0",
                    "po_item_id": "325",
                    "quantity": "3",
                    "subtotal": "30",
                    "subtotal_tax": "6.3",
                    "total": "30",
                    "total_tax": "6.3",
                    "taxes": {
                        "subtotal": {
                            "1": "6.3"
                        },
                        "total": {
                            "1": "6.3"
                        }
                    }
                }
            ],
            "po_id": 2140,
            "date_created": null,
            "date_created_gmt": null,
            "_links": {
                "self": [
                    {
                        "href": "https://example.com/wp-json/wc/v3/atum/invoice/2152"
                    }
                ],
                "collection": [
                    {
                        "href": "https://example.com/wp-json/wc/v3/atum/invoice"
                    }
                ]
            }
        }
    ]
}

On this page