Update invoices
const url = 'https://app.commitly.com/api/invoices/';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '[{"reference":"AR-007","amount":3000},{"reference":"AR-008","status":"PD","paid_amount":500}]'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://app.commitly.com/api/invoices/ \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '[ { "reference": "AR-007", "amount": 3000 }, { "reference": "AR-008", "status": "PD", "paid_amount": 500 } ]'Updates one or more invoices. The body must be a JSON array; a single object is rejected with 400.
Matching key. The key used to find the invoices is chosen from the first item of the array, and applies to all items:
id(internal invoice ID), if the first item containsid;- otherwise
source_idtogether withsource, if the first item containssource_id; - otherwise
reference.
Send the same key in every item.
Behaviour.
- Only the fields sent are changed.
nameis not required. - Items that match no invoice are skipped silently. The response contains only the invoices that were updated.
- PATCH never creates an invoice.
categorymust be a leaf category of the company.tagsandexpected_datecan be updated.- An
expected_datein the past is set to the current date, unless the invoice status isPD(paid).
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”One item of a PATCH body. Identify the invoice by id, by source_id
together with source, or by reference; the key is chosen from the first
item of the array (see the operation). All other fields are optional; only the
fields sent are changed.
object
Internal invoice ID (matching key).
ID of the invoice in its source (matching key, together with source).
Source of the invoice (matching key, together with source_id).
Invoice number (matching key, exact match).
RE receivable, PA payable. Optional on create: if omitted, a positive
amount sets RE, any other amount PA.
| 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 |
Decimal with at most 10 digits and 2 decimal places. A JSON number or a
numeric string ("7450.00").
A date in the past is set to the current date, unless the status is PD.
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.
Additional information for mapping rules.
Example
[ { "reference": "AR-007", "amount": 3000 }, { "reference": "AR-008", "status": "PD", "paid_amount": 500 }]Responses
Section titled “Responses”The invoices that were updated.
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
Updated invoices (list)
[ { "id": 3102, "transactions": [], "paid_amount": 0, "amount_due": 3000, "date_created": "2022-04-16T09:53:03.919398Z", "date_updated": "2022-04-16T10:02:11.000000Z", "name": "Equipment", "notes": "Special equipment", "amount": 3000, "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."}
