跳至主要内容

POST /api/contracts/templates/:id/deploy

One-call deploy. Loads the template's definition, stamps created_by to the caller's ZID, validates against the live operator registry, and inserts a row in contracts.

Auth

Bearer with operator role or higher on the target state machine.

Request

{ "slug": "my-iot-fleet" }
FieldTypeRequired
slugstringyes — your state machine's slug

Response — 201

{
"ok": true,
"contract": { ... },
"template_id": "force-threshold-alarm"
}

The contract object is the same shape as POST /api/chain/:slug/contracts.

Errors

StatusBodyCause
400Required: slug …slug missing
400validator messagetemplate's definition fails on the live operator set
403forbiddenrole < operator
404Template not foundbad template id
404Machine not foundslug doesn't resolve