> ## Documentation Index
> Fetch the complete documentation index at: https://cobalt-55-abhishek.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Execute Workflow

> Execute a published workflow for a linked account.

Execute a workflow for a linked account via a manual trigger. The workflow must be **published** and owned by the linked account. Execution is asynchronous by default; set the `sync_execution` header to run synchronously and return the result inline.

<Note>
  The **`slug` header is required** — it names the application the workflow belongs to. Without it the call fails with `Workflow ID and slug are required`.
</Note>

## Authentication

This endpoint is scoped to a linked account (it runs that account's private workflow), so it accepts **either** authentication method.

**Option 1 — API key**

<ParamField header="x-api-key" type="string">Your Refold API key.</ParamField>
<ParamField header="linked_account_id" type="string">The linked account that owns the workflow.</ParamField>

**Option 2 — Session token**

<ParamField header="Authorization" type="string">Session token. **Format:** `Bearer YOUR_SESSION_TOKEN`</ParamField>

## Path Parameters

<ParamField path="workflow_id" type="string" required>
  The **published** workflow ID (from [List Workflows](/legacy/api-reference/workflows/list-workflows)). The workflow must be published before it can be executed.
</ParamField>

## Headers

<ParamField header="slug" type="string" required>The application slug the workflow belongs to.</ParamField>
<ParamField header="config_id" type="string">Config to scope execution to. Defaults to the linked account ID.</ParamField>
<ParamField header="sync_execution" type="boolean">Run synchronously and return the result inline.</ParamField>
<ParamField header="instance_tag" type="string">Tag to label the resulting execution.</ParamField>
<ParamField header="include-headers" type="boolean">Return sanitized request headers in the response.</ParamField>

## Body Parameters

<ParamField body="payload" type="object">
  The execution input, matching the workflow's [request structure](/legacy/api-reference/workflows/request-structure).
</ParamField>

## Response

<Tabs>
  <Tab title="200 OK">
    Returns the execution result. For async runs this is an acknowledgement with the execution reference; for sync runs it includes the workflow output.
  </Tab>

  <Tab title="400 Bad Request">
    Returned when the `slug` is missing, or the workflow is unpublished / not owned by the linked account.
    <ResponseField name="message" type="string">Error message, e.g. `Workflow ID and slug are required`.</ResponseField>
    <ResponseField name="error" type="string">Error detail.</ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 theme={null}
  {
    "message": "Workflow execution started",
    "execution_id": "6a314c54d4616e99e7fa5a02"
  }
  ```

  ```json 400 theme={null}
  {
    "message": "Server Error",
    "error": "Workflow ID and slug are required"
  }
  ```
</ResponseExample>

<RequestExample>
  ```bash cURL (API key) theme={null}
  curl -X POST "https://app.refold.ai/api/v2/public/workflow/{workflow_id}/execute" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "slug: {slug}" \
    -H "Content-Type: application/json" \
    -d '{ "payload": { "email": "jane@example.com" } }'
  ```

  ```bash cURL (session token, sync) theme={null}
  curl -X POST "https://app.refold.ai/api/v2/public/workflow/{workflow_id}/execute" \
    -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
    -H "slug: {slug}" \
    -H "sync_execution: true" \
    -H "Content-Type: application/json" \
    -d '{ "payload": {} }'
  ```
</RequestExample>
