Flows API

Flows

Save, update and run a waterfall of catalog calls

A flow is a saved waterfall of catalog calls: named inputs and outputs, steps tried in order until every output is filled, and a budget per run. Saving, listing and editing a flow is free. A run costs the sum of the steps it calls, each charged like POST /v1/run, and never more than the budget. The CLI (orth flows) and the TypeScript SDK (orthogonal.flows, @orth/sdk 0.8.0 and later) call these routes.

Access

Every route takes Authorization: Bearer YOUR_API_KEY. Flows are in beta for Orthogonal staff and invited teams. Anyone else, and a flow that belongs to another account, gets 404.

Save a flow

POST /v1/flows saves a definition as the next version. The same name again keeps the earlier versions. A step whose API and path are not in the catalog is refused and nothing is saved (400, problems lists why).

POST /v1/flows
{
"name": "email-to-linkedin",
"title": "Email to LinkedIn",
"inputs": { "email": "string" },
"outputs": ["linkedin_url"],
"steps": [{
"api": "tomba",
"path": "/v1/people",
"params": { "email": "$input.email" },
"map": { "linkedin_url": "linkedin" }
}],
"maxSpendPerRun": 0.06
}

$input.email passes that input as the whole value. {{input.email}} puts it inside a string. $found.linkedin_url takes an output an earlier step filled. Input types are string, number and boolean. The answer is the flow’s summary. created is true the first time that name is saved. warnings, when present, name a step that can never fit the budget or that sends a parameter in the wrong shape.

Update or roll back

PATCH /v1/flows/<name> changes the title, description or budget without a new version. rollbackTo copies that version’s inputs, outputs and steps into a new version, so every version stays on record. Send at least one of the four fields.

PATCH /v1/flows/email-to-linkedin
{ "maxSpendPerRun": 0.08 }
PATCH /v1/flows/email-to-linkedin
{ "rollbackTo": 1 }

Run one input

POST /v1/flows/<name>/run runs the newest version. maxSpend is a lower budget for this run. Send Idempotency-Key (or X-Idempotency-Key): a retry with the same key and the same input answers the stored run and charges nothing. The same key with another input is 409.

POST /v1/flows/email-to-linkedin/run
Idempotency-Key: row-1
{ "input": { "email": "ada@example.com" }, "maxSpend": 0.05 }

Inputs must match the declared types. A number is a JSON number, not a string of digits. A wrong type or an unknown name is 400 with BAD_INPUT, before any call, and is free. The answer has runId, status (complete, partial or empty), output, missing, costUsd and a steps trace. 409 means that key’s run is still going, or the key was already used for a different input.

Run a batch

POST /v1/flows/<name>/batch runs up to 20 inputs. Each item is its own run, with its own idempotencyKey (a row id or a file name). Sending the batch again answers items that already ran, free, and runs only the rest. One bad input is refused alone and does not stop the others.

POST /v1/flows/email-to-linkedin/batch
{
"items": [
{ "input": { "email": "ada@example.com" }, "idempotencyKey": "row-1" },
{ "input": { "email": "grace@example.com" }, "idempotencyKey": "row-2" }
]
}

The answer has batchId when a new run started, totals (complete, partial, empty, failed, cost) and one entry per item with its runId, status, output and costUsd.

From the SDK

Each route has one method on orthogonal.flows: save, update, list, get, run, batch and getRun. A refusal throws OrthogonalRunError with the status and the answer’s body.

import Orthogonal from "@orth/sdk";
const orthogonal = new Orthogonal({ apiKey: process.env.ORTHOGONAL_API_KEY! });
const run = await orthogonal.flows.run("email-to-linkedin", {
input: { email: "ada@example.com" },
idempotencyKey: "row-1",
});
console.log(run.status, run.output, run.costUsd);

Read flows

List

GET /v1/flows lists the account’s flows with their ids, the active version and how many runs each has.

One flow

GET /v1/flows/<name> returns every version, run totals, spend per API and the latest runs. ?before= takes a previous answer’s olderBefore to page back.

One run

GET /v1/flows/<name>/runs/<run id> returns that run’s input, output and each step’s API, outcome and cost.