When to use this endpoint

Use Suppliers_getExportData for the current selectable-field Supplier CSV exporter. Call it first with _ids=1, then call it with JSON ID and field arrays in manageable batches.

Authentication and permissions

The request must authenticate with signed API-key fields or a logged-in CRM session. The handler calls the normal login guard but performs no additional Suppliers-page, stock, purchasing, role, create, edit, or delete permission check.

All records are selected from the authenticated tenant. CRM1 and CRM2 hide some controls through client-side permissions, but these endpoints do not repeat those UI checks.

Parameters

ParameterTypeRequiredDescription
_idsExact <code>1</code> or JSON arrayYesExact number/string 1 selects IDs. A JSON array of IDs requests the data phase. IDs are integer-converted.
searchStringNo (ID phase)Substring across name, account number, phone, email, tax ID, and website, plus exact integer ID.
supplierIDInteger stringNo (ID phase)Exact nonzero supplier ID.
name, accountNumber, phone, email, website, taxIDStringNo (ID phase)Case-insensitive substring filters, AND-combined.
fieldsJSON arrayYes (data phase)Requested export fields. Stored fields include id, name, account_number, contact_name, phone, email, website, tax_id, address fields, notes, on_hold, is_active, terms, type, cdate, and last_edited. Accounting aliases are accounts_email/email_accounting, accounts_contact/contact_accounting, and email_extra.

Example request

$ids = FM_api('Suppliers_getExportData', ['_ids' => 1, 'search' => 'northshore']);

$rows = FM_api('Suppliers_getExportData', [
	'_ids' => json_encode([488104]),
	'fields' => json_encode(['id', 'name', 'accounts_email']),
]);

Example response

[
  {"supplier_id":"488104","f0":"488104","f1":"Northshore Components","f2":"accounts@example.test"}
]

The ID phase returns {"ids":[488104,...]}. Data-phase keys are positional f0, f1, and so on in requested-field order, plus supplier_id.

Errors and unusual responses

ResponseCondition
{"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"}_ids is absent.
{"error":"_ids should be a JSON array of numbers"}Data-phase _ids is not a nonempty decoded array.
{"error":"fields should be an array of requested field names"}fields is not a nonempty decoded array.
{"error":"unknown field name: ..."}A non-colon field is not in the export allowlist.
{"ids":[]}No ID-phase row matches.

Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.

Behaviour and edge cases

  • The ID phase orders ascending by ID and has no pagination. The data phase establishes no row order.
  • Inactive and on-hold suppliers remain unless excluded by the supplied filters.
  • Duplicate requested fields produce duplicate positional output keys at their respective indexes. Duplicate IDs collapse in SQL.
  • Accounting aliases decode keys from meta; absent or malformed metadata produces blank values.
  • Colon-containing field tokens are treated as custom-table candidates and skipped from the selected output. The handler collects their tokens but never appends corresponding values, so they must not be relied upon.

See it in Fieldmotion

CRM1

Open Stock → Suppliers in CRM1 and filter browser developer tools for the exact function name. The export widget calls ID selection with current table filters and then requests chosen fields in batches.

CRM2

Open Stock → Suppliers in CRM2 and filter browser developer tools for the exact function name. CRM2 normally gathers filtered IDs from Suppliers_getDataTable, then calls this route’s data phase.

Related endpoints