Easymailing
Workflows

Save the draft of a workflow

PUT /workflows/{uuid}

PUT/workflows/{uuid}

Replaces the whole DRAFT of a workflow with the document in definition (and its name, if title is sent), provided nobody saved it since expected_draft_version, and answers the workflow as get_workflow reads it plus validation: the review of the saved draft. It never changes the published version nor what is running.

When to use: To fix what validation listed after create_workflow, or to change a workflow: read it with get_workflow, change its definition and send the whole document with its draft_version as expected_draft_version.

When not to use: To create a workflow use create_workflow. It does not merge: a trigger or node that is not sent is removed from the draft. Saving does not publish: the published version keeps running until the draft is published with publish_workflow.

Side effects: Saves the draft and its name; draft_version grows by one. Nothing is published, nobody enters or leaves the workflow and nothing is sent or changed: the draft may be incomplete. Secret header values of «Send webhook» are returned as null; send them as null to keep the stored secret.

About definition: The same document get_workflow returns in definition, with its keys in camelCase (it is a declarative document, not API fields): formatVersion 3, settings, triggers and nodes in reading order. The pieces that exist (catalogId) are in list_workflow_pieces; how each piece is configured, with an example of each, is in the automation_workflows_guide guide of the MCP (get_guide). The hint of each issue in validation says what to fix.

Permissions: Requires the automations.work capability. The account must also have a plan with CRM. Writing the value of a secret header of «Send webhook» also needs automations.manage.

Authorization

X-Auth-Token<token>

Value for the X-Auth-Token header parameter.

In: header

Path Parameters

uuid*string

UUID of the workflow. Get it from list_workflows or from the answer of create_workflow.

Formatuuid

Request Body

The updated Workflow resource

TypeScript Definitions

Use the request body type in TypeScript.

Workflows of the new automation engine in the public API (F7, task B4; writes since the plan «flujos en la API pública», T7 and T8). It reads them (list_workflows, get_workflow), creates them and saves their draft (create_workflow, update_workflow) and runs their lifecycle (publish_workflow, pause_workflow, resume_workflow, set_workflow_entry_state, delete_workflow), so that an external client or an AI, through the public MCP, can build, publish and run a workflow end to end; the review of the draft is {@see WorkflowValidationResource}. Each provider or processor checks its capability before the use case ({@see \App\Application\Automation\ApiWorkflowAccess}: automations.read to read, automations.work to create and save, automations.manage for the lifecycle, as in the internal API), because API Platform evaluates security after the provider; the rules, the visibility, CRM in the plan, the plan limit of automations and the audit (origin api) are those of the CoreBundle use cases the internal API and Maia run (Service\App\Automation\Workflows).

The list gives the summary (with the execution counts); get_workflow the whole workflow with its draft (definition, the format 3 document as stored, in camelCase like the internal API: it is a declarative document, not API fields), the triggers of the published version, the versions and the responsible. Creating and saving answer the same workflow plus validation (the review of the saved draft) and neither publishes nor starts anything. Publishing has no confirmation step (decision of Sergio: an external API does not treat an AI differently): its side effects are explained in its description, as in automation_activate. The lifecycle operations answer the workflow as get_workflow reads it, and delete_workflow nothing (204). A workflow that the account does not have is 404 workflow_not_found.

Response Body

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X PUT "https://api.easymailing.com/workflows/3f6c2a1e-8b4d-4c7a-9e10-5d2b7a9c4e61" \  -H "X-Auth-Token: YOUR_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "expected_draft_version": 1,    "definition": {},    "title": "string"  }'
{  "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",  "title": "string",  "status": "draft",  "published_revision": 0,  "unpublished_changes": true,  "trigger_catalog_ids": [    "string"  ],  "entries_open": true,  "paused_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z",  "updated_by": "deea00dc-b6b6-4412-a483-26ac61e1f6fe",  "draft_version": 1,  "definition": {},  "triggers": [    {      "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",      "entry_state": "open",      "published_since_revision": 1    }  ],  "versions": [    {      "revision": 1,      "published_at": "2019-08-24T14:15:22Z",      "published_by": "9ac9eee7-2153-423d-b22d-04e12679154a",      "node_count": 0    }  ],  "resuming": true,  "responsible": {    "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",    "name": "string",    "email": "string",    "can_act": true  },  "validation": {    "workflow_uuid": "5f472623-08f6-4789-89f2-effc00ed9ea8",    "draft_version": 1,    "publishable": true,    "counts": {      "incomplete": 0,      "error": 0,      "warning": 0    },    "issues": [      {        "node_uuid": "196b4b43-66dc-4630-bc74-d193c349e248",        "catalog_id": "string",        "field": "string",        "code": "missing_trigger",        "severity": "incomplete",        "hint": "string"      }    ]  }}