{"slug":"agent-halowerk-com-v1-state-machine-step-12e365","title":"Takes a machine definition, the current state, one event and an optional context","host":"agent.halowerk.com","method":"POST","resource":"https://agent.halowerk.com/v1/state-machine-step","category":"code","description":"Takes a machine definition, the current state, one event and an optional context, and computes a single step. Transitions may carry a guard, which is a declared comparison — field, operator, value — and never an expression: the field is a dotted path into context or payload, so a machine handed in b","price_listed":0.002,"price_asked":null,"state":"effects","state_label":"Not tested: has real-world effects","checks_7d":0,"answered_7d":0,"latency_ms_median":null,"reported_calls_30d":1,"reported_payers_30d":1,"networks":["eip155:8453"],"badge":"unverified","paid_checks_7d":0,"paid_ok_7d":0,"example_input":{"body":{"context":{"attempts":1},"current_state":"awaiting_quote","elapsed_in_state_s":120,"event":{"name":"quote_received","payload":{"amount_eur":420}},"machine":{"initial":"awaiting_quote","states":[{"name":"awaiting_quote","on":[{"actions":["book_slot"],"event":"quote_received","guard":{"field":"payload.amount_eur","op":"lte","value":500},"target":"quote_accepted"},{"actions":["request_approval"],"event":"quote_received","target":"needs_approval"},{"event":"cancel","target":"cancelled"}],"timeout_actions":["notify_requester"],"timeout_s":3600,"timeout_target":"expired"},{"name":"quote_accepted","on":[{"event":"cancel","target":"cancelled"}]},{"name":"needs_approval","on":[{"event":"approved","target":"quote_accepted"}]},{"final":true,"name":"cancelled"},{"final":true,"name":"expired"}]},"timeout_precedence":"timeout"},"bodyType":"json","method":"POST","type":"http"},"output_schema":{"$schema":"https://json-schema.org/draft/2020-12/schema","properties":{"input":{"additionalProperties":false,"properties":{"body":{"additionalProperties":false,"properties":{"context":{"description":"Machine context, addressable in guards as context.<field>. Never modified.","type":"object"},"current_state":{"description":"The state the machine is in right now.","maxLength":64,"minLength":1,"type":"string"},"elapsed_in_state_s":{"default":0,"description":"Seconds already spent in current_state. Supplied by you, so the result does not depend on this server clock.","maximum":31536000,"minimum":0,"type":"number"},"event":{"additionalProperties":false,"description":"The event to apply.","properties":{"name":{"description":"Event name.","maxLength":64,"minLength":1,"type":"string"},"payload":{"description":"Event data, addressable in guards as payload.<field>.","type":"object"}},"required":["name"],"type":"object"},"machine":{"additionalProperties":false,"description":"The automaton definition.","properties":{"initial":{"description":"Name of the initial state. Must be one of the defined states.","maxLength":64,"minLength":1,"type":"string"},"states":{"description":"The states of the machine.","items":{"additionalProperties":false,"properties":{"final":{"default":false,"description":"If true no event is accepted in this state.","type":"boolean"},"name":{"description":"State name, unique within the machine.","maxLength":64,"minLength":1,"type":"string"},"on":{"description":"Event-driven transitions out of this state, evaluated in order.","items":{"additionalProperties":false,"properties":{"actions":{"description":"Actions triggered by this transition.","items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":20,"type":"array"},"event":{"description":"Event name this transition reacts to.","maxLength":64,"minLength":1,"type":"string"},"guard":{"additionalProperties":false,"description":"Condition that must hold for this transition to be taken.","properties":{"field":{"description":"Dotted path starting with context. or payload., e.g. context.attempts.","maxLength":200,"minLength":1,"type":"string"},"op":{"description":"Comparison operator.","enum":["eq","ne","gt","gte","lt","lte","in","not_in","exists","not_exists"],"type":"string"},"value":{"description":"Right-hand operand. Not used by exists and not_exists; an array for in and not_in."}},"required":["field","op"],"type":"object"},"target":{"description":"State to move to.","maxLength":64,"minLength":1,"type":"string"}},"required":["event","target"],"type":"object"},"maxItems":50,"type":"array"},"timeout_actions":{"description":"Actions triggered by the deadline transition.","items":{"maxLength":64,"minLength":1,"type":"string"},"maxItems":20,"type":"array"},"timeout_s":{"description":"Deadline for this state in seconds.","maximum":31536000,"minimum":0,"type":"number"},"timeout_target":{"description":"State to move to when the deadline is exceeded. Without it a breach is only reported.","maxLength":64,"minLength":1,"type":"string"}},"required":["name"],"type":"object"},"maxItems":200,"minItems":1,"type":"array"}},"required":["initial","states"],"type":"object"},"timeout_precedence":{"default":"timeout","description":"Which side wins when the deadline is breached and an event transition also matches.","enum":["timeout","event"],"type":"string"}},"required":["machine","current_state","event"],"type":"object"},"bodyType":{"enum":["json","form-data","text"],"type":"string"},"method":{"enum":["POST","PUT","PATCH"],"type":"string"},"type":{"const":"http","type":"string"}},"required":["type","method","bodyType","body"],"type":"object"}},"required":["input"],"type":"object"},"history":[],"description_full":"Takes a machine definition, the current state, one event and an optional context, and computes a single step. Transitions may carry a guard, which is a declared comparison — field, operator, value — and never an expression: the field is a dotted path into context or payload, so a machine handed in by a stranger cannot execute anything on this server.","last_updated":"2026-11-02T14:55:10.359Z","schemes":["exact"]}