# MyWorkflowAPI > Automate actions from webhook triggers via API Base URL: https://api.myworkflowapi.com Authentication: `Authorization: Bearer ` # MyWorkflowAPI Webhook-triggered workflow automation. Define a sequence of steps that fire when a webhook payload arrives. Steps support `{{payload.field}}` variable interpolation and retry automatically on failure. ## How it works 1. Create a webhook endpoint via mywebhookapi.com — note the `endpoint_id`. 2. `POST /workflow/workflows` with `trigger_config: { "endpoint_id": "" }` and a `steps` array. 3. `POST /workflow/workflows/{id}/enable`. 4. Any payload POSTed to the webhook URL will now trigger the workflow steps in sequence. ## Step types ### send_email `from` must be a mailbox created and sending-activated via my-email-api. Using an arbitrary address will silently fail. ```json { "type": "send_email", "from": "hello@yourdomain.com", "to": "{{payload.email}}", "subject": "Welcome {{payload.name}}", "template_id": "" } ``` ### slack_message ```json { "type": "slack_message", "webhook_url": "https://hooks.slack.com/services/...", "text": "New lead: {{payload.name}} — {{payload.email}}" } ``` ## Retry behaviour Attempt 1: immediate. Attempt 2: after 30s. Attempt 3: after 5min. After 3 failures the run is marked `failed`. ## Key endpoints - `POST /workflow/workflows` — create (requires `org_id`, `name`, `trigger_config.endpoint_id`, `steps`) - `GET /workflow/workflows` — list workflows - `GET /workflow/workflows/{id}` — get a workflow - `PATCH /workflow/workflows/{id}` — update name, trigger_config, or replace steps array - `DELETE /workflow/workflows/{id}` — delete (204 No Content) - `POST /workflow/workflows/{id}/enable` / `disable` - `GET /workflow/workflows/{id}/runs` — last 100 runs, newest first — use this to debug - `GET /workflow/runs/{id}` — inspect a single run ## Agent Onboarding To use this or any other MyAPIHQ service as an autonomous agent, follow these steps: 1. **Register an Agent Account**: Create an agent account. Returns `account_id`, `pin`, and a `token` (JWT) in one call — no email or human required. ```bash curl -X POST https://api.myapihq.com/hq/account/agent/create \ -H "Content-Type: application/json" \ -d '{"label": "my-agent"}' ``` 2. **Create a Permanent API Key**: Use the `token` from step 1 to create a workspace-scoped API key (`hq_live_...`). ```bash curl -X POST https://api.myapihq.com/hq/account/create/key \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{"name": "my-agent-key"}' ``` 3. **Authenticate**: All subsequent requests must include: `Authorization: Bearer `. The JWT token from step 1 is valid for account and billing endpoints only. All service calls (orgs, funnels, email, domains) require the API key from step 2. ## Endpoints ### POST /workflow/workflows **Create a workflow** Create a workflow with a webhook trigger and a sequence of steps. Step configs support `{{payload.field}}` variable interpolation. **Request Body (JSON):** ```json { "org_id": string (Required), "name": string (Required), "trigger_config": { "endpoint_id": string (Required) } (Required), "steps": Array<{ "type": string (send_email|slack_message), "from": string - (send_email) Must be an activated mailbox from my-email-api., "to": string - (send_email) Supports `{{payload.email}}`, "subject": string - (send_email) Supports `{{payload.name}}`, "template_id": string - (send_email) UUID of a stored email template. Takes priority over html., "html": string - (send_email) Inline HTML fallback., "webhook_url": string - (slack_message) Slack incoming webhook URL., "text": string - (slack_message) Message body. Supports `{{payload.field}}` interpolation. }> (Required) } ``` **Response (JSON):** ```json [Ref: Workflow] ``` --- ### GET /workflow/workflows **List workflows** **Response (JSON):** ```json Array<[Ref: Workflow]> ``` ### GET /workflow/workflows/{id} **Get a workflow** **Parameters:** - `id` (path): (type: string, Required) **Response (JSON):** ```json [Ref: Workflow] ``` --- ### PATCH /workflow/workflows/{id} **Update a workflow** Partially update a workflow. You can update `name`, `trigger_config`, or completely replace the `steps` array. **Parameters:** - `id` (path): (type: string, Required) **Request Body (JSON):** ```json { "name": string, "trigger_config": object, "steps": Array } ``` **Response (JSON):** ```json [Ref: Workflow] ``` --- ### DELETE /workflow/workflows/{id} **Delete a workflow** **Parameters:** - `id` (path): (type: string, Required) ### POST /workflow/workflows/{id}/enable **Enable a workflow** **Parameters:** - `id` (path): (type: string, Required) **Response:** Enabled ### POST /workflow/workflows/{id}/disable **Disable a workflow** **Parameters:** - `id` (path): (type: string, Required) **Response:** Disabled ### GET /workflow/workflows/{id}/runs **List runs for a workflow** Returns the last 100 runs ordered by newest first. Use this to debug execution — check `status`, `error`, and `attempt`. **Parameters:** - `id` (path): Workflow ID (type: string, Required) **Response (JSON):** ```json Array<[Ref: Run]> ``` ### GET /workflow/runs/{id} **Get a single run by ID** **Parameters:** - `id` (path): (type: string, Required) **Response (JSON):** ```json [Ref: Run] ``` ## Pricing Pay per use. No subscription. --- ## Ecosystem Integration This service is part of the MyAPIHQ ecosystem. You authenticate using an API Key generated from your MyAPIHQ account. To view the full list of available services (like domain registration, funnel building, transactional email, object storage, etc.), fetch [https://myapihq.com/llms.txt](https://myapihq.com/llms.txt).