post_vouchers_batches
Calls POST /api/vouchers/batches as the signed-in person · REST reference
Mint a batch of vouchers (voucher-pool and allocation gated)
Creates an inventory batch and mints its vouchers in a single DAL transaction. The DAL enforces the voucher-pool balance and the per-organization allocation inside that same transaction, so an unaffordable batch is refused as a 400 rather than partially created. type is coerced by exact match: only the literal string PHYSICAL selects a physical batch and every other value yields DIGITAL. unitValue is honoured only when sent as a JSON number; anything else falls back to the service's unit-value policy. PRINTING IS DECIDED HERE, ONCE: a PHYSICAL batch is sent to the office printer AFTER it is committed when, and only when, print is true, using the codes the mint just returned. The batch stays committed whatever the printer does, and the response's print carries the TRUE outcome — a failure is reported there, never swallowed — while every voucher the print covered is recorded SUBMITTED or PRINT_FAILED. A SUBMITTED print ISSUES the vouchers it carried in that same write (paper exists, so they are live); a failed or skipped one leaves them unissued, and is sent again with POST /api/vouchers/batches/{id}/print. Requires execute:CreateVoucherBatchCommand — MINTING, which no organization is ever entitled to; platform staff are admitted as on every gate.
Arguments
| Argument | Type | Description | |
|---|---|---|---|
bodyJSON | object | required | The request body, as a JSON object. Its fields are listed below. |
Fields of body
| Field | Type | Description | |
|---|---|---|---|
assignToOrgId | string (uuid) | Organization the batch and its vouchers are assigned to. Only a DISTRIBUTOR or the platform organization may hold a batch — naming a service provider answers 400, a missing or deleted organization 404. GET /api/vouchers/batches/capacity lists the eligible organizations and the most vouchers each can be minted. | |
expiresAt | integer | string | Expiry as epoch MILLISECONDS or a Date.parse-able string. Omitted or unparseable falls back to 180 days from now; a time already past answers 400. | |
print | boolean | Print a PHYSICAL batch on the office printer as soon as it is minted. Ignored for a DIGITAL batch. Anything but the JSON true does not print. | |
procedure | string | ||
quantity | integer | required | Vouchers to mint. Outside 1..10000 the service refuses with 400. |
serviceType | string | null | ||
sex | string | ||
species | string | Procedure-catalog binding. When procedure is also set the DAL uses the catalog max_payout as the voucher face value instead of unitValue. | |
type | "DIGITAL" | "PHYSICAL" | Anything but the literal PHYSICAL is treated as DIGITAL. | |
unitValue | integer | Face value per voucher in CENTS. Applied only when it arrives as a JSON number; otherwise the service's policy default is used. |
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",
"arguments": {
"body": {
"quantity": 1,
"assignToOrgId": "11111111-1111-4111-8111-111111111111",
"expiresAt": 1,
"print": false,
"procedure": "string",
"serviceType": "string",
"sex": "string",
"species": "string",
"type": "DIGITAL",
"unitValue": 1
}
}
}
}Result
On success (HTTP 201) the tool returns one text item holding the API's JSON, pretty-printed.
Batch created and its vouchers minted — print says what the printer did, including when it failed. A 201 means the BATCH exists, not that paper came out.
{
"batchId": "11111111-1111-4111-8111-111111111111",
"batchNumber": "string",
"print": {
"status": "SUBMITTED",
"code": "PRINTER_UNREACHABLE",
"error": "string",
"jobId": 1,
"vouchers": 1
},
"quantity": 1,
"totalValue": 1,
"vouchers": [
{
"code": "string",
"currency": "string",
"expiresAt": 1,
"id": "11111111-1111-4111-8111-111111111111",
"state": "string",
"value": 1
}
],
"batchType": "string"
}Fields
| Field | Type | Description |
|---|---|---|
batchId | string (uuid) | |
batchNumber | string | |
batchType | string | null | DIGITAL or PHYSICAL, as the DAL recorded it. |
print | object | |
print.code | "PRINTER_UNREACHABLE" | "PRINTER_AUTH_REJECTED" | "PRINTER_TLS_UNVERIFIED" | "PRINTER_REJECTED_JOB" | "PRINTER_NOT_CONFIGURED" | "PRINT_FAILED" | … (7 values) | Machine-readable reason for error. |
print.error | string | Curated and safe to show. On FAILED and NOT_CONFIGURED; on SUBMITTED only when the job was accepted but could not be recorded — its vouchers were then neither marked as sent nor issued. |
print.jobId | integer | The printer's job id, on SUBMITTED. |
print.status | "SUBMITTED" | "FAILED" | "NOT_REQUESTED" | "NOT_CONFIGURED" | SUBMITTED: the printer ACCEPTED the job (accepted, not paper confirmed), and the vouchers it carried are ISSUED — unless code is PRINT_STATUS_NOT_RECORDED. FAILED: nothing was printed or issued. NOT_REQUESTED: no print was asked for, or the batch is DIGITAL. NOT_CONFIGURED: a print was asked for and this server has no printer. |
print.vouchers | integer | How many vouchers the print covered. Absent when none was attempted. |
quantity | integer | |
totalValue | integer | Total face value of the batch in CENTS. |
vouchers | array of object | The FIRST FIVE minted vouchers only — a preview, never the whole batch. The whole batch is read by id through GET /api/vouchers/batches/{id}/print-sheet. |
vouchers[].code | string | |
vouchers[].currency | string | |
vouchers[].expiresAt | integer | Epoch MILLISECONDS. |
vouchers[].id | string (uuid) | |
vouchers[].state | string | |
vouchers[].value | integer | Face value in CENTS. |
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.
409The resource is not in a state that allows this operation.
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",
"description": "POST /api/vouchers/batches — Creates an inventory batch and mints its vouchers in a single DAL transaction. The DAL enforces the voucher-pool balance and the per-organization allocation inside that same transaction, so an unaffordable batch is refused as a 400 rather than partially created. `type` is coerced by exact match: only the literal string `PHYSICAL` selects a physical batch and every other value yields `DIGITAL`. `unitValue` is honoured only when sent as a JSON number; anything else falls back to the service's unit-value policy. PRINTING IS DECIDED HERE, ONCE: a PHYSICAL batch is sent to the office printer AFTER it is committed when, and only when, `print` is `true`, using the codes the mint just returned. The batch stays committed whatever the printer does, and the response's `print` carries the TRUE outcome — a failure is reported there, never swallowed — while every voucher the print covered is recorded SUBMITTED or PRINT_FAILED. A SUBMITTED print ISSUES the vouchers it carried in that same write (paper exists, so they are live); a failed or skipped one leaves them unissued, and is sent again with `POST /api/vouchers/batches/{id}/print`. Requires `execute:CreateVoucherBatchCommand` — MINTING, which no organization is ever entitled to; platform staff are admitted as on every gate.\n\nThis changes data. The person is asked to confirm it before it runs, and nothing happens if they decline.",
"inputSchema": {
"type": "object",
"properties": {
"body": {
"type": "string",
"description": "The JSON request body: { assignToOrgId: string (Organization the batch and its vouchers are assigned to.); expiresAt: integer or string (Expiry as epoch MILLISECONDS or a Date.parse-able string.); print: boolean (Print a PHYSICAL batch on the office printer as soon as it is minted.); procedure: string; quantity*: integer (Vouchers to mint.); serviceType: string; sex: string; species: string (Procedure-catalog binding.); type: one of \"DIGITAL\" | \"PHYSICAL\" (Anything but the literal `PHYSICAL` is treated as `DIGITAL`.); unitValue: integer (Face value per voucher in CENTS.) }"
}
},
"required": [
"body"
]
},
"annotations": {
"readOnlyHint": false,
"destructiveHint": true,
"idempotentHint": false,
"openWorldHint": false
}
}