Create an invoice
const url = 'https://app.commitly.com/api/invoices/';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"reference":"AR-007","name":"Equipment","notes":"Special equipment","type":"RE","date":"2022-04-16","amount":7450,"due_date":"2022-04-28","paid_amount":0,"category":1002}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://app.commitly.com/api/invoices/ \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "reference": "AR-007", "name": "Equipment", "notes": "Special equipment", "type": "RE", "date": "2022-04-16", "amount": 7450, "due_date": "2022-04-28", "paid_amount": 0, "category": 1002 }'Creates an invoice (open item).
Required: reference (invoice number), name, amount, due_date.
If type is omitted, it is derived from the sign of amount: a positive amount
creates a receivable (RE), any other amount a payable (PA).
If expected_date is omitted, COMMITLY sets the expected payment date to the
due date, or to the current date if the due date lies in the past.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Invoice number.
Decimal with at most 10 digits and 2 decimal places. A JSON number or a
numeric string ("7450.00").
Invoice date.
Description of the invoice.
RE receivable, PA payable. Optional on create: if omitted, a positive
amount sets RE, any other amount PA.
Additional information for mapping rules, e.g. the category.
Decimal with at most 10 digits and 2 decimal places. A JSON number or a
numeric string ("7450.00").
ID of a leaf category of the company (from GET /categories/).
Expected payment date, if different from the due date. If omitted, it is set to the due date, or to the current date if the due date lies in the past.
Example
{ "reference": "AR-007", "name": "Equipment", "notes": "Special equipment", "type": "RE", "date": "2022-04-16", "amount": 7450, "due_date": "2022-04-28", "paid_amount": 0, "category": 1002}Responses
Section titled “Responses”Invoice created.
object
Internal invoice ID. Used in /invoices/{id}/ and as id selector.
Bank transactions matched to the invoice.
A bank transaction matched to the invoice.
object
Bank account of the transaction.
Decimal with at most 10 digits and 2 decimal places.
RE receivable, PA payable. Optional on create: if omitted, a positive
amount sets RE, any other amount PA.
Invoice number.
Invoice date.
Expected payment date.
Origin of the invoice, e.g. direct_api or Manually Added.
ID of the invoice in its source.
| Code | Label |
|---|---|
OD | Overdue |
PL | Expected |
OR | Lead/Order |
PD | Paid |
PP | Partially Paid |
IN | Installments |
HD | On Hold |
PR | Promised |
DP | In Dispute |
CA | Cancelled |
IP | In Progress |
Label of status, e.g. Expected.
Category ID.
Present in list responses.
Examples
Invoice
{ "id": 3102, "transactions": [], "paid_amount": 0, "amount_due": 7450, "date_created": "2022-04-16T09:53:03.919398Z", "date_updated": "2022-04-16T09:53:03.919422Z", "name": "Equipment", "notes": "Special equipment", "amount": 7450, "type": "RE", "reference": "AR-007", "date": "2022-04-16", "due_date": "2022-04-28", "source": "direct_api", "source_id": "00000000-0000-4000-8000-000000000002", "status": "PL", "status_label": "Expected", "is_archived": false, "category": 1002}Invalid request body or parameters. The body lists the errors per field; errors
not tied to a field are listed under non_field_errors. For request bodies
that are arrays, the body is a list with one error object per item. Messages
are localized (see Accept-Language).
Validation errors. Each key is a field of the request body; its value is the
list of messages for that field. Errors not tied to a field are listed under
non_field_errors.
object
Validation errors. Each key is a field of the request body; its value is the
list of messages for that field. Errors not tied to a field are listed under
non_field_errors.
object
Example
{ "settlement_date": [ "This field is required." ]}The access token is invalid or has expired. Request a new token. The message is
localized (see Accept-Language).
object
Error message.
Present only if the company’s edition does not include the function; value billing_plan_permission_denied.
Example
{ "detail": "Invalid token."}Headers
Section titled “Headers”Authentication scheme, Bearer.
Example
BearerNo access token was sent, or the credentials are not allowed to call this
endpoint. If the company’s COMMITLY edition does not include the requested
function, the body additionally contains
"code": "billing_plan_permission_denied".
object
Error message.
Present only if the company’s edition does not include the function; value billing_plan_permission_denied.
Example
{ "detail": "User must be authenticated to access this resource."}
