Skip to content

Save an automation

PUT
/v1/automations/{id}
curl --request PUT \
--url https://api.pixonaut.app/v1/automations/example \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "body": { "steps": [ { "id": "approve", "settings": {}, "type": "approve" }, { "branches": { "onFailure": [ { "id": "tell", "settings": { "role": "admin" }, "type": "notify" } ] }, "id": "print", "settings": {}, "type": "create_print" } ] }, "expectedUpdatedAt": 1760000400000, "name": "Hosted link to printshop", "runsAs": "author", "sources": { "includeNewKeys": true, "includeNewLinks": true, "includeNewStores": true, "keys": null, "links": null, "stores": null }, "spendLimit": 50, "trigger": "design.committed" }'

Operation ID: automations.save

The whole draft, stored as its next version. A save since expectedUpdatedAt is refused automation_changed. The saver becomes its author, unless it runs as the workspace; only an admin may save one that does, or set it to. An MCP key saves only a disabled one.

id
required
string
Media typeapplication/json
object
body
required

The automation’s tree of steps.

object
conditions
Any of:
object
all
required

Every one holds.

Array
>= 1 items
steps
required

The steps, in the order they run. A step’s type names an action from the catalogue.

Array<object>
object
branches

Further steps, under each branch’s name.

object
key
additional properties
Array
id
required

Its id, unique in the body: what a firing names it by.

string
>= 1 characters <= 64 characters
settings

What its type takes; the draft check refuses settings the type does not.

object
key
additional properties
type
required

Its action (approve, create_print, place_order, reroute, cancel_order, notify, email, webhook) or flow step (only_if, paths, wait_for, delay).

string
>= 1 characters <= 64 characters
confirmSpend

Confirms that the automation spends without a person, at most its spend limit in 24 hours. Required, true, when it holds a spend action (create print, place order, reroute); a save without it is refused spend_unconfirmed.

boolean
expectDisabled

Save only while it is disabled: an enabled one is refused automation_enabled and left as it is.

boolean
expectedUpdatedAt
required

The updatedAt the draft was read at. A save since is refused automation_changed, naming who saved it and when.

number
name
required

What members call it.

string
>= 1 characters <= 120 characters
runsAs
required

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.

string
Allowed values: author workspace
sources
required

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
includeNewKeys
required

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.

boolean
includeNewLinks
required

On, it acts on designs from every designer link, those made later too. Off, only from the links in links.

boolean
includeNewStores
required

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.

boolean
keys

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
sources
required

Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.

Array<string>
<= 10000 items
takenAt
required

When its switch was turned off: the snapshot is as of then.

integer
links

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
sources
required

Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.

Array<string>
<= 10000 items
takenAt
required

When its switch was turned off: the snapshot is as of then.

integer
stores

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
sources
required

Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.

Array<string>
<= 10000 items
takenAt
required

When its switch was turned off: the snapshot is as of then.

integer
spendLimit
required

Spend actions it may take per rolling 24 hours.

integer
>= 1 <= 10000
trigger
required

The event it fires on; null for none yet, which fires on nothing. One with none cannot be enabled.

string | null
Allowed values: design.committed design.approved design.changes_requested design.delivery_captured print.completed print.failed order.submitted order.status_changed order.failed order.cancelled order.delivery_changed

Examples

Exampleexample

Example

{
"body": {
"steps": [
{
"id": "approve",
"settings": {},
"type": "approve"
},
{
"branches": {
"onFailure": [
{
"id": "tell",
"settings": {
"role": "admin"
},
"type": "notify"
}
]
},
"id": "print",
"settings": {},
"type": "create_print"
}
]
},
"expectedUpdatedAt": 1760000400000,
"name": "Hosted link to printshop",
"runsAs": "author",
"sources": {
"includeNewKeys": true,
"includeNewLinks": true,
"includeNewStores": true,
"keys": null,
"links": null,
"stores": null
},
"spendLimit": 50,
"trigger": "design.committed"
}

The automation as saved

Media typeapplication/json
object
author
required

The member whose grants it acts with: whoever last saved it. Null when it runs as the workspace.

object
name
required
string | null
userId
required
string
body
required

The automation’s tree of steps.

object
conditions
Any of:
object
all
required

Every one holds.

Array
>= 1 items
steps
required

The steps, in the order they run. A step’s type names an action from the catalogue.

Array<object>
object
branches

Further steps, under each branch’s name.

object
key
additional properties
Array
id
required

Its id, unique in the body: what a firing names it by.

string
>= 1 characters <= 64 characters
settings

What its type takes; the draft check refuses settings the type does not.

object
key
additional properties
type
required

Its action (approve, create_print, place_order, reroute, cancel_order, notify, email, webhook) or flow step (only_if, paths, wait_for, delay).

string
>= 1 characters <= 64 characters
createdAt
required
number
enabled
required
boolean
enabledAt
required

When it was last enabled: it never fires on an event from before. Null for one never enabled.

number | null
firings
required
object
count
required
number
lastAt
required
number | null
paused
required
number
spentToday
required

Spend actions it took in the last 24 hours, against its spend limit.

number
waiting
required
number
id
required
string
name
required
string
runsAs
required
string
sources
required

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
includeNewKeys
required

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.

boolean
includeNewLinks
required

On, it acts on designs from every designer link, those made later too. Off, only from the links in links.

boolean
includeNewStores
required

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.

boolean
keys
required

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
sources
required

Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.

Array<string>
<= 10000 items
takenAt
required

When its switch was turned off: the snapshot is as of then.

integer
links
required

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
sources
required

Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.

Array<string>
<= 10000 items
takenAt
required

When its switch was turned off: the snapshot is as of then.

integer
stores
required

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
sources
required

Each one that existed then, as a design’s origin names it: link:<id>, secret_key:<id> and publishable_key:<id>, or store:<site>.

Array<string>
<= 10000 items
takenAt
required

When its switch was turned off: the snapshot is as of then.

integer
spendLimit
required
number
standing
required
One of:
object
state
required
string
trigger
required

The event it fires on; null for none yet.

string | null
updatedAt
required

When it was last saved: a save names it as expectedUpdatedAt.

number
version
required

Its current version.

number

Examples

Exampleexample

Example

{
"author": {
"name": "Ada Lewis",
"userId": "u_8b1d2c3e4f5a"
},
"body": {
"steps": [
{
"id": "approve",
"settings": {},
"type": "approve"
},
{
"branches": {
"onFailure": [
{
"id": "tell",
"settings": {
"role": "admin"
},
"type": "notify"
}
]
},
"id": "print",
"settings": {},
"type": "create_print"
}
]
},
"createdAt": 1760000000000,
"enabled": true,
"enabledAt": 1760000500000,
"firings": {
"count": 42,
"lastAt": 1760086400000,
"paused": 0,
"spentToday": 3,
"waiting": 2
},
"id": "aut_3c9e1f7a-2b4d-4e8a-9f6c-1d2e3f4a5b6c",
"name": "Hosted link to printshop",
"runsAs": "author",
"sources": {
"includeNewKeys": true,
"includeNewLinks": true,
"includeNewStores": true,
"keys": null,
"links": null,
"stores": null
},
"spendLimit": 50,
"standing": {
"state": "enabled"
},
"trigger": "design.committed",
"updatedAt": 1760090000000,
"version": 4
}
X-Request-Id
required
string

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

Media typeapplication/json
object
error
required
string
fields

Always sent with invalid_body.

Array<string>

Examples

Exampleinvalid_body

invalid_body

{
"error": "invalid_body",
"fields": [
"string"
]
}
X-Request-Id
required
string

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

Media typeapplication/json
object
error
required
string

Examples

Exampleunauthorized

unauthorized

{
"error": "unauthorized"
}
X-Request-Id
required
string

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, admin_only, origin_forbidden, forbidden

Media typeapplication/json
object
error
required
string
feature

The feature the tenant does not have. Always sent with feature_disabled.

string
reason

Always sent with admin_only.

string

Examples

admin_only

{
"error": "admin_only",
"reason": "string"
}
X-Request-Id
required
string

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

Media typeapplication/json
object
error
required
string

Examples

Exampleautomation_not_found

automation_not_found

{
"error": "automation_not_found"
}
X-Request-Id
required
string

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_changed, automation_no_trigger, automation_enabled

Media typeapplication/json
object
error
required
string
reason

Always sent with automation_no_trigger, automation_enabled.

string
savedAt

Always sent with automation_changed.

number
savedBy
One of:
object
kind
required
string
Allowed values: member
name
required
string | null
userId
required
string

Examples

automation_changed

{
"error": "automation_changed",
"savedAt": 0,
"savedBy": {
"kind": "member",
"name": "string",
"userId": "string"
}
}
X-Request-Id
required
string

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: author_needs_member, draft_refused, spend_unconfirmed, spend_limit_over_ceiling, payload_too_large

Media typeapplication/json
object
bytes

Sent with payload_too_large.

number
ceiling

The workspace’s ceiling, the most a spend limit may say. Always sent with spend_limit_over_ceiling.

number
error
required
string
maxBytes

Always sent with payload_too_large.

number
reason

Always sent with author_needs_member, spend_unconfirmed, spend_limit_over_ceiling.

string
refusals

Always sent with draft_refused.

Array<object>
object
code
required
string
message
required

What is wrong, in words.

string
stepId

The step it is about.

string

Examples

author_needs_member

{
"error": "author_needs_member",
"reason": "string"
}
X-Request-Id
required
string

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
error
required
string

Examples

Exampledb_error

db_error

{
"error": "db_error"
}
X-Request-Id
required
string

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].

Status · Terms of service · Privacy policy · Subprocessors