Skip to main content
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 for a member who is not read-only, and a procedure’s source file. The Effective agent 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:
claim-acknowledgement.procedure.md
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.
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.
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:

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.
The responses in this guide are abbreviated; your ids and times differ.
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.
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.

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:
Read a task for its instructions and the JSON Schema an answer must match:
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:
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:
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, 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:
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

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.