Documents.Sum
Return the sum of document amounts for the account. Filters: customer_id, type/types, invoice_setting_id, from_date/to_date. Default (type omitted or net) uses invoice + receipt_tax_invoice - credit_invoice. When types is an array, invoice and receipt_tax_invoice are added and credit_invoice is subtracted when present with other types. Drafts (save_as_draft=1) are excluded unless include_drafts=1.
Permissions
- User must be logged in with a valid bearer token.
- The user must be from the same company domain as the request Host (call the API on that account subdomain or allowed custom domain). A token from another company returns success=0, error user_not_in_company.
- Returned or changed records are limited by the user permissions, team access, folder access, and account settings.
Action
- Runs the Documents.Sum function and returns JSON.
Push Service
No push is sent because this function only reads data or returns helper information.
Automation
No automation is run for this function.
Special Instructions
- Send the bearer token on protected calls with Authorization: Bearer YOUR TOKEN.
- On a company subdomain (e.g. https://{user_domain}.bull36.com) the user must match that Host — Login and protected APIs reject another company with success=0, error user_not_in_company. On a main brand host (bull36.com, biz1.co.il, mastrocrm.com, …) the company domain gate is skipped.
- Send parameters as POST body fields exactly as documented.
Required Parameters
No body parameters are required for this function.
Optional Parameters
| Name | Type | Sample | What it gives |
|---|---|---|---|
customer_idpost | int | 108545 | Optional customer filter. Aliases: cust_id, client_id. |
typespost | array | ["invoice","credit_invoice"] | Optional document types array. invoice and receipt_tax_invoice are added; credit_invoice is subtracted when mixed with other types. Alias: type / document_type (string, comma list, or array). Omit or send net for the default net formula. |
typepost | string | net | Optional type filter. Use net (default), a single type such as invoice, or an array/comma list. Prefer types when sending multiple values. |
invoice_setting_idpost | int | 19 | Optional company / invoice settings filter. Ids from InvoiceSettings.List. |
from_datepost | date | 2026-01-01 | Optional start date on documents.date_created (inclusive). Send date filters and date values as UTC Y-m-d H:i:s when the route accepts date/time; date-only table columns store the Y-m-d date part. |
to_datepost | date | 2026-12-31 | Optional end date on documents.date_created (inclusive). Send date filters and date values as UTC Y-m-d H:i:s when the route accepts date/time; date-only table columns store the Y-m-d date part. |
include_draftspost | int | 1 | When 1, include draft documents (save_as_draft=1). Default excludes drafts. |
Authentication
Send the bearer token returned by Login in the request header. The user must be from the same company domain as this Host — a token from another company is rejected (user_not_in_company).
Authorization: Bearer YOUR TOKEN
Sample Request
{
"url": "\/app\/Documents.Sum",
"method": "POST",
"headers": {
"Authorization": "Bearer YOUR TOKEN"
},
"body": {
"customer_id": "108545",
"types": [
"invoice",
"credit_invoice"
],
"invoice_setting_id": "19",
"include_drafts": 1
},
"url_user": "https:\/\/{user}.bull36.com\/app\/Documents.Sum",
"url_domain": "https:\/\/{domain}\/app\/Documents.Sum"
}Endpoint
POST /app/Documents.Sum
POST https://{user}.bull36.com/app/Documents.Sum
POST https://{domain}/app/Documents.SumSample Output
{
"success": 1,
"count": 42,
"counts": {
"invoice": 38,
"credit_invoice": 4
},
"by_type": {
"invoice": {
"count": 38,
"sum_total": 10000,
"sum_final_amount": 11700
},
"credit_invoice": {
"count": 4,
"sum_total": 500,
"sum_final_amount": 585
}
},
"sum": 9500,
"sum_total": 9500,
"sum_final_amount": 11115,
"formula": "selected_add_types - credit_invoice",
"types": [
"invoice",
"credit_invoice"
]
}JavaScript Example
const token = 'YOUR TOKEN';
const res = await fetch('/app/Documents.Sum', {
method: 'POST',
headers: { Authorization: 'Bearer ' + token, 'Content-Type': 'application/json' },
body: JSON.stringify({
customer_id: '108545',
types: ['invoice', 'credit_invoice'],
invoice_setting_id: '19',
include_drafts: 1
})
});
const data = await res.json();
console.log(data);Error Example
{
"success": "0",
"error": "bearer_token_required",
"message": "Authorization bearer token is required. Send header: Authorization: Bearer YOUR TOKEN"
}