# Run workflow (/api/run-workflow)

**POST** `/v1/workflows/{id}/run`

Starts a **run** of an active workflow whose trigger is configured for external calls. trumpet accepts the request immediately and executes steps asynchronously. The response contains a **dispatch** id so you can correlate the run — it does not include per-step results.

<Callout type="idea" title="Beyond the REST API">
The Public API reference pages mostly cover **resource operations** — creating and updating Pods, listing statuses, and similar calls. **Workflows** are a separate automation layer: you design triggers, steps, branches, enrollment, and input mappings in the trumpet builder, then start runs from CRM events, in-app signals, or this endpoint. See [Workflows](/workflows/overview).
</Callout>

<Callout type="info" title="API key">
Use a brand API key in the `Authorization: Bearer` header. See [Authentication](/api/authentication) for format and key management.
</Callout>

<Callout type="info" title="Before you call this endpoint">
The workflow must be **active** and set up in trumpet to accept external runs. Publish it in the builder first, then pass a `data` object that matches what that workflow expects.
</Callout>

## Path parameters [#path-parameters]

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `id` | string | **Required** | The workflow ID (MongoDB ObjectId), e.g. from the workflow URL in the trumpet dashboard. |

## Body parameters [#body-parameters]

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `data` | object | **Required** | Payload passed into the workflow. Keys must match the fields your workflow is configured to accept. Values are validated before a dispatch is created. |

## Example request [#example-request]

<CodeBlockTabs defaultValue="curl">
<CodeBlockTabsList>
<CodeBlockTabsTrigger value="curl">
cURL
</CodeBlockTabsTrigger>

<CodeBlockTabsTrigger value="javascript">
JavaScript
</CodeBlockTabsTrigger>

<CodeBlockTabsTrigger value="python">
Python
</CodeBlockTabsTrigger>
</CodeBlockTabsList>

<CodeBlockTab value="curl">
```bash
curl -X POST https://trumpet.app/api/v1/workflows/69f0bafc4cc54b506b0355d8/run \
  -H "Authorization: Bearer trpt_a1b2c3_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "dealId": "12345",
      "ownerEmail": "alice@yourcompany.com"
    }
  }'
```
</CodeBlockTab>

<CodeBlockTab value="javascript">
```javascript
const workflowId = "69f0bafc4cc54b506b0355d8";

const response = await fetch(
  `https://trumpet.app/api/v1/workflows/${workflowId}/run`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.TRUMPET_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      data: {
        dealId: "12345",
        ownerEmail: "alice@yourcompany.com",
      },
    }),
  },
);

const { success, data } = await response.json();
```
</CodeBlockTab>

<CodeBlockTab value="python">
```python
import os
import requests

workflow_id = "69f0bafc4cc54b506b0355d8"

response = requests.post(
    f"https://trumpet.app/api/v1/workflows/{workflow_id}/run",
    headers={
        "Authorization": f"Bearer {os.environ['TRUMPET_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "data": {
            "dealId": "12345",
            "ownerEmail": "alice@yourcompany.com",
        },
    },
)

data = response.json()
```
</CodeBlockTab>
</CodeBlockTabs>

Replace `dealId` and `ownerEmail` with fields your workflow declares on its trigger. Omitted required fields are rejected before a run starts.

The request body does **not** choose which trumpet user runs the workflow. **Enrollment** on the workflow does. See [Enrollment](/workflows/enrollment) for audience types, owner-matching on integration triggers, and service-account patterns.

## Success response [#success-response]

Returns **`202 Accepted`** when the dispatch is queued:

```json
{
  "success": true,
  "data": {
    "dispatchId": "69f0bafc4cc54b506b0355e2",
    "workflowId": "69f0bafc4cc54b506b0355d8",
    "status": "pending",
    "enrolledUserCount": 1,
    "createdAt": "2026-11-24T10:15:30.000Z"
  }
}
```

The run continues in the background. Configure notifications and run history in trumpet if you need to track outcomes beyond this response.

## Error responses [#error-responses]

| Status | Error | Cause |
|--------|-------|-------|
| `400` | Invalid workflow ID format | The `id` path segment is not a valid ObjectId. |
| `400` | Validation error | Request body failed schema validation (for example missing `data` or wrong shape). |
| `400` | Workflow is not fully configured | The workflow is missing a trigger or has configuration errors. |
| `400` | Workflow contains steps that cannot be run via API yet | One or more steps are not supported for API dispatch. |
| `400` | Workflow contains steps that are not available for this workspace | A step is disabled or unavailable for your brand. |
| `400` | Invalid trigger data | `data` does not match the trigger's declared inputs (message describes the field). |
| `401` | Invalid or revoked API key | Missing, malformed, revoked, or deleted key. |
| `404` | Workflow not found | No **active** workflow with that id exists for your brand, or it cannot be started through this endpoint. |
| `422` | Workflow enrollment is not configured | Enrollment is required before a run can start. |
| `429` | Rate limit exceeded | More than 30 requests per minute for this key. Retry after a short delay. |

<Callout type="warn" title="Runs are asynchronous">
A `202` response only means the dispatch was accepted. Step failures after that do not change the HTTP status of this request. Use workflow history in trumpet, configured completion webhooks, or downstream logging to observe outcomes.
</Callout>

## Related [#related]

<Cards>
<Card title="Workflows overview" href="/workflows/overview">
Triggers, steps, catalog, and how automation fits together.
</Card>

<Card title="Enrollment" href="/workflows/enrollment">
Who receives a run and how fan-out works.
</Card>

<Card title="Workflow catalog" href="/workflows/overview">
Trigger and step reference for building workflows.
</Card>

<Card title="Getting Started" href="/api/getting-started">
API keys and your first Pod request.
</Card>

<Card title="Webhooks" href="/webhooks">
Real-time Pod and engagement events (separate from workflow runs).
</Card>
</Cards>