Invoices
Export invoice line items
/a/Invoices_getLineItemExportData
Select invoices and return requested export columns once per normalized line item.
When to use this endpoint
This is a two-phase export API. Send _ids=1 to obtain the complete filtered ID list, then send JSON-encoded ID and field arrays in one or more data requests. Neither phase paginates internally. Use this variant for line-item exports; invoices with no line items still produce one row.
Authentication and permissions
The request must authenticate with signed API-key fields or a logged-in CRM session and is scoped to the authenticated tenant.
The handler performs no additional invoice page, record-owner, or department permission check unless stated below.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
_ids | String | Yes | Literal 1 selects IDs; otherwise a JSON array for the data phase. |
fields | JSON array | Data phase | Any supported invoice or calculated line-item export key. The job link uses the legacy appointment_id wire key. |
from / to / inv_no / customer / status / search | Mixed | No | Selection-phase inclusive date, invoice number, customer/asset, exact status, and broad-search filters. |
Example request
$rows = FM_api('Invoices_getLineItemExportData', [
'_ids' => json_encode(['981']),
'fields' => json_encode(['num', 'rows', 'total_net_price']),
]);
Example response
[
{"invoice_id": "981", "f0": "INV-981", "f1": "{...one line item...}", "f2": 100}
]
Errors and unusual responses
| Response | Condition |
|---|---|
{"error":"not logged in"} | No authenticated tenant context is available. Invalid signed credentials can be rejected by the dispatcher before the handler runs. |
{"error":"missing or invalid parameter: _ids"} | The phase selector is absent. |
{"error":"_ids should be a JSON array of numbers"} | Data-phase IDs are empty or invalid. |
{"error":"fields should be an array of requested field names"} | Fields is not a nonempty JSON array. |
{"error":"unknown field name: …"} | A field key is unsupported. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Selection is unpaginated, excludes deleted and legacy orphan drafts, and orders IDs numerically by invoice number.
- Customer filter expansion uses the same site and owned/located-asset tenant settings as invoice export.
- Each invoice row is expanded using normalized line items.
rowscontains one JSON line-item object. total_discount_valueandtotal_net_priceare totals for the current invoice. The invoice-level values repeat on each exported line belonging to that invoice.- Asset invoice customer IDs are converted to owner IDs when requested; parent and direct-job values are looked up separately.
See it in Fieldmotion
CRM1
The line-item export tab uses this function.
CRM2
The invoice module uses this endpoint as its line-item export provider.
Related endpoints
Invoices_getExportDatareturns one row per invoice.