post_vouchers_batches_by_id_assign
Calls POST /api/vouchers/batches/{id}/assign as the signed-in person · REST reference
Assign an existing batch to an organization
How a distributor is handed stock PFF minted for it — the holder is always a distributor or the platform org, never a clinic. Also re-points the batch's PRE-ISSUE vouchers, so their holder (assignedToOrgId) follows the batch. A batch whose vouchers are already out in the world is NOT wholesale reassigned: the DAL moves only the pre-issue ones and reports how many it had to leave bound, so a non-zero vouchersLeftBound means the batch is no longer homogeneous. That is a success, not an error — check the field rather than the status code. Gated by the platform-staff middleware, not by a dedicated assign permission.
Arguments
| Argument | Type | Description | |
|---|---|---|---|
idpath | string (uuid) | required | Inventory batch id. |
bodyJSON | object | required | The request body, as a JSON object. Its fields are listed below. |
Fields of body
| Field | Type | Description | |
|---|---|---|---|
orgId | string (uuid) | required | Organization to assign the batch to. Missing or blank answers 400, and so does anything but a DISTRIBUTOR or the platform organization — a service provider never holds a batch. A missing or deleted organization answers 404. |
Example call
A client sends this over the MCP session; Claude and other agents build it for you. The values are placeholders — the shape is real.
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "post_vouchers_batches_by_id_assign",
"arguments": {
"id": "11111111-1111-4111-8111-111111111111",
"body": {
"orgId": "11111111-1111-4111-8111-111111111111"
}
}
}
}Result
On success (HTTP 200) the tool returns one text item holding the API's JSON, pretty-printed.
The batch was assigned; the counts say how completely.
{
"batchId": "11111111-1111-4111-8111-111111111111",
"vouchersLeftBound": 1,
"vouchersReassigned": 1,
"assignedTo": "11111111-1111-4111-8111-111111111111"
}Fields
| Field | Type | Description |
|---|---|---|
assignedTo | string (uuid) | null | The org the batch now belongs to, read back from the DAL. |
batchId | string (uuid) | |
vouchersLeftBound | integer | Vouchers already past pre-issue and therefore left pointing at their previous org. Non-zero means the batch is now split across two orgs. |
vouchersReassigned | integer | Pre-issue vouchers moved to the new org. |
When it fails
A failed call returns isError: true with the API's message as text. A change the person declines, or lets time out, also comes back this way and nothing changes.
400The request was malformed or failed a guard.
403Authenticated, but the caller holds none of the required permissions.
404No such resource — or none this caller may see.
What the model is shown
This is the tool exactly as the server lists it in tools/list. The description starts with the REST call it makes.
{
"name": "post_vouchers_batches_by_id_assign",
"description": "POST /api/vouchers/batches/{id}/assign — How a distributor is handed stock PFF minted for it — the holder is always a distributor or the platform org, never a clinic. Also re-points the batch's PRE-ISSUE vouchers, so their holder (`assignedToOrgId`) follows the batch. A batch whose vouchers are already out in the world is NOT wholesale reassigned: the DAL moves only the pre-issue ones and reports how many it had to leave bound, so a non-zero `vouchersLeftBound` means the batch is no longer homogeneous. That is a success, not an error — check the field rather than the status code. Gated by the platform-staff middleware, not by a dedicated assign permission.\n\nThis changes data. The person is asked to confirm it before it runs, and nothing happens if they decline.",
"inputSchema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "Inventory batch id."
},
"body": {
"type": "string",
"description": "The JSON request body: { orgId*: string (Organization to assign the batch to.) }"
}
},
"required": [
"id",
"body"
]
},
"annotations": {
"readOnlyHint": false,
"destructiveHint": true,
"idempotentHint": false,
"openWorldHint": false
}
}