When to use this endpoint

Use to populate the Dispatch dialog, then perform the actual dispatch through Stock_dispatch. Loading this list does not consume stock.

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
containerTypeInteger-compatibleYesExactly 1 User, 2 Vehicle or 7 Job after integer conversion. Dispatched types 14/18/20 are not accepted.
containerIDInteger-compatibleNoOptional owner ID to narrow the picker; if present, blank/zero also becomes a literal filter. Not an allocation row ID.

Example request

$owners = FM_api('StockContainer_getDispatch', ['containerType'=>'1']);

Example response

{"1088":{"id":1088,"name":"Engineer","stock":[{"id":"1042","name":"Valve","qty":3,"inventoryID":0}]}}

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":"missing or invalid parameter: containerType"}Missing or unsupported type.
{"error":"Saved batch quantities exceed the allocation balance; reconcile this allocation first."}Saved batch evidence overstates the allocation.
{"error":"no inventory available"}Positive batch reference is deleted/missing or belongs to another stock.

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

Behaviour and edge cases

  • Empty result is []; otherwise returns an owner-ID-keyed object with numeric owner id,name,stock array. Stock entries contain catalogue id,name,float qty,numeric inventoryID. User/Vehicle/Job types remain1/2/7.
  • Requires active Users and undeleted catalogue stock; Job sources require an undeleted assigned Job whose stock_used contains a type7 source. Vehicle numeric/UUID allocation keys resolve to the same numeric vehicle ID. Positive allocation balances only; no paging or sort is added.
  • Positive batch references must be active and belong to the stock. Saved batch quantities must be finite,nonnegative and no greater in total than the allocation balance. Invalid/stale/overstated evidence or duplicate allocations returns an error requiring reconciliation; it is not silently offered as dispatchable.
  • Valid metadata batch entries produce fixed disable:1 selections. Any balance not assigned in metadata becomes an inventoryID=0 unbatched entry. A legacy positive inventory_id without structured entries represents the row’s batch quantity.

Side effects

  • Database reads only; no reservation, movement, alert or history entry is created.

See it in Fieldmotion

CRM1

No direct CRM1 caller was found in the source search. CRM1 uses its legacy Stock grid and stockContainerEdit allocation editor instead.

CRM2

In CRM2 open Dispatch from User/Vehicle/Job stock. widgetDispatch first sends containerType, then optionally containerID for a preselected owner; filter Network for StockContainer_getDispatch.

Related endpoints