Inventory Management
Find what you hold at a facility, and record which of your end users each unit belongs to.
Queries
listFacilityItems
Pages the units you hold. Every filter is optional; omitting one does not apply it.
query {
listFacilityItems(input: {
state: VAULTED
externalUserId: "user-8821"
pagination: { limit: 20, offset: 0 }
}) {
facilityItems {
id
lineItemId
facilityId
state
externalUserId
expiresAt
}
pagination { totalCount limit offset hasNextPage }
error { message code }
}
}
| Field | Notes |
|---|---|
facilityId | Narrow to one facility |
state | One of the placement states |
externalUserId | Your own reference for the end user holding the unit |
pagination | limit defaults to 20 |
lineItemId is the handle every mutation takes — carry it forward from here.
getFacilityItem
query {
getFacilityItem(input: { id: "0f2c…" }) {
facilityItem { id lineItemId facilityId state externalUserId }
error { message code }
}
}
Returns NOT_FOUND for a placement that doesn't exist or isn't yours.
Mutations
setFacilityItemExternalUsers
Records which of your end users each unit belongs to. externalUserId is your identifier — Tradepost stores it and gives it back, and never interprets it.
Assignments are pairs, so one call can map many units across many users.
mutation {
setFacilityItemExternalUsers(input: {
assignments: [
{ lineItemId: "a1b2…", externalUserId: "user-8821" },
{ lineItemId: "c3d4…", externalUserId: "user-8821" },
{ lineItemId: "e5f6…", externalUserId: "user-9034" }
]
}) {
facilityItems { lineItemId externalUserId }
unmatchedLineItemIds
error { message code }
}
}
Pass externalUserId: null to clear a mapping.
Once set, listFacilityItems(input: { externalUserId: "user-8821" }) returns everything you hold for that user, and an outtake can be requested for all of it in one call.
Partial success
Line items you don't own, or that have no placement, are returned in unmatchedLineItemIds. The rest still apply — the call does not fail because one id was wrong.
| Code | Cause |
|---|---|
TOO_MANY_ASSIGNMENTS | More than 500 assignments |
DUPLICATE_LINE_ITEM_IDS | The same line item appears twice |
VALIDATION_ERROR | assignments empty |