Create a workflow as a draft
POST /workflows
/workflowsCreates a workflow of the new automation engine as an unpublished DRAFT, blank or with its whole document in definition, and answers it as get_workflow reads it plus validation: the review of the saved draft, with what is still missing or wrong to publish it and a hint for each issue.
When to use: To build a new automation of the CRM or of marketing (a trigger, waits, conditions, branches and steps). Send the title and the whole document in one call; then fix what validation lists with update_workflow until publishable is true.
When not to use: To change a workflow that already exists use update_workflow: look for it with list_workflows before creating a second one with the same purpose. Classic automations of an audience are create_automation; email sequences are create_email_sequence.
Side effects: The workflow appears in Easymailing › Automations as a draft, with the person who owns the key or token as its responsible. Nothing is published, nobody enters it and nothing is sent or changed: the draft may be incomplete. A document that has not the shape of format 3 creates nothing (422 validation_failed). A failure after creating (a secret header of «Send webhook» that is not valid, for example) leaves the workflow created and blank, and the error carries its workflow_uuid: fix it with update_workflow, never create another.
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). Every uuid is yours to choose (UUID v4, unique in the document). 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.
Value for the X-Auth-Token header parameter.
In: header
The new 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
curl -X POST "https://api.easymailing.com/workflows" \ -H "X-Auth-Token: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "title": "string", "definition": {} }'{ "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" } ] }}