Deploying recipes
This page describes automated recipes in API v3.1. The v3 recipe operations still work and stay available until they are switched off; if you are on them today, see Moving recipes to v3.1.
An automated recipe turns a template into a SQL view in the destination of your workspace, built from the extractions the template needs. What follows is the complete deployment path: what to call, in what order, what each call needs, and how to tell what the result is worth.
Authentication and two transport rules
Every request is workspace-scoped. Exchange your Basic credentials for a bearer token with
POST /api/v3/token, as described in
Authorization:
Code
A token lives for 30 minutes and every successful request renews it, so a client that keeps
working never has to re-authenticate; one that goes quiet for half an hour exchanges again. The
token is bound to one workspace — the one named in the exchange — and a request for a
resource of another workspace answers 404, not 403. The first exchange for a pair of agency
and workspace creates one machine account with the Editor role and reuses it afterwards, so
repeated exchanges do not multiply users.
If you call the API with cookie authentication instead of a token, send the workspace id in the
X-IM-WORKSPACE-ID header; with a bearer token the workspace is already fixed and the header is
not needed.
Every path ends in a slash. A 301 from this API means the slash is missing from your URL —
it is a mistake in the request, not a redirect worth following. The redirect leads to a 404, and
most HTTP clients follow it by turning your POST into a GET and dropping the body, so you end
up parsing an HTML error page as JSON. Configure the client not to follow redirects:
Code
Every response carries an x-im-trace-id header. It identifies the request on our side: keep it
in your logs and quote it when you contact support.
All errors of the v3.1 recipe and account operations use one envelope, {code, message, details},
and you branch on code. The catalogue is on the Errors page.
Deploying a recipe: five calls
1. Pick a template
Code
A template belongs to your agency, not to a workspace, so the same id deploys everywhere. The
list holds only templates that can be deployed through the API, so it can be shorter than the
catalogue the interface shows. origin says who owns the template: improvado for ours,
agency for one of yours.
GET /api/v3.1/automated-recipe-templates/{template_id}/
adds what you need to choose between templates: categories, build_mode (see
Build modes) and output_columns, the schema of the table the template produces —
available before you deploy anything. An empty output_columns means the schema could not be
read, not that the table has no columns.
Templates are created and edited in the interface only; this API reads them. Everything else about them — how to author one, how to name it, what a step may contain — is in Recipe templates.
Two identifiers travel together through the rest of this page and they are not of the same type:
recipe_id is a string (of digits, but a string — do not parse it into a number), and
template_id is an integer.
2. Find the connections and accounts of this workspace
Code
GET /api/v3/datasources/{datasource_name}/connections
gives you connection_id, and
GET /api/v3.1/connections/{connection_id}/accounts/
gives you the accounts of that connection. The account id a recipe accepts comes only from
the v3.1 accounts operation and only from accounts with is_active: true — the operation also
returns accounts that are switched off, and configuring a recipe with one of them is rejected with
account_unavailable. Note that the v3.1 path requires the trailing slash while the v3 connections
path does not.
Both identifiers are local to the workspace. Never reuse an id resolved in another workspace.
3. Create the recipe
Code
POST /api/v3.1/automated-recipes/ answers 201 with
the whole recipe. It is created empty: data_sources and connections are empty,
last_build_at is null and state is extracting_data. That combination means "created, not
configured yet" — the next call is mandatory.
title names the recipe and nothing else; it is optional and the template supplies a default. It
has no effect on the name of the output table, see
The name of the output table.
One recipe per template per workspace. A second create answers 409 recipe_already_exists:
Code
Treat that as already deployed rather than as a failure. The list is ordered: recipes that are
not failed come first, and within each group the most recently updated one comes first, so the
first id is the one worth reusing. The list can be empty — that happens when two creates raced
each other — and then you find the recipe with
GET /api/v3.1/automated-recipes/?template_id=4021. Do not create recipes from one template in
one workspace in parallel.
4. Configure it — mandatory
Code
PUT /api/v3.1/automated-recipes/{recipe_id}/ gives
the recipe the data sources, connections and accounts it builds from. This is a required step, not
an edit: a build started before it answers 409 recipe_not_configured.
accounts[] takes objects with an id, not bare numbers, and every data source you name has to
be one of the recipe's allowed_data_sources with at least one connection for it. An account that
is not active, or does not belong to that connection, comes back as 400 account_unavailable with
the offending ids in details.
The call answers 200 with the recipe as it now stands, so you can compare the response with what
you sent. It changes neither state nor error and starts no build. The body is the full set, not
a delta — see PUT only adds.
5. Start the build and poll
Code
POST .../build/ answers 202 straight away with
the recipe, whose last_build_at is the moment the build started. 202 means the build started,
not that it will finish.
Poll GET /api/v3.1/automated-recipes/{recipe_id}/ until
state is ready_to_work or failed. The four states are snake_case:
state | Meaning |
|---|---|
extracting_data | Data is being collected. |
building_dependencies | The tables are being built. |
ready_to_work | The last build finished and the output table can be queried. |
failed | The last build failed; error says why. |
The same four values are what the ?state= filter of
GET /api/v3.1/automated-recipes/ accepts. Anything else,
a v3 value such as Ready to work included, is rejected with 400 invalid_query_parameter and
the allowed values in details.allowed_values — it is not answered with an empty page.
There is no hard limit on how long a build takes, but in practice it finishes within 120
minutes. If there is still no outcome well after that, contact support with the x-im-trace-id
of one of your requests.
What ready_to_work means
ready_to_work means built, not built completely. A build waits for the extractions of the recipe
and is then built on the ones that delivered. An extraction counts as delivered once one of its
runs has completed: the first data is in, while the historical backfill may still be loading. The
build does not wait for extractions that cannot deliver on their own, and it waits for the rest
only up to a limit; whatever is still missing then is left out.
Three fields tell you how complete the result is:
degraded—truewhen the last build left something out,falsewhen everything delivered. It is only meaningful whilestateisready_to_work; in every other state it isfalse.nullmeans the completeness of that build is unknown because it ran before version 3.1.not_delivered_reasons— the distinct reasons behind an incomplete build, deduplicated across all data sources. Enough to triage a fleet from the list operation alone.sources[]— the breakdown per data source: itsstatus, itserror,not_delivered_countandnot_delivered[]with the extraction, the account and the reason. The list holds at most 100 entries per data source, whilenot_delivered_countis the full number.
sources[].not_delivered[].account_id is the same id you sent in connections[].accounts[].
reason | What happened | What to do |
|---|---|---|
connection_unavailable | The connection was deleted or has to be reconnected. | Reconnect it in the interface, then build again. |
account_disabled | The account is switched off. | Switch it back on, then build again. |
permission_denied | Access to the account was withdrawn on the platform side. | Restore access with the platform, then build again. |
extraction_failing | The extraction keeps failing on the platform. | Check the extraction in the interface; build again once it succeeds. |
report_type_deprecated | The platform retired the report this extraction reads. | Pick a template that does not rely on it, or ask support. |
paused | The extraction is paused. | Resume it, then build again. |
not_running | An existing extraction the build reused has nothing running. | Run it, then build again. |
timed_out | It did not deliver within the window the build waits. | Nothing is wrong yet — build again later; the data is usually there by then. |
unknown | None of the above. | Contact support with the x-im-trace-id. |
source_failed | A whole data source dropped out of the build. Appears in not_delivered_reasons only. | Read sources[].error for that data source. |
New reasons can be added without a new version, so tolerate values you do not know.
One thing none of this covers: an extraction that ran and returned zero rows counts as delivered. No row counts are checked anywhere, so if you need to be sure every account is represented in the output, query the table in your destination and compare the accounts present there with the ones you configured.
When a build fails
A failed recipe always carries error, and error is filled in if and only if state is
failed:
Code
code— branch on this. Build error codes are a namespace of their own, separate from the codes of HTTP error responses; a few names appear in both. The catalogue is on the Errors page.stage—extraction,transformation_build,final_build, ornullwhen the failure was recorded without a phase.message— public text, not raw output: a fixed sentence for our own codes and the cleaned-up message of the database for SQL failures. Its wording is not part of the contract.
A data source that failed on its own carries the same object in sources[].error, with
data_source matching that entry.
A failure recorded before v3.1 is classified from the stored database text: a recognised one comes
back with an sql_* code and cleaned-up text, and one that is unrecognised or empty comes back as
build_failed with a generic message.
If the extractions the recipe needs could not be created at all, the detailed reason from the
platform is not passed through. Contact support with the x-im-trace-id of the build request.
Checking the extraction tables
A recipe reads extraction tables, and a build that starts before they exist fails on missing data. Ask what it is waiting for:
Code
Code
GET .../extractions/ answers "were the
tables created", not "is the data ready". A table exists as soon as the first rows land in it, so
all_tables_exist: true says nothing about coverage and can be true while the recipe is still
extracting_data. Readiness is the state of the recipe together with degraded and sources.
That makes it a decision aid for one question: whether repeating the build is worth it. While
all_tables_exist is false, another build fails the same way; once it is true, starting one
makes sense. A data source whose extractions write into more than one table appears once per
table, so key the list by table, not by data_source. Nothing is cached — every call queries
the destination, and a destination that cannot be queried answers 503 rather than reporting
table_exists: false.
Build modes
A template has a build_mode, and it answers one question: what happens when one source of the
recipe returns no data. A source here is the set of extractions behind one report of the template.
A source fails when no account delivered data for it, or when its extractions could not be created
at all.
build_mode | One source fails | All sources fail, or the final build fails |
|---|---|---|
progressive | The source is dropped. The recipe becomes ready_to_work with degraded: true and source_failed among not_delivered_reasons. | The recipe is failed — all_sources_failed, or the code of the build failure. |
atomic | The recipe is failed. | The recipe is failed. |
In both modes, individual accounts that did not deliver never fail the recipe as long as at least
one account delivered data for their source. They show up in degraded, not_delivered_reasons
and sources[].not_delivered[].
A template with a single source behaves the same way in both modes: if that source fails, the recipe fails.
Picking up a template change
When a template is edited in the interface, recipes already deployed from it keep the steps they
were created with.
POST .../resetup/ recreates those
steps from the current template:
Code
The configuration is kept — data sources, connections, accounts and sync_from_date — and so are
the recipe identifier and the name of its output table. Nothing has to be sent again with PUT. A
build starts on its own, so no separate /build/ call is needed; 202 means started, not
finished, and you poll as after any build.
If a build of that recipe is already running, the answer is 409 build_already_running with
details.recipe_updated. true means the steps were already recreated and only the build was not
started: repeat the call, or start a build, once the running one is over. false, or no
recipe_updated at all, means nothing was changed.
PUT only adds
The body of a configuration call is the complete set, not a delta: send every data source,
connection and account the recipe should have, including the ones it already has. Leaving one out
is rejected with 409 and the matching code — data_source_removal_not_allowed,
connection_removal_not_allowed or account_removal_not_allowed — and nothing is saved:
Code
An account cannot be removed from a recipe. There is no call that does it, and deleting the recipe does not do it either — the extractions created for the account keep running and their data stays in place, so a recipe deployed again from the same template in the same workspace still sees it. Add an account to a recipe only when its data belongs in the result for good.
If the data of an account has to be taken out of a result, contact support with the recipe id and the account id.
Deleting a recipe
Code
DELETE /api/v3.1/automated-recipes/{recipe_id}/ answers
204 with an empty body. This is a hard delete and cannot be undone: the output tables the recipe
produced are dropped, its configuration goes with it, and the intermediate recipes it was built on
are deleted too. The cascade follows what the recipe reads, not what reads it — a recipe built on
top of this one stays in place and breaks, and an intermediate that another deployed recipe also
reads is deleted all the same.
The extractions created for the recipe are not deleted. They keep running on their schedule, the data they have already collected stays where it is, and a recipe deployed from the same template in the same workspace later sees the data of all those accounts, whatever set of accounts its own configuration names. A delete cannot stop extractions, and it is not a way to narrow what a result contains.
The template slot and the output table name are free again as soon as the 204 arrives, but the
registration of the table on the platform side is removed asynchronously. Before deploying the
same template here again, wait until the recipe is gone from
GET /api/v3.1/automated-recipes/: a create sent straight after the 204 can be handed the
datatable_id of the old table, which is then dropped.
If the recipe itself could not be deleted, the answer is 500 delete_incomplete. An intermediate
recipe that could not be deleted is recorded on our side and does not change the answer.
The name of the output table
The name of the output table is derived from the title of the template at the moment the recipe
is created, never from the title you pass when creating the recipe. A recipe gets its name
once and keeps it: renaming the template does not rename it, and neither does resetup. Renaming
a template in the interface changes the table name only for recipes deployed after the rename, so
two recipes of one template in one workspace, deployed before and after a rename, can carry
different table names — and the current title of the template does not tell you the name of a
recipe deployed earlier. The name is also a normalised form of the title rather than the title
itself.
The only reliable way to learn the physical name is to take datatable_id from the recipe and
read sql_name from
GET /api/v3/data-tables/{data_table_id}.
Names are unique within a pair of agency and workspace, so the same name repeating across your
workspaces is normal and expected. The name is checked on create, on build and on resetup,
which answer 409 view_name_taken with conflicting_recipe_ids, and it is checked again during
the build for every table the recipe writes, intermediate ones included — so a 202 does not
guarantee the name is still free when the build gets there. A collision found then arrives as
error.code: view_name_taken on the recipe; in progressive mode a collision on an intermediate
table arrives as sources[].error.code: view_name_taken for the source that failed, and the
recipe can still finish ready_to_work with degraded: true.
Deleting a recipe, through this API or in the interface, frees its name immediately. The one
exception is a recipe deleted in the interface earlier, back when the interface kept the record
instead of removing it: such a recipe still holds its name, conflicting_recipe_ids points at a
recipe that answers 404, and only support can free the name.
Retrying after a 503
A 503 carries the header Retry-After: 30. On a read, wait and repeat. On POST, PUT,
DELETE, build and resetup the outcome is unknown, so re-read the resource first, then
repeat — never repeat a write blindly.
| Operation | What to read first | Why repeating is then safe |
|---|---|---|
POST /automated-recipes/ | GET /automated-recipes/?template_id=… | If the recipe was created, it is in the list; if it was not, the repeat creates it, and a duplicate answers 409 recipe_already_exists. |
PUT /automated-recipes/{recipe_id}/ | GET /automated-recipes/{recipe_id}/ | The body is the full set, so sending it again over a saved copy changes nothing. |
DELETE /automated-recipes/{recipe_id}/ | GET /automated-recipes/{recipe_id}/ | A recipe already deleted answers 404; otherwise repeat the delete. |
POST .../build/ | GET /automated-recipes/{recipe_id}/ | A build that did start shows a fresh last_build_at, and a second one answers 409 build_already_running. |
POST .../resetup/ | GET /automated-recipes/{recipe_id}/ | Same as build; build_already_running with recipe_updated: true says the steps were recreated already. |

