Test an automation on a past event
const url = 'https://api.pixonaut.app/v1/automations/test-run';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"draft":{"body":{"steps":[{"id":"print","settings":{},"type":"create_print"}]},"runsAs":"author","sources":{"includeNewKeys":true,"includeNewLinks":true,"includeNewStores":true,"keys":null,"links":null,"stores":null},"spendLimit":50,"trigger":"design.committed"},"eventId":"evt_5a1c9e7b2d4f"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.pixonaut.app/v1/automations/test-run \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "draft": { "body": { "steps": [ { "id": "print", "settings": {}, "type": "create_print" } ] }, "runsAs": "author", "sources": { "includeNewKeys": true, "includeNewLinks": true, "includeNewStores": true, "keys": null, "links": null, "stores": null }, "spendLimit": 50, "trigger": "design.committed" }, "eventId": "evt_5a1c9e7b2d4f" }'Operation ID: automations.testRun
What it would have done: each condition with the values compared, each step blocked and why or run, its placeholders rendered and the limits a spend would count against. A wait does not wait. Nothing is moved, sent or stored, and a test run is never a firing.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
A saved automation, by its id. Name it or draft.
A draft, as the editor holds it. Name it or automationId.
object
The automation’s tree of steps.
object
object
Every one holds.
object
At least one holds.
object
It does not hold.
object
The fact compared.
It holds when the fact is one of these: each at most 200 characters, or 2054 for an origin, which may name a store’s site.
object
It holds from this many copies up.
It holds up to this many copies.
The order’s quantity.
object
The order’s delivery address.
Whether it must be set, or must not.
The steps, in the order they run. A step’s type names an action from the catalogue.
object
Further steps, under each branch’s name.
object
Its id, unique in the body: what a firing names it by.
What its type takes; the draft check refuses settings the type does not.
object
Its action (approve, create_print, place_order, reroute, cancel_order, notify, email, webhook) or flow step (only_if, paths, wait_for, delay).
author: it acts with the grants of the member who last saved it. workspace: it acts as the workspace, tied to no member; only an admin may set it, and an automation made with a secret key always runs so.
The sources it acts on: the studio always; designer links, keys and connected stores, each every one or a snapshot. To act on only some, an Only if compares the design’s origin.
object
On, it acts on designs from every secret and publishable key no store was given, those added later too. Off, only from those in keys.
On, it acts on designs from every designer link, those made later too. Off, only from the links in links.
On, it acts on designs from every connected store, those connected later too. Off, only from those in stores. A store may have its own automated flows on its designs; if it does, the first to move one on wins.
While its switch is off, those that existed when it was switched off; null while it is on. A save that turns it off with none takes it then.
object
Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.
When its switch was turned off: the snapshot is as of then.
While its switch is off, those that existed when it was switched off; null while it is on. A save that turns it off with none takes it then.
object
Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.
When its switch was turned off: the snapshot is as of then.
While its switch is off, those that existed when it was switched off; null while it is on. A save that turns it off with none takes it then.
object
Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.
When its switch was turned off: the snapshot is as of then.
Spend actions it may take per rolling 24 hours.
The event it fires on; null for none yet, which fires on nothing. One with none cannot be enabled.
The past event to test on, as the events found name it.
Examples
Example
{ "draft": { "body": { "steps": [ { "id": "print", "settings": {}, "type": "create_print" } ] }, "runsAs": "author", "sources": { "includeNewKeys": true, "includeNewLinks": true, "includeNewStores": true, "keys": null, "links": null, "stores": null }, "spendLimit": 50, "trigger": "design.committed" }, "eventId": "evt_5a1c9e7b2d4f"}Responses
Section titled “Responses”What it would have done
object
Its conditions, each with the values compared; null for none.
object
object
Where it sits in the tree, as all.0.not; empty for a tree of one.
object
object
Whether the automation would fire on it.
Why it would not fire.
Every step, in order, branches after their step: what it would do.
object
The printshop it would act at, and what it could do.
object
object
Why it cannot act there.
object
When it can: checked when it runs, and a step that meets it unmet is blocked.
Why it is blocked, would pause or would stop; what a wait or a delay would wait for; the path a choice of paths would take.
Its placeholders as they render for this event. Empty for an MCP key: a text written to an order’s own printshop may name its customer.
object
The limits a spend action counts against, as they would stand when it ran.
object
object
object
What it was about, by id.
object
Examples
Example
{ "conditions": { "holds": true, "leaves": [ { "field": "origin", "has": [ "studio" ], "holds": true, "path": "", "wants": { "in": [ "studio" ] } } ] }, "event": { "at": 1760000300000, "id": "evt_5a1c9e7b2d4f", "type": "design.committed" }, "fires": true, "reason": null, "steps": [ { "branch": [], "label": null, "outcome": "would_run", "printshops": [], "reason": null, "rendered": {}, "spend": { "automation": { "limit": 50, "used": 3 }, "workspace": { "ceiling": 500, "used": 12 } }, "stepId": "print", "type": "create_print" }, { "branch": [], "label": "Order one copy", "outcome": "blocked", "printshops": [ { "can": "yes", "id": "psc_4e8a9f6c1d2e", "name": "Printful" } ], "reason": "The printshop “Riso Corner” is paused and takes no new orders.", "rendered": {}, "spend": { "automation": { "limit": 50, "used": 4 }, "workspace": { "ceiling": 500, "used": 13 } }, "stepId": "order", "type": "place_order" }, { "branch": [ "onFailure" ], "label": null, "outcome": "not_reached", "printshops": [], "reason": null, "rendered": {}, "spend": null, "stepId": "tell", "type": "notify" } ], "subject": { "designId": "des_2b4d8a9f6c1e", "revision": 2 }}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: invalid_body
object
Always sent with invalid_body.
Examples
invalid_body
{ "error": "invalid_body", "fields": [ "string" ]}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: unauthorized
object
Examples
unauthorized
{ "error": "unauthorized"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: feature_disabled, origin_forbidden, forbidden
object
The feature the tenant does not have. Always sent with feature_disabled.
Examples
feature_disabled
{ "error": "feature_disabled", "feature": "api"}forbidden
{ "error": "forbidden"}origin_forbidden
{ "error": "origin_forbidden"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: automation_not_found, event_not_found
object
Examples
automation_not_found
{ "error": "automation_not_found"}event_not_found
{ "error": "event_not_found"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: payload_too_large
object
Always sent with payload_too_large.
Examples
payload_too_large
{ "error": "payload_too_large", "maxBytes": 0}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Refused: db_error. A request that failed unexpectedly answers as text instead.
object
Examples
db_error
{ "error": "db_error"}Headers
Section titled “Headers”Every response names the request it answers in X-Request-Id: the id the request was sent with in that header, when it is well formed, else one the API gave it. Quote it when reporting a refusal or a failure: the API’s log lines for that request carry it.
Questions? Write to [email protected].