> ## Documentation Index
> Fetch the complete documentation index at: https://docs.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Run procedures from your system

> Publish a procedure from its source, try changes as drafts, start runs with your own inputs, and read each run's result.

A procedure is a program that Effective runs for your organization: it can read documents, call
your connections, ask people to approve a step and return a typed result. Your own system can
publish procedures you keep in source control and start runs when its own events happen, such as
a new claim or a renewal coming due.

You need an [API key](https://docs.effectiveai.app/getting-started/authentication.md) for a member who is not read-only, and a
procedure's source file. The [Effective agent](https://docs.effectiveai.app/getting-started/using-with-agents.md) can write one
for you, or you can keep one you exported.

## Publish a version

This guide uses a small procedure that acknowledges a new claim. Save it as
`claim-acknowledgement.procedure.md`:

````markdown claim-acknowledgement.procedure.md theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
---
kind: procedure@v0
id: claim-acknowledgement

inputs:
  claim_number: { type: string }
  policy_number: { type: string }
outputs:
  acknowledgement: { schema: acknowledgement }
---

# Claim acknowledgement

Acknowledge a new claim against its policy.

## Acknowledge

```yaml complete id=acknowledge
output: acknowledgement
value:
  claimNumber: $inputs.claim_number
  policyNumber: $inputs.policy_number
  received: true
```

## Resources

```yaml schema id=acknowledgement
type: object
additionalProperties: false
required: [claimNumber, policyNumber, received]
properties:
  claimNumber: { type: string }
  policyNumber: { type: string }
  received: { type: boolean }
```
````

Send the file's text as `source`. Every publish needs an `Idempotency-Key`; retrying with the
same key returns the first result instead of publishing twice.

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.effectiveai.app/api/v2/procedures/procedures" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: claim-acknowledgement-v1" \
  --data "$(jq --null-input --rawfile source claim-acknowledgement.procedure.md '{
    sourceName: "claim-acknowledgement.procedure.md",
    source: $source,
    access: "organization",
    expectedLatestVersion: null
  }')"
```

The `id` in the source's front matter is the procedure's id. `access: "organization"` lets every
member of your organization run a new procedure; without it, only you can until you share it.
`expectedLatestVersion: null` makes the publish fail with `409 version_conflict` if the procedure
already exists, so you never overwrite one by accident. On later publishes, send the version you
expect to be the latest.

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "procedureId": "claim-acknowledgement",
  "version": 1,
  "outcome": "published",
  "created": true,
  "live": { "outcome": "promoted", "version": 1 },
  "diagnostics": []
}
```

The first version becomes the procedure's **live** version: the one a run starts unless it names
another. `diagnostics` lists compiler warnings. If the source doesn't compile, nothing is
published and the response is `422 invalid_procedure`, with a `details` entry for each error
giving its line, column and message.

## Check its inputs

Read the version to see the inputs a run takes, each with its JSON Schema, the schema of the
result it returns, and any connections it needs:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request GET \
  --url "https://api.effectiveai.app/api/v2/procedures/procedures/claim-acknowledgement/versions/1" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY"
```

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "procedureId": "claim-acknowledgement",
  "version": 1,
  "inputs": [
    { "name": "claim_number", "schema": { "type": "string" } },
    { "name": "policy_number", "schema": { "type": "string" } }
  ],
  "output": {
    "name": "acknowledgement",
    "schema": {
      "type": "object",
      "additionalProperties": false,
      "required": ["claimNumber", "policyNumber", "received"],
      "properties": {
        "claimNumber": { "type": "string" },
        "policyNumber": { "type": "string" },
        "received": { "type": "boolean" }
      }
    }
  },
  "connections": [],
  "secrets": []
}
```

## Start a run

Name the procedure and pass the inputs. Without `version`, the run starts the live version. Use a
key you can derive from your own event, such as the claim number, so a retried request never
starts a second run.

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.effectiveai.app/api/v2/procedures/runs" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: claim-CLM-20431" \
  --data '{
    "procedureId": "claim-acknowledgement",
    "inputs": { "claim_number": "CLM-20431", "policy_number": "HO-118204" }
  }'
```

The responses in this guide are abbreviated; your ids and times differ.

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "outcome": "started",
  "run": {
    "id": "0b7c6d1e-4f2a-4c3b-9a8e-5d6f7a8b9c0d",
    "procedureId": "claim-acknowledgement",
    "version": 1,
    "status": "running",
    "visibility": "collaborative",
    "cause": { "kind": "direct", "triggerId": null, "parentRunId": null },
    "createdAt": "2026-11-19T17:02:11.408Z",
    "finishedAt": null,
    "webUrl": "…"
  }
}
```

Keep `run.id`. A retry with the same key and body returns `outcome: "already_started"` and the
same run. Inputs that don't match the version's schemas are refused with
`422 invalid_run_inputs`, whose `details` name the input that doesn't match, such as
`Procedure input claim_number does not satisfy its schema.`

Add `"visibility": "private"` to keep the run visible only to the key's user. Private runs are
left out of everyone else's run lists.

## Read the result

Read the run until its `status` is final: `completed`, `failed`, `cancelled`, `terminated` or
`timed_out`.

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request GET \
  --url "https://api.effectiveai.app/api/v2/procedures/runs/0b7c6d1e-4f2a-4c3b-9a8e-5d6f7a8b9c0d" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY"
```

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "id": "0b7c6d1e-4f2a-4c3b-9a8e-5d6f7a8b9c0d",
  "procedureId": "claim-acknowledgement",
  "status": "completed",
  "paused": false,
  "finishedAt": "2026-11-19T17:02:13.950Z",
  "output": {
    "acknowledgement": {
      "claimNumber": "CLM-20431",
      "policyNumber": "HO-118204",
      "received": true
    }
  },
  "failure": null,
  "tasks": []
}
```

`output` holds the value the procedure returned under its output's name (`acknowledgement`
here), in the shape the version's output `schema` declares. A failed
run has `failure` with a `code` and `message` instead. `tasks` lists what the run asked people to
do, such as approvals, each with its `id`, `title` and `status`; while one is `open` the run stays
`running`. A task you can't read shows only its `id`. Open `webUrl` to see the run's
steps in Effective.

To find runs later, list them with `GET /procedures/runs`, filtered by `procedureId`, `status` or
creation time. Lists are [paginated](https://docs.effectiveai.app/getting-started/pagination.md).

## Answer a task

A procedure can ask people to decide something, such as approving a payout. The run waits, and
its `tasks` list each task with its status. Your system can answer for the person who was assigned the task,
using that person's API key. To find what is waiting on them, list their open tasks:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request GET \
  --url "https://api.effectiveai.app/api/v2/procedures/tasks?status=open&assignedToMe=true" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY"
```

Read a task for its instructions and the JSON Schema an answer must match:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request GET \
  --url "https://api.effectiveai.app/api/v2/procedures/tasks/5a1d2c3b-6e7f-4a8b-9c0d-1e2f3a4b5c6d" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY"
```

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "id": "5a1d2c3b-6e7f-4a8b-9c0d-1e2f3a4b5c6d",
  "runId": "0b7c6d1e-4f2a-4c3b-9a8e-5d6f7a8b9c0d",
  "procedureId": "claim-payout",
  "title": "Approve the payout for CLM-20431?",
  "status": "open",
  "instructions": "Check the adjuster's estimate, then approve or deny.",
  "answerSchema": {
    "type": "object",
    "required": ["approved"],
    "properties": { "approved": { "type": "boolean" } }
  },
  "canSubmit": true,
  "submission": null,
  "webUrl": "…"
}
```

`canSubmit` is `true` when the task is open and assigned to you. Send an `answer` that matches
`answerSchema`, with an optional `comment` kept beside it:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.effectiveai.app/api/v2/procedures/tasks/5a1d2c3b-6e7f-4a8b-9c0d-1e2f3a4b5c6d/submissions" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: payout-CLM-20431" \
  --data '{ "answer": { "approved": true }, "comment": "Estimate matches the invoice." }'
```

The response is `outcome: "submitted"` with the task, now `completed`, and the run continues with
the answer. A retry with the same key returns `outcome: "already_submitted"` and the first answer.
An answer that doesn't match the schema is refused with `422 invalid_answer`, with a `details`
entry for each mismatch. A task that was already answered, or closed because its run was
cancelled, is refused with `409 task_not_open`. Only the task's assignees can answer it.

## Try a draft

Before you publish a change, run the edited source as a draft. Effective compiles it and runs it
with your inputs and connections, but stores no version: the live version doesn't change, and
runs that don't send source keep starting it. Send the source fields you would publish (`source`,
`sourceName`, and any `fragments` or `documents`) in place of `procedureId`:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.effectiveai.app/api/v2/procedures/runs" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: claim-acknowledgement-draft-1" \
  --data "$(jq --null-input --rawfile source claim-acknowledgement.procedure.md '{
    sourceName: "claim-acknowledgement.procedure.md",
    source: $source,
    inputs: { claim_number: "CLM-20431", policy_number: "HO-118204" }
  }')"
```

```json theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
{
  "outcome": "started",
  "run": {
    "id": "5e2f8a40-1c3d-4b6e-8f7a-9b0c1d2e3f4a",
    "procedureId": "claim-acknowledgement",
    "version": null,
    "draft": true,
    "status": "starting",
    "visibility": "private",
    "webUrl": "…"
  }
}
```

A draft has `draft: true` and no `version`. Only you can see it unless you send
`"visibility": "collaborative"`. Read it with `GET /procedures/runs/{runId}` as in
[Read the result](#read-the-result), and list your drafts with `draft=true`.

* Source that doesn't compile is refused with `422 invalid_procedure` and the same `details` a
  publish gives, and no run starts.
* The `Idempotency-Key` covers the source, so use a new key for each edit. Reusing one with
  changed source is refused with `409 idempotency_conflict`.
* A draft can't declare secrets. Publish a procedure that reads secrets to run it.

When the draft does what you want, publish the same source as the next version. Nothing a draft
stores becomes a version, and triggers never start drafts.

## Publish a new version

Publish the changed source with a new `Idempotency-Key` and `expectedLatestVersion` set to the
current latest version. The response's `live.outcome` says what happened to the live version:

* `promoted`: the new version is live, and new runs start it.
* `held_interface_mismatch`: the new version's inputs or output differ from the live version's, so
  it was not made live. Systems that start runs keep working against the old inputs until you
  switch.

To switch, read the procedure for its current live `generation`, then set the live version:

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.effectiveai.app/api/v2/procedures/procedures/claim-acknowledgement/live" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{ "version": 2, "expectedGeneration": 1 }'
```

If someone else changed the live version since you read it, the request is refused with
`409 live_version_changed`; read the procedure again and decide. Runs that name a `version` are
not affected by the live version.

## Cancel a run

```bash theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
curl --request POST \
  --url "https://api.effectiveai.app/api/v2/procedures/runs/0b7c6d1e-4f2a-4c3b-9a8e-5d6f7a8b9c0d/cancel" \
  --header "Authorization: Bearer $EFFECTIVE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{ "reason": "Claim withdrawn" }'
```

The response is `outcome: "cancelling"`, and the run reaches `cancelled`. Cancelling a run that
already finished returns `outcome: "already_finished"` and changes nothing, so a retry is safe.
The body is required; send `{}` without a reason.

## Who can do what

The API follows the procedure's sharing in Effective. A procedure you can't see answers `404`.
Reading a version's inputs needs permission to read the procedure's source, and publishing or
setting the live version needs permission to publish it; without them the answer is `403`.
Starting a run needs permission to run the procedure. A draft runs unpublished code, so it needs
permission to publish the procedure its source's `id` names, or to create procedures when that id
is new; resource-scoped and app API keys can't start drafts. Someone else's private run answers
`404`.
Tasks follow their own sharing: you can read a task assigned to you, or any task if you can view
your organization's tasks, and only its assignees can answer it.

Procedures, runs and tasks have no API usage charge. A run uses credits for the agent and model work its
steps do; see [Usage and billing](https://docs.effectiveai.app/getting-started/billing.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.