When to use this endpoint

Normally called by Stock_dispatch as one step of the dispatch workflow. External callers must not assume inserting this record performs the movement.

Authentication and permissions

Authenticate with a signed API key or a logged-in CRM session on the account’s routed host. Signed requests act as the key owner. Session requests must include the dispatcher CSRF value when configured. All record identifiers belong to the authenticated tenant.

The dispatcher and these handlers do not impose an additional CRM2 Stock role or Stock TeamAccess record scope. CRM2 screen permissions are separate controls and must not be assumed to apply to CRM1. These routes do not become public because an individual legacy handler checks only the tenant context.

Parameters

ParameterTypeRequiredDescription
stockID / qtyInteger-compatible / float-compatibleNo explicit required map flagsCatalogue ID and recorded quantity. Handler/map do not enforce positive quantity or active stock existence.
linkID / linkType / linkIDs or native {id,type}NoSource owner reference; use stock-source type codes (1 User,2 Vehicle,7 Job in normal dispatch). link expands into its components.
customerID / customerType / customerIDs or native {id,type}NoRecorded destination customer/asset reference, supplied by the caller. No relationship validation.
createdDateUnix epoch or parseable datetimeNoDefaults server now. The layout readonly flag does not prevent supplying a historical value.

Example request

$record = FM_api('StockDispatch_createData', ['stockID'=>'1042','qty'=>'2.5','linkID'=>'2088','linkType'=>'7','customerID'=>'1088','customerType'=>'0']);

Example response

{"ok":1,"id":3081}

Examples show one representative result; database numeric scalars can be JSON strings. Application errors can use HTTP 200: inspect error and warning in the decoded response.

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":"Unable to create record"}The shared insert fails or returns no positive ID.

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

Behaviour and edge cases

  • Mapped fields: id, stockID, linkID, linkType, link, customerID, customerType, customer, qty and createdDate. Numeric fields coerce through the shared writer; omitted fields use schema/default values. Native link/customer objects expand. This route has no dispatch availability, inventory or completed-Job receipt checks.
  • Creates a new ledger ID on every call. No idempotency key or enclosing transaction is added by this wrapper.
  • createdDate is stored as an epoch; mapped reads format it as SQL date/time. This is distinct from the stock item’s own creation date.

Side effects

  • Inserts stock_dispatches, invalidates that table cache and writes generic field audit entries. Does not change warehouse/container/inventory quantities or fire Stock_edit.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found. Legacy allocation editors call Stock_containerAdd rather than creating dispatch ledger rows.

CRM2

CRM2 widgetDispatch calls Stock_dispatch; that server workflow invokes StockDispatch_createData per stock row. Filter for Stock_dispatch in browser Network, since the nested ledger call is server-side.

Related endpoints