Patterns
Two ways to combine the routes on Run a Flow from your system with what a Flow's author builds in Studio: a Flow that reads files your system dropped in Amazon S3, and one that ends by training the next version of an Intelligence Graph. api is the shell function from step 1 of that page and call the helper from its Python example.
Files dropped in S3 are picked up by a Flow
Your system writes files to a prefix in a bucket you own; when a run starts, the Flow reads that prefix through the AWS connector's role in your account, copies the objects into the run, and the steps work on them. Nothing watches the bucket: a run reads the prefix when it starts, and a schedule or your POST starts it.
Before you start: the Flow's author has created an AWS connector in Data Bridge with a recorded passing Test connection, connected it to the agent that owns the reading step (Agents: configure and activate), and activated a Flow version with an s3_prefix parameter naming that connector (Flows: build a Flow). Your key needs workflows:read and runs:create for it.
-
Write the files under a prefix of your choosing, for example the day's trade and custodian files under
s3://<your-bucket>/incoming/2026-09-27/. Any object type is fine. Finish writing before you start the run: the copy happens once, at launch, and objects added afterwards are not seen by that run. -
Read the parameter contract.
api "https://$STUDIO/api/v1/workflows/<workflow_id>/parameters"{"name": "drop", "type": "s3_prefix", "required": true, "description": "Trade files to reconcile","connector": {"connector_id": "<connector_id>", "name": "Intake bucket", "region": "eu-west-1"},"bucket": "<your-bucket>", "prefix_default": "incoming/","constraints": {"max_objects": 500, "max_bytes": 2147483648}}connectoris the AWS connector whose role reads the bucket, with its default region. With a fixedbucketyou pass only a prefix; without one you pass a fulls3://bucket/prefix, which the role must be allowed to read.prefix_defaultapplies when you omit the parameter.constraintsare the most a run copies in: 500 objects and 2 GiB by default, up to 5,000 and 20 GiB. -
Start the run by API, with the prefix as the value:
api -X POST "https://$STUDIO/api/v1/workflows/<workflow_id>/runs" \-H "Idempotency-Key: intake-2026-09-27-batch-1" \-H "Content-Type: application/json" \-d '{"parameters": {"drop": "incoming/2026-09-27/"}, "client_reference": "recon-2026-09-27-1"}'The parameter has You pass Example A fixed bucketA prefix inside it; the s3://<that bucket>/…form is accepted and strippedincoming/2026-09-27/No fixed bucketA full s3://bucket/prefixs3://<your-bucket>/incoming/2026-09-27/A trailing
/is added if missing. The value must not start with/, contain.or..segments or control characters, or exceed 900 characters after the bucket. A prefix in another bucket ("must be a prefix inside bucket …") or a bare prefix where a URI is needed ("must be a full s3://bucket/prefix because the parameter has no fixed bucket") answers400 invalid_parameterswith the parameter'snameandreason.Or by schedule from Studio: a
cron(...)orrate(...)expression in UTC with fixed parameter values suits a stable prefix (incoming/) your system keeps filling and the Flow drains, not a per-batch prefix. Scheduled runs belong to the person who created the schedule and are not visible to your key onGET /runs; trigger by API when your system must follow the run (Flows: run, schedule, approve). -
At launch the API checks the run before it starts (among other things, the connector exists, is not flagged as needing attention and has a recorded passing Test connection; otherwise
409 workflow_not_readywithdetails.reasons, The check before a run), then copies every object under the prefix into the run'sinputs/drop/folder (named after the parameter), up to the caps.inputs_manifestlists what arrived; a step's objective can refer to{{params.drop}}. A failed copy ends the run before any step (Notes). -
Collect the outputs from the run's
outputs/folder in the deployment's own workspace storage, throughGET /runs/{run_id}/outputs,/outputs/{output_id}/contentand/outputs.zip; a final step that writesoutputs/result.jsonappears parsed asresult. Studio writes nothing back to your bucket. If you want results there, the author has the task's agent write them through the same connector (the AWS SDK in its kernel, with the role's temporary credentials), and the role's policy must allows3:PutObjecton the destination.
Train an Intelligence Graph from a Flow run
A Flow can end with an Intelligence Graph update step, which trains the next version of an Intelligence Graph from what the earlier steps learned. Started through the API, the run builds a training document, a person may review it in Studio's Inbox, and a new version is created and, if the author chose so, adopted by the agents that use the graph. The API and its events still call this step ampg_update and the graph a knowledge base (kb_id).
Before you start: the graph has a Ready version with training documents, and the author has configured the step (the target graph, the source steps, Mode Rewrite or Append, Hold the new PDF for my review before creating the version, on by default, and Update all agents using this Intelligence Graph, off by default); see Flows: the Intelligence Graph update node. Your key needs runs:create and runs:read.
-
Start the run as for any Flow; the training happens in its last steps.
api -X POST "https://$STUDIO/api/v1/workflows/<workflow_id>/runs" \-H "Idempotency-Key: kb-refresh-2026-09-27" \-H "Content-Type: application/json" \-d '{"parameters": {"drop": "incoming/2026-09-27/"}, "client_reference": "kb-refresh-2026-09-27"}' -
Watch the two steps the update step becomes on
GET /runs/{run_id}/steps: the build step, with the update step's slug andnode_typeampg_update, reads the sources and the base version's documents and writes the new training document; the publish step,<slug>-publishwithnode_typeampg_publishandderived: true(the runtime adds it; it is not one of the version'snodes), depends on it and creates the version. Each has its ownstatus, timings andresult_summary. -
If the document is held for review, the build step finishes and parks:
GET /runs/{run_id}readswaiting_for_approvalwithcounts.awaiting_approval1,/approvalslists the step underpendingwith"phase": "result", and/stepsshows"awaiting": {"phase": "result", "since": "…"}. In the builder's words, "An Inbox card shows the built PDF with Approve · Send back · Stop before the Intelligence Graph version is created." A person approves it, sends it back or stops the run there; the API cannot. Once approved,approved_byandapproved_atname that person, the publish step starts and the run returns torunning. Keep polling every 5 seconds; a long wait here is a person, not a fault. -
Rewrite or Append. The publish step creates version
N+1from baseN: Rewrite (the default) rewrites versionN's documents and the learnings from the connected steps into one new training document, the whole next version; Append keeps versionN's documents and adds one document with only the learnings. The base is the graph's highest Ready version when the run publishes, not when the Flow was saved: the builder's "Starts from v<N>·<k>documents" line is resolved again at run time. -
Adoption. With Update all agents using this Intelligence Graph on, every agent that uses the graph moves to the new version once it is Ready, and the event below lists them in
adopted_agents. With it off, "The version is created; you publish and adopt it from the Inbox card." Agents keep the version they pin until then (Intelligence Graphs: use, move agents, delete). -
Read the new version. The API has no Intelligence Graph routes; the run tells you in three places: the publish step's
result_summaryonce it iscompleted; the eventampg_version_createdonGET /runs/{run_id}/events, whosepayloadcarrieskb_id,version,key(the training document's workspace key),adopted_agents,job_ids,base_version,base_documentsandmode; and the graph's versions in Studio, where the row reads Building and then Ready (Intelligence Graphs). The approval started a new segment, so readsegmentsand poll the latest fromafter_seq=0.api "https://$STUDIO/api/v1/runs/<run_id>/events?after_seq=0&limit=500"events = call("GET", f"/runs/{run['run_id']}/events", params={"after_seq": 0, "limit": 500}).json()created = [e for e in events["events"] if e["type"] == "ampg_version_created"]if created:p = created[-1]["payload"]print("graph", p["kb_id"], "version", p["version"], "from", p["base_version"], "mode", p["mode"],"adopted", p["adopted_agents"])
What you should see
| Pattern | What the run reports |
|---|---|
| Files in S3 | 202 with the run running; parameters.drop normalised with its trailing /; inputs_manifest listing each copied object with name and size; on /steps the reading step running, then completed with a result_summary; the files on /outputs once completed |
| Intelligence Graph | running while the upstream steps and the build work; waiting_for_approval while the document is held (and, at any point, while a person decides on a command a step's agent wants to run, phase tool); running again after the approval; completed once the version is Ready (and, with the toggle on, the agents moved). In Studio's Inbox the review card, then the publish card, appear for everyone assigned to the deployment, tagged API run |
Notes
- The connector's session is 3,600 seconds by default, between 900 and 43,200 seconds, capped by the role's own maximum session duration.
409 workflow_not_readywith "… which @load-positions uses, needs attention: …": Studio has flagged the connector and the reason follows the colon; the author fixes it and runs Test connection (Connector versions, Test connection and guides).input_materialisation_failed(the run endsfailedwith thiserror.codebefore any step runs: role denied, empty prefix or a cap exceeded): check the role's permission policy against the bucket, that the objects were written before the run started, and the object count and size againstconstraints. A run that reconciled an older batch means the schedule passed a fixed prefix: trigger by API with a per-batch prefix, or point the schedule at a prefix your system drains.- A graph holds 50 versions and builds one at a time: a publish step that finds another version building fails; wait, then start a new run. A Rewrite with no documents behind the base fails rather than rewrite nothing (the builder warns "No training documents found for v
<N>— the step will fail rather than rewrite nothing."); the author builds a version from documents first, or switches the step to Append. - After 3,600 seconds the publish step fails with no
ampg_version_createdevent while the version keeps building; check the graph's versions in Studio, and if it reads Failed there, open it for the reason.
Related
- Overview
- AWS connector: the role, the External ID, Test connection.
- Flows: build a Flow: declaring the
s3_prefixparameter. - Flows: the Intelligence Graph update node: configuring the step.
- Flows: run, schedule, approve: schedules and approvals in Studio.
- Inbox: where the review and publish cards appear.
- Secrets and connector credentials: how the role's temporary credentials reach the kernel.