Stock allocations and movement records
Read raw allocations for stock IDs
/a/Stocks_getContainers
Fetch all saved allocation rows for a batch of catalogue items.
When to use this endpoint
Use when a bill of materials or allocation summary already knows the stock IDs. This is a raw lookup; apply the appropriate owner/type/positive-quantity selection in your caller.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
ids | Native or JSON ID list | Yes | Native or JSON-encoded list of positive IDs. JSON objects, scalars, nested elements and nonpositive IDs are rejected. Any explicit empty list returns []; no selection broadens to all rows. |
Example request
$rows = FM_api('Stocks_getContainers', ['ids'=>json_encode(['1042','1043'])]);
Example response
[{"id":"2081","stock_id":"1042","container_id":"1088","container_type":"1","amt":"3","amt_trigger":"","last_edited":"2026-11-23 10:00:00","inventory_id":"0","meta":null}]
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
| 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"} | ids absent/null or an invalid ID element. |
{"error":"ids should be an array"} | Not a native/JSON list, including encoded objects/scalars. |
Legacy application errors may be returned with HTTP 200. Check the decoded response for error, not only the HTTP status.
Behaviour and edge cases
- Bare raw row array. Ordered by allocation row id; no paging, active-stock join, positive-quantity restriction or outbound-type exclusion. stock_id is the catalogue item; id is the allocation row; meta remains encoded JSON.
- Source types include 0 Warehouse, 1 User, 2 Vehicle, 3 Location, 6 Customer, 7 Job, 10 Stock Storage, 11 Asset, 12 Quote, 14 dispatched User, 15 Requisition, 16 Purchase Order, 18 dispatched Job and 20 dispatched Vehicle. A container row ID identifies one saved allocation; container.id identifies its owner and requires the paired type. Neither is a catalogue stock ID or a batch/inventory ID.
- Decoded list shape and every element are validated before the query. Native lists and JSON lists have the same behavior, including [] for empty lists.
Side effects
- Database reads only; no reservation, movement, alert or history entry is created.
See it in Fieldmotion
CRM1
Open the CRM1 Stock page and use the selected-stock workflow which loads container allocations; filter Network for Stocks_getContainers. The caller sends JSON.stringify(selected IDs).
CRM2
Open a Job bill of materials in CRM2. widgetJobsBillOfMaterials fetches allocations with JSON.stringify(stockIDs), selects positive type-10 Stock Storage rows and resolves those storage names before falling back to saved location tags.
Related endpoints
StockContainer_getRequestedDetails— request named mapped fields and explicit owner filters.