Skip to content

Workflows

Cord Workflows as code: keep your workflows in your repository, check them before you upload them and try them out in your test environment.

Overview

A Cord Workflows workflow is a rule that acts on its own when an event happens: it creates a task, notifies your team or writes to your client. Through the API it’s the same JSON definition the app’s editor saves, and Cord checks it with the same rules.

Every workflow has two copies: the draft, which is what you edit, and the published version, which is what runs. Creating and editing through the API always change the draft; what runs doesn’t change until the workflow is published (see Publish). The full operations, with every field, are in the API reference.

Field What it is
object Always "workflow".
id The workflow’s UUID.
nombre 1 to 120 characters.
estado draft if it was never published, active if it runs and paused if it’s paused.
pausado_por Why Cord paused it on its own: fallos (its latest runs failed) or permisos (the person who published it lost a permission one of its steps needs). null if a person paused it or it isn’t paused.
disparador The event that starts the draft, such as quote.approved.
disparador_publicado The one of the published version; null if it was never published.
version The published version’s number; 0 if it was never published.
rev The draft’s revision: it changes every time someone saves it, in the app or through the API.
cambios_sin_publicar true if the draft differs from the published version, or if it was never published.
actualizado Last time the draft or its status changed, ISO 8601.
publicado_at When the current version was published; null if never.
definicion The draft. It only comes in the detail and in the create, edit and publish responses, like the next two fields.
publicado The definition of the version that runs; null if it was never published.
para_publicar What still keeps the draft from being published, the same the editor flags; empty if it can be published.

The definition

The definition holds the trigger in trigger and the steps in steps, in order. The trigger is a Cord event (quote.approved, invoice.overdue…), schedule.tick for a scheduled one, webhook.received for one that starts from another system, or quote.manual_run and invoice.manual_run for the You run it ones; null in a draft that doesn’t have one yet. Each step carries its id, 4 to 24 lowercase letters or digits and not repeated in the workflow, and its type: action, condition, wait, query, wait_until, switch, approval, data, classify, split, draft or foreach. A step with branches carries them inside (then, else, ramas, grupos, steps or falla).

The definition can also carry filtro (Only when…), inscripcion (How often it enters), meta (Ends early if…), envios (the hours and the limit of what it writes to the client), schedule in a scheduled workflow and entrada in one that starts from another system. The triggers, the actions and the event data are explained in the Cord Workflows guide. The fastest way to get to know a full definition is to build the workflow in the editor and read it with GET /api/v1/workflows/{id}.

A minimal definition that can already be published: when the client approves a quote, it creates a task with its number.

{
  "trigger": "quote.approved",
  "steps": [
    { "id": "t001", "type": "action", "action": "create_task", "params": { "titulo": "Review {{folio}}" } }
  ]
}

Cord saves the definition the way the editor would, and anything the editor would remove or change is rejected instead of being saved differently: an action or a parameter that doesn’t exist, a text longer than its field accepts, a repeated id, or more than 30 steps or 4 levels (see Limits). Those responses are 400 invalid_request (see Validate without saving).

List and retrieve

GET /api/v1/workflows returns up to 200 workflows without their definitions, from the most recently changed to the oldest. It isn’t paginated. With a test key it lists the ones in your test environment.

curl "https://cordhq.app/api/v1/workflows" \
     -H "Authorization: Bearer sk_test_tU..."
{
  "data": [
    { "object": "workflow", "id": "8f3c2a1e-5b7d-4e9a-9c6f-1d2e3f4a5b6c", "nombre": "Task on approval", "estado": "active", "pausado_por": null, "disparador": "quote.approved", "disparador_publicado": "quote.approved", "version": 3, "rev": 7, "cambios_sin_publicar": false, "actualizado": "2026-11-24T17:20:41.000Z", "publicado_at": "2026-11-24T17:20:41.000Z" },
    { "object": "workflow", "id": "2b7e9d4c-1a6f-4c3e-8d5b-7f0a9e2c4d18", "nombre": "Overdue invoice", "estado": "draft", "pausado_por": null, "disparador": "invoice.overdue", "disparador_publicado": null, "version": 0, "rev": 2, "cambios_sin_publicar": true, "actualizado": "2026-11-22T15:08:12.000Z", "publicado_at": null }
  ]
}

GET /api/v1/workflows/{id} returns the workflow with definicion, publicado and para_publicar. An id that doesn’t exist or belongs to another account responds 404 not_found.

Create a draft

POST /api/v1/workflows takes nombre and, optionally, definicion. Without a definition it starts empty (trigger set to null and no steps). A workflow created through the API always starts as a draft, even if it can already be published: it doesn’t run until it’s published.

curl -X POST "https://cordhq.app/api/v1/workflows" \
     -H "Authorization: Bearer sk_test_tU..." \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: workflow-task-on-approval" \
     -d '{ "nombre": "Task on approval", "definicion": { "trigger": "quote.approved", "steps": [{ "id": "t001", "type": "action", "action": "create_task", "params": {} }] } }'

It responds with the workflow and its draft. Here the step has no title, so it’s saved but can’t be published yet: para_publicar says what’s missing, with the step’s path in path and its id in step_id. The messages come in English, like the rest of the API.

{
  "data": {
    "object": "workflow",
    "id": "8f3c2a1e-5b7d-4e9a-9c6f-1d2e3f4a5b6c",
    "nombre": "Task on approval",
    "estado": "draft",
    "pausado_por": null,
    "disparador": "quote.approved",
    "disparador_publicado": null,
    "version": 0,
    "rev": 0,
    "cambios_sin_publicar": true,
    "actualizado": "2026-11-25T16:02:37.000Z",
    "publicado_at": null,
    "definicion": { "trigger": "quote.approved", "steps": [{ "id": "t001", "type": "action", "action": "create_task", "params": {} }] },
    "publicado": null,
    "para_publicar": [
      { "path": "definicion.steps.0", "step_id": "t001", "message": "Fill in \"Task title\"." }
    ]
  }
}

Edit the draft

PATCH /api/v1/workflows/{id} changes what you send and keeps the rest. The published version doesn’t change: cambios_sin_publicar becomes true until the workflow is published.

Field Effect
nombre Replaces the saved one.
definicion Replaces the whole draft. Cord checks it the same way as when it’s created.
rev The draft revision you read. If someone saved it afterwards, in the app or through the API, it responds 409 draft_conflict and changes nothing: read it again and apply your changes on its current rev. Without rev, the last save wins.
curl -X PATCH "https://cordhq.app/api/v1/workflows/8f3c2a1e-5b7d-4e9a-9c6f-1d2e3f4a5b6c" \
     -H "Authorization: Bearer sk_test_tU..." \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: workflow-task-title" \
     -d '{ "rev": 0, "definicion": { "trigger": "quote.approved", "steps": [{ "id": "t001", "type": "action", "action": "create_task", "params": { "titulo": "Review {{folio}}" } }] } }'

It responds with the workflow, its new rev and an empty para_publicar.

Validate without saving

POST /api/v1/workflows/validar takes { "definicion": { … } } and checks it like the editor, without saving anything. If the definition belongs to a workflow that already exists, also send its workflow_id: that way a Run another workflow step is checked against it. Use it in your CI before you upload a workflow; a key with read access to workflows is enough.

curl -X POST "https://cordhq.app/api/v1/workflows/validar" \
     -H "Authorization: Bearer sk_test_tU..." \
     -H "Content-Type: application/json" \
     -d '{ "definicion": { "trigger": "quote.approved", "steps": [{ "id": "t001", "type": "action", "action": "enviar_fax", "params": {} }] } }'

There are two responses, and it’s worth telling them apart:

  • 200, with object: "workflow_validacion", publicable, para_publicar and definicion, the definition as Cord would save it. If publicable is false, the definition can be saved as a draft but can’t be published yet, and para_publicar says why.
  • 400 invalid_request if Cord wouldn’t save it as it is. issues lists each problem with its path in path and what’s wrong in message, and field is the path of the first one. Nothing was saved.
{
  "error": "definicion.steps.0.action: is not an action Cord knows.",
  "code": "invalid_request",
  "field": "definicion.steps.0.action",
  "issues": [
    { "path": "definicion.steps.0.action", "message": "is not an action Cord knows." }
  ]
}

The error and message texts come in English and don’t change with the caller’s language: decide by code and by each problem’s path. Creating and editing return the same 400 response when the definition can’t be saved as it is.

Publish

POST /api/v1/workflows/{id}/publicar takes the rev of the draft you reviewed and, optionally, a nota of up to 280 characters that says what changed and stays in the editor’s Versions tab. That revision is published or nothing is: if someone saved the draft afterwards, it responds 409 draft_conflict and doesn’t publish.

Publishing lends the workflow a person’s permissions: from then on it runs on its own and acts with them (see Which permissions it acts with). That’s why the API only publishes like this:

  • With an unrestricted test secret key (sk_test_), in your test environment.
  • With the authority of the person who created the key, if they’re still active in your real account and have the Settings permission. In the test environment, their permissions are the ones they have in your real account.
  • Without steps that person couldn’t do by hand. If one needs a permission they don’t have, it responds 403 insufficient_permission with issues, each with its path, its step_id and the missing permission. If the person can no longer publish workflows in your account, the same response comes without issues.

With any other credential it responds 403 publish_in_app: a live key, a restricted key (rk_, including the one from cord login), the token of an app connected with OAuth or the Workbench Shell. In your real account, a person publishes a workflow in Cord.

curl -X POST "https://cordhq.app/api/v1/workflows/8f3c2a1e-5b7d-4e9a-9c6f-1d2e3f4a5b6c/publicar" \
     -H "Authorization: Bearer sk_test_tU..." \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: publish-task-on-approval-1" \
     -d '{ "rev": 1, "nota": "First version" }'

It responds with the workflow with estado: "active", its new version and cambios_sin_publicar: false. The workflow starts with the next event; it doesn’t run on what already happened. Also:

  • If it can’t be published yet, it responds 422 invalid_workflow with issues: the same as para_publicar.
  • If the workflow wasn’t active and your plan doesn’t include more active workflows, it responds 402 plan_limit_reached. Publishing changes to one that already runs doesn’t take another slot.

In your real account

A workflow in your test environment doesn’t move to your real account on its own. To bring it over through the API, send its nombre and definicion to POST /api/v1/workflows with a live secret key, from your server or your CI: it arrives as a draft and doesn’t run until a person with the Settings permission publishes it in Workflows, in the app. With MCP, the agent can request it with publicar_workflow and a person approves it in Cord. A Run another workflow step names the id of another workflow, which is different in your real account: para_publicar flags it. In the app, Copy to the live account in the editor takes a workflow from the test environment to your live account as a draft and tells you what to check there (see Try it in the test environment and copy it to the live account); the API does not copy between accounts, because a test key never writes to your live account.

Run a You run it workflow

POST /api/v1/workflows/{id}/invoke runs an active You run it workflow on up to 50 quotes or invoices, with the published version and its rules. It takes objeto (quote or invoice, the document of its trigger) and ids.

curl -X POST "https://cordhq.app/api/v1/workflows/2b7e9d4c-1a6f-4c3e-8d5b-7f0a9e2c4d18/invoke" \
     -H "Authorization: Bearer sk_live_tU..." \
     -H "Content-Type: application/json" \
     -H "Idempotency-Key: collect-invoice-4f1a" \
     -d '{ "objeto": "invoice", "ids": ["4f1a9c2e-7b3d-4e8a-9c5f-2d6b1e0a3c74"] }'

It responds { "data": { "ok": true, "documentos": 1, "corridas": 1 } }: how many of the ids are documents in your account and how many runs started. A document that doesn’t meet the workflow’s filter, or that already entered before, doesn’t count in corridas. If the workflow isn’t active or isn’t a You run it one for that object, it responds 409 invalid_state.

From the CLI

From version 2.4.0, the Cord CLI downloads and uploads the workflows of your test environment as JSON files, so you can keep them in your repository and check them in your CI.

cord workflows pull --dir workflows
cord workflows validar workflows
cord workflows push workflows/task-on-approval.json
  • pull writes one file per workflow to ./workflows, or to the --dir folder. If there’s already a file with the same id, it rewrites it.
  • validar checks a file or every .json in a folder like POST /api/v1/workflows/validar, without saving anything, and exits with code 1 if any has something Cord wouldn’t save as it is or can’t be published yet.
  • push uploads each file as a draft: it updates the workflow whose file has an id and creates the rest, writes the new id and rev to the file and shows what’s still missing to publish it. It never publishes. If someone changed the draft in Cord after your last pull, that file fails with draft_conflict: run pull and apply your changes again.
  • push and validar list each point with its path, move on to the next file and exit with code 1 if any failed. With --json, each command prints {"type":"workflows_pull",…}, {"type":"workflows_push",…} or {"type":"workflows_validar",…} with the result of each file.

Each file carries id, nombre, rev and definicion:

{
  "id": "8f3c2a1e-5b7d-4e9a-9c6f-1d2e3f4a5b6c",
  "nombre": "Task on approval",
  "rev": 1,
  "definicion": {
    "trigger": "quote.approved",
    "steps": [
      { "id": "t001", "type": "action", "action": "create_task", "params": { "titulo": "Review {{folio}}" } }
    ]
  }
}

cord sandbox reset deletes the workflows of your test environment: after a reset, remove id and rev from your files so push creates them again. A cord login key from before version 2.4.0 doesn’t have the workflows permission: run cord login again.

From the SDKs

The server SDKs have the workflows resource, with the same fields as the API:

SDK Methods
Node (@flouviahq/node, from 1.6.0) cord.workflows.list, create, retrieve, update, validate and publish, plus invoke
Python (cord-sdk, from 1.4.0) cord.workflows.list, create, retrieve, update, validate and publish, plus invoke, also in AsyncCord
PHP (flouviahq/cord, from 1.4.0) $cord->workflows->list, create, retrieve, update, validate and publish, plus invoke

A definition Cord wouldn’t save as it is comes back as an invalid_request error with its issues, and draft_conflict, publish_in_app and invalid_workflow come back with their code. See Node SDK.

import { Cord, CordError } from '@flouviahq/node';

const cord = new Cord(process.env.CORD_SECRET_KEY!);

const definicion = {
  trigger: 'quote.approved',
  steps: [{ id: 't001', type: 'action', action: 'create_task', params: { titulo: 'Review {{folio}}' } }],
};

const workflow = await cord.workflows.create({ nombre: 'Task on approval', definicion });
if (workflow.para_publicar.length === 0) {
  try {
    await cord.workflows.publish(workflow.id, { rev: workflow.rev, nota: 'First version' });
  } catch (err) {
    if (err instanceof CordError && err.code === 'draft_conflict') {
      // Someone saved the draft afterwards: read it again with retrieve().
    } else throw err;
  }
}
import os
from cord import Cord

cord = Cord(os.environ["CORD_SECRET_KEY"])

definicion = {
    "trigger": "quote.approved",
    "steps": [{"id": "t001", "type": "action", "action": "create_task", "params": {"titulo": "Review {{folio}}"}}],
}

validacion = cord.workflows.validate(definicion)
for punto in validacion["para_publicar"]:
    print(punto["path"], punto["message"])

workflow = cord.workflows.create("Task on approval", definicion)
if validacion["publicable"]:
    cord.workflows.publish(workflow["id"], workflow["rev"], nota="First version")
use Flouvia\Cord\Cord;

$cord = new Cord(getenv('CORD_SECRET_KEY'));

$definicion = [
    'trigger' => 'quote.approved',
    'steps' => [['id' => 't001', 'type' => 'action', 'action' => 'create_task', 'params' => ['titulo' => 'Review {{folio}}']]],
];

$workflow = $cord->workflows->create('Task on approval', $definicion);
$workflow = $cord->workflows->update($workflow['id'], ['nombre' => 'Task when a quote is approved', 'rev' => $workflow['rev']]);
if ($workflow['para_publicar'] === []) {
    $cord->workflows->publish($workflow['id'], $workflow['rev'], 'First version');
}

publish follows the rules in Publish: with an unrestricted sk_test_ it publishes in your test environment, and in live mode it throws publish_in_app.

From MCP

The Cord MCP server has five tools to build workflows. The agent creates and edits drafts; a person decides what gets published.

Tool What it does Group and resource
listar_workflows Lists your workflows: id, nombre, estado, the draft’s trigger, the published version, the draft’s rev and whether it has unpublished changes. Read, workflows
detalle_workflow A workflow with its draft, the version that runs, its rev and para_publicar. Read, workflows
crear_workflow_borrador Creates a draft workflow with its name and definition. It never publishes it or runs anything. Draft writes, workflows
editar_workflow_borrador Changes the name or the draft; with the rev it read, it doesn’t overwrite another person’s changes. What runs doesn’t change. Draft writes, workflows
publicar_workflow Asks to publish revision rev of the draft. Waits for approval. Actions with external effects, workflows

publicar_workflow doesn’t publish when the agent calls it: it leaves a request in Settings › MCP › Requests (see Actions that wait for approval). It can only be requested with the draft’s current rev and once the draft can be published. A person with the Settings permission approves it, seeing the workflow and the requested revision, and the workflow runs with that person’s permissions. If the draft changed after the request, approving it publishes nothing. As in the API, anything Cord wouldn’t save as it is gets rejected with the path of each problem.

Permissions and errors

A restricted key needs the workflows resource: Read to list, retrieve and validate, and Write to create, edit and run a workflow. Publishing also needs an unrestricted test secret key (see Publish). The cord login key already includes workflows.

Code Status When
invalid_request 400 A field isn’t valid, rev is missing when publishing or the definition has something Cord wouldn’t save as it is.
plan_limit_reached 402 Your plan doesn’t include more active workflows.
insufficient_permissions 403 The restricted key has no permission on workflows.
publish_in_app 403 You tried to publish with a key that isn’t an unrestricted sk_test_.
insufficient_permission 403 The person who created the key can no longer publish workflows, or a step needs a permission they don’t have.
not_found 404 The workflow doesn’t exist or belongs to another account.
draft_conflict 409 The draft changed after the rev you sent.
invalid_state 409 When running it with invoke, the workflow isn’t active or isn’t a You run it one for that object.
invalid_workflow 422 The draft can’t be published yet.
rate_limited 429 Your organization already made 60 workflow changes in the last minute (create, edit or publish).