Skip to content

Run a pipe from your program

Updated Nov 28, 2026
On this page

Your own program can run a pipe that you deployed. Raven calls such a program the End. The End sends the input, the run continues in the background, and the End reads the run until it has a result.

The base URL is https://api.cch137.com.

Before you start

  1. Deploy a version of the pipe in its Deploy tab, or ask the pipe assistant to deploy it. The newest version is the default. You can choose an older one.
  2. Create a token with the scope pipe in Settings → Credentials.

The End runs only the deployed version. A version that you save later takes effect after you deploy it.

To undeploy, use the Deploy tab of the pipe, or ask the pipe assistant. After an undeploy, submissions and reads of the deployment return 404. You can still read and cancel the runs that you sent, also after you delete the pipe.

Authentication

Send the token in the header Authorization: Bearer <token>.

  • A pipe token reaches only /v1/pipes/*. On other paths, it gets the same response as an invalid token.
  • An api token and a signed-in browser session can also call these endpoints.
  • A token with more than one scope can call these endpoints when one of its scopes is pipe or api.
  • Each pipe or api token can make 60 requests in 60 seconds. More requests get 429.

Endpoints

Method and path Body Response
GET /v1/pipes/{pipe_id} None 200 { pipe_id, name, version, deployed_at, input_schema, output_schema }. The schemas are those of the deployed version.
POST /v1/pipes/{pipe_id}/runs JSON or CBOR { input? }, with an optional Idempotency-Key header 202 with the run. The header Location is /v1/pipes/{pipe_id}/runs/{run_id}. A repeated key also gets Idempotent-Replayed: true.
GET /v1/pipes/{pipe_id}/runs/{run_id}?wait=N None 200 with the run. N is 0 to 30 seconds.
POST /v1/pipes/{pipe_id}/runs/{run_id}/cancel None 200 with the canceled run.

Read the result describes the run.

Responses and errors

All responses are JSON. A success is the resource itself: the deployment or the run. An error has this shape, and details can be absent:

json
{ "error": { "code": "not_found", "message": "Not found", "details": {} } }

The message is for people and can change. Programs read only code.

Status code Cause
400 invalid_request The body is not an object, does not decode, or has a key other than input. The Idempotency-Key header is not valid. A file is over a limit. wait is not a number from 0 to 30. The input check failed (see below).
401 unauthenticated The request has no credential. Or the token is invalid, expired or revoked, or has no scope for these endpoints. Every refused token gets the same response.
404 not_found The pipe does not exist, is deleted, is not deployed or belongs to another user. All four get the same response. The run is not a run of this deployment. An id is not a UUID.
409 conflict A cancel of a run that ended, or of a run that another Raven server runs.
413 payload_too_large The body is over 204 MiB. The input without its files is over 1 MiB.
429 rate_limited The token used its 60 requests. Retry-After gives the seconds until the 60 seconds end.
429 too_many_runs You have 20 runs that are running or pausing over all pipes (Retry-After: 10).
502 upstream_failed Raven could not store the files, or Raven failed to start or read the run.
503 draining Raven restarts for an update (Retry-After: 30).

An input error returns 400 with the message validation failed and details.errors [{ reason }]. These cause it:

  • The input does not match the input_schema of the deployed version.
  • A string or a key in the input contains NUL.

The reason starts with the JSON Pointer of the position in the input, such as /q: ….

After a 502 or a lost connection:

  • Send reads and cancels again as they are.
  • Send a submission again with the same Idempotency-Key.
  • A restart of Raven ends waiting reads with 502.
  • The result of a submission without a key is unknown after a 502. A repeat can start a second run. Thus always send a key.

Send a run

http
POST /v1/pipes/{pipe_id}/runs
Authorization: Bearer <token>
Content-Type: application/json
Idempotency-Key: order-1234

{ "input": { … } }
  • The body must be an object. A missing input is {}. Other keys return 400.
  • A Content-Type that contains application/cbor makes the body CBOR. Every other body is JSON.
  • Without the Idempotency-Key header, the submission has no key. A key is 1 to 200 printable ASCII characters. It must not be all spaces.
  • One key of a pipe gives one run, also when submissions arrive at the same time.
  • A key that a run already has returns the current state of that run: 202 with Idempotent-Replayed: true. Raven does not compare the new input and deletes the files of the new upload.
  • A key stays valid while the run record exists, which is 90 days after the run ends. Without a deployment, a repeat also returns 404.

File objects

A file object { "name", "type", "buffer", "size"? } can be at any position in the input.

  • An object whose buffer holds bytes is a file object.
  • name and type (the MIME type) must be strings that are not all whitespace. Raven ignores size and counts the bytes. Other keys return 400.
  • Bytes can only be the buffer of a file object. Bytes at other positions return 400.
  • Raven stores each file, and the pipe gets a file reference in its place.

JSON

JSON gives bytes and dates in a subset of Extended JSON, as Meteor EJSON writes it. The relaxed $date string of MongoDB also works.

Form Meaning
{"$binary": "<base64>"} Bytes, in the standard base64 alphabet. The padding is optional.
{"$date": <epoch milliseconds>}, {"$date": "<RFC 3339>"} A date. The pipe gets a UTC string: {"$date": 0} is "1970-01-01T00:00:00.000Z". Raven drops parts of a millisecond. Years are 0000 to 9999.
{"$escape": {…}} The object inside, with its keys taken literally: {"$escape": {"$date": 1}} is the object {"$date": 1}. Its values convert as usual.
  • Only an object with exactly one of these three keys has a special meaning. A value of the wrong type returns 400. All other objects are plain data.
  • A buffer that is not a $binary object, such as a base64 string or an array of numbers, does not make a file object. It goes to the pipe unchanged.
  • The canonical forms of MongoDB, such as {"$binary": {"base64": …}} and {"$date": {"$numberLong": …}}, do not work.
json
{
  "input": {
    "question": "What does the report conclude?",
    "report": { "name": "report.pdf", "type": "application/pdf", "buffer": { "$binary": "JVBERi0xLjcK…" } },
    "since": { "$date": "2026-09-01T00:00:00+08:00" }
  }
}

The pipe gets this input:

json
{
  "question": "What does the report conclude?",
  "report": { "type": "file", "file_id": "<uuid>", "name": "report.pdf", "mime_type": "application/pdf", "size": 48213 },
  "since": "2026-08-31T16:00:00.000Z"
}

CBOR

  • A byte string is bytes. A byte string in tag 64 (a uint8 typed array) is also bytes. cbor-x on Node writes a Uint8Array in this form.
  • Tag 0 (an RFC 3339 string) and tag 1 (epoch seconds, an integer or a float) are dates. Raven rounds a float to the millisecond. A date becomes the same string as a $date.
  • undefined becomes null.
  • Map keys must be strings. Other tags, NaN, infinities and integers larger than 64 bits return 400. Data after the first CBOR value returns 400.

This is the same submission as the JSON example:

js
import { encode } from "cbor-x";

const body = encode({
  input: {
    question: "What does the report conclude?",
    report: { name: "report.pdf", type: "application/pdf", buffer: pdfBytes }, // Uint8Array
    since: new Date("2026-09-01T00:00:00+08:00"),
  },
});
const res = await fetch(`https://api.cch137.com/v1/pipes/${pipeId}/runs`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${token}`,
    "Content-Type": "application/cbor",
    "Idempotency-Key": "report-2026-09-28",
  },
  body,
});

When the position of a decode error is known, its message starts with the JSON Pointer of the position in the body, such as /input/report: a file object needs a type. A syntax error of JSON or CBOR has only the message of the decoder.

Limits

Item Limit
Files in one submission 8
One image (PNG, JPEG, GIF, WebP, BMP, TIFF, ICO) 10 MiB
One other file 100 MiB
All files of one submission 200 MiB
The body 204 MiB
The input without its files, as JSON 1 MiB
  • The type of a file decides if it is an image. A file over a limit returns 400 with the reason.
  • base64 makes JSON a third larger, so a JSON body can carry about 150 MiB of files. Use CBOR for more.

Files in the input

Each file object becomes a file reference:

json
{ "type": "file", "file_id": "<uuid>", "name": "report.pdf", "mime_type": "application/pdf", "size": 48213 }
  • The nodes of a pipe read only type and file_id. name, mime_type and size are information.
  • input_schema checks the input after the files became references. Write a file field like this:

    json
    { "type": "object", "required": ["type", "file_id"],
      "properties": { "type": { "const": "file" }, "file_id": { "type": "string" },
                      "name": { "type": "string" }, "mime_type": { "type": "string" }, "size": { "type": "integer" } } }
  • You can also put an existing file reference in the input as plain JSON. The file must still exist.
  • Raven stores the files in your Raven files, like chat attachments. They are public: anyone with the download URL can read them.
  • Your storage quota does not stop the upload, but the files count in your storage.
  • A file stays while a run record refers to it. A run record stays for 90 days after the run ends. Then Raven deletes the files that nothing refers to, once a day. Files uploaded less than 24 hours ago stay.
  • When a submission fails with 4xx or 503, Raven deletes its files at once. After a 502, the files stay, because a run can refer to them.

Read the result

GET …/runs/{run_id}?wait=N waits up to N seconds for the run to end. N is 0 to 30, and the default is 0.

  • A run that ended returns at once. Otherwise the response comes after N seconds, with the current state.
  • To wait for a result, read with wait=30 until the status is final.
  • The run in a 202 response is the state at creation. It can already be final, for example failed when a nested pipe does not resolve.
Status Final Meaning
running No The run runs.
pausing No The run finishes the nodes in progress, then pauses.
waiting No The run stopped at a wait or wait_event node. It continues when the time comes or the callback arrives.
paused No You paused it.
interrupted No Raven restarted during the run.
completed Yes output holds the result.
failed Yes error tells the cause.
limit_exceeded Yes A node or the run went over its limit. error tells which.
canceled Yes The run was canceled.

A paused or interrupted run waits until you continue it on the pipe page. The End can cancel it and send it again with a new key.

Field Contents
id The run id
version The version number that ran
status See the table above
source Always deployment
input The stored input, with files as file references
output The output when completed, otherwise null
error The cause of the failure, otherwise null. See Errors of a run.
warnings An array
created_at, started_at, finished_at RFC 3339. finished_at is null until the run ends.

The run also has pipe_id, pipe_name, version_id, retention, resolved_versions and wake_at.

Errors of a run

error is an object whose kind tells the cause. The other fields depend on the kind.

kind Fields
node_failed node_id, message
output_schema node_id, errors (an array of violation strings)
limit_exceeded node_id, max_execs
run_budget_exceeded max_execs (the run budget)
payload_budget_exceeded max_bytes (the data that the run can send between its nodes)
timeout max_seconds
stalled dropped, waiting
edge_predicate from, to, message
unresolvable_reference node_id, message
invalid_plan node_id, message
persistence message
unknown raw, the raw text of an old error that does not parse

Cancel a run

POST …/runs/{run_id}/cancel cancels a run that did not end, also when it is paused, waiting or interrupted. It returns the canceled run. A run that ended returns 409 conflict. Cancel also works after an undeploy.

Limits

  • The deployment does not fix the version of a nested pipe node. Each run takes the newest compatible version of the nested pipe when it starts.
  • Runs of a deployment count in the hourly limit of the triggers of the pipe: 70 runs started in one hour. Many End submissions thus make triggers skip runs (rate_limited).
  • No endpoint lists runs. To find a lost run id, send the submission again with the same key. The pipe must still be deployed, and the run record must still exist.
  • No server-sent events or callbacks report the end of a run. Read the run with ?wait=.