Documents

Automations

Automate document work with the automation builder, the API, the SDKs, the CLI, MCP, webhooks and embeds: triggers, schedules, branches, waits, approvals and agent steps.

Ways to automate

Every option below works on the same documents with the same permissions. Pick the one that fits who starts the work: a person, your server, an AI client or an event.

WayUse it toStart here
Automation builderStart runs from events, Run now or a schedule; process, share, notify, export, branch, wait, ask for approval or ask an agent/dashboard/automations
Developer APICall every tool and feature from your server with one bearer key/docs/developer-api
SDKsTypeScript, Python, Go and Rust clients: one line per tool, plus every API operation/docs/sdk-cli
CLIRun any tool, pipeline or API call from a terminal or a CI job/docs/sdk-cli/cli
MCPLet an MCP client run tools and chains, create and run workflows and decide approvals/docs/mcp
WebhooksReceive signed events when documents, operations, links, workflow runs and approvals change/docs/webhooks
Tool stepsRun several tools on one document in one workflow, each step reading the previous output/docs/developer-api/workflows
API workflowsCreate, publish and run workflow graphs through the API, and cancel, replay or approve their runs/docs/automations/runs
EmbedsPut a tool or the document viewer inside your own app with a short-lived session/docs/developer-api/tool-embeds

The automation builder

Build automations in the dashboard under Automations. A draft is checked as you build; publish it to make an immutable version that new runs use.

Starts

  • Run now, from the dashboard.
  • Documents: a document is uploaded or ready.
  • Links and viewing: a secure link is created or opened, a viewer session starts, a page is viewed, a document is downloaded or printed.
  • Forms and review: a form is submitted, a comment is created or resolved.
  • Rooms, requests and Q&A: a room is created or opened, a participant joins, a document is added or downloaded, a request is created, submitted or satisfied, a question is created, assigned or answered, an action plan task is completed.
  • Agents: an agent run completes or fails.
  • An inbound webhook: a signed request to a Generic HTTP connection.
  • A schedule: once at a set time, at an interval, or on a calendar, in the time zone you choose. Pausing an automation pauses its schedules; when it resumes, the next time is counted from then and missed times are not run.

Steps

  • Process a document with a tool, the same tools as the website and the API.
  • Create a secure link, add recipients to a link, or revoke a link.
  • Send an email or an in-app notification.
  • Generate an export.
  • Ask an agent: the agent's own rules and budget apply, it may ask for approval, and the step waits until the task ends.

Branches, waits and approvals

  • A branch takes the first path whose condition holds (equals, not equals, exists, is missing, greater or less than, contains, is one of) and an Otherwise path when none does.
  • A wait pauses the run for a set time.
  • An approval holds the run until the required number of the named approvers approve; it can expire.
  • Step settings can use values from the trigger and from earlier steps, for example {{trigger.payload.documentId}} or {{steps.compress.output.versionId}}.

Runs

  • Each step has a retry policy (none, fixed or exponential) and its own idempotency key, so a retry does not repeat its effect.
  • Watch every run and step in the dashboard, retry a failed step, cancel a run, or replay it as a new run; the original run is kept unchanged.
  • Decide approvals in the dashboard's approvals inbox or with POST /api/v2/workflow-approvals/{approvalId}/decision.
  • Steps the platform cannot run yet are shown as unavailable in the builder and cannot be saved.

Limits

Schedules, webhook endpoints and replays have fixed limits, checked by the server whichever way you automate.

Schedule limits count active and paused schedules, not disabled ones. Endpoint limits do not count deleted endpoints. The same limits apply in the dashboard, the API, the SDKs and MCP.

LimitValueWhen it is reached
Schedules per automation20WORKFLOW_SCHEDULE_LIMIT_REACHED
Schedules per workspace200WORKFLOW_SCHEDULE_LIMIT_REACHED
Webhook endpoints per workspace and environment (test or live)20WEBHOOK_ENDPOINT_LIMIT_REACHED
Replays of one endpoint's deliveries in any hour200WEBHOOK_REPLAY_LIMIT_REACHED
Deliveries in one bulk replay1,000Bulk replay stops at the limit
File size of one MCP URL import25 MBThe import is refused

Workflows through the API

Workflows created with POST /api/v2/workflows use the wellfriend-workflow/v2 graph. Action nodes call an API operation that GET /api/v2/capabilities marks as a workflow action: ingest or read a document, run a tool, run a chain, create or revoke a secure link, and import, send or export through a connector. Branch, parallel and join nodes shape the path, wait nodes pause for up to one day, approval nodes wait for a decision, and completion nodes end the run.

Validate a graph with POST /api/v2/workflows/validate, create the workflow, publish it, then start runs. API workflows are listed through the API, MCP and the CLI; the dashboard builder lists the automations built there.

Create a workflow (cURL)
curl -sS --fail-with-body -X POST "https://wellfriend.dev/api/v2/workflows" \
  -H "Authorization: Bearer $WELLFRIEND_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "name": "Read and finish",
  "trigger": { "type": "manual" },
  "idempotencyKey": "workflow-read-1",
  "graph": {
    "schemaVersion": "wellfriend-workflow/v2",
    "startNodeId": "read",
    "nodes": [{ "id": "read", "type": "action", "action": "documents.get" }, { "id": "done", "type": "completion" }],
    "edges": [{ "from": "read", "to": "done" }]
  }
}'

Examples

Each example calls a live route; the Snippets page has every workflow, approval, chain and webhook call in cURL, JavaScript, Python, the SDKs and the CLI.

Publish and start a run (TypeScript SDK)
import { Wellfriend } from "wellfriend-document-sdk";

const wf = new Wellfriend(); // reads WELLFRIEND_API_KEY
await wf.workflows.publish("<workflowId>");
const run = await wf.workflowRuns.create("<workflowId>", { input: { documentId: "<documentId>" } });
console.log(run);
Decide an approval (CLI)
wellfriend api POST "/workflow-approvals/$APPROVAL_ID/decision" --data '{"decision":"approve","reason":"Checked the totals"}'
Get a signed event when workflow runs change (cURL)
curl -sS --fail-with-body -X POST "https://wellfriend.dev/api/v2/webhook-endpoints" \
  -H "Authorization: Bearer $WELLFRIEND_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"url":"https://example.com/hooks/wellfriend","eventFilters":["com.wellfriend.workflow.*"],"idempotencyKey":"workflow-events-1"}'
Run three tools on one document as a pipeline (Python SDK)
from wellfriend import Wellfriend

wf = Wellfriend()  # reads WELLFRIEND_API_KEY
steps = [
    {"tool": "compress-pdf"},
    {"tool": "add-watermark", "params": {"text": "CONFIDENTIAL"}},
    {"tool": "protect-pdf", "params": {"password": "<password>"}},
]
wf.pipeline(steps).run("input.pdf").save("output.pdf")

Versions and runs

  • Drafts can change; runs always use a published version.
  • Published versions never change.
  • Each run keeps its trigger, input, version and idempotency key.
  • A processing step finishes only when its document operation finishes.
  • An approval is decided once, and the decision is never reopened.

Handling a failed run

Look at the failed step, its error code, its attempts and its outputs before you act. Retry a step only if it is retryable and within its retry limit. A replay starts a new run; the original run and anything it already did stay as they were.