> ## 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.

# Create Workflow

> Create a private workflow scoped to a linked account.

Create a workflow scoped to a linked account. If you don't supply `associated_application` or `slug`, the workflow is attached to the org's default custom application. The new workflow starts as an unpublished draft with a single start node — build it out, then [publish](/legacy/api-reference/workflows/publish-workflow) it.

<Note>
  Because this call authenticates as a linked account (API key + `linked_account_id`, or a session token), it creates a **private workflow** — one that belongs to that specific linked account. **Public workflows** are org-level and tied to application slugs; they are not created through this endpoint.
</Note>

## Authentication

This endpoint is scoped to a linked account, 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 to scope the workflow to.</ParamField>

**Option 2 — Session token**

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

## Body Parameters

<ParamField body="name" type="string">Workflow name.</ParamField>
<ParamField body="slug" type="string">Application slug to associate. Defaults to the org's default custom app.</ParamField>
<ParamField body="associated_application" type="string">Application ID to associate (alternative to `slug`).</ParamField>

## Response

<Tabs>
  <Tab title="200 OK">
    <ResponseField name="workflow" type="object">
      The created workflow.

      <Expandable title="properties">
        <ResponseField name="_id" type="string">The **draft** workflow ID — pass this to [Publish Workflow](/legacy/api-reference/workflows/publish-workflow). Publishing returns a separate published ID.</ResponseField>
        <ResponseField name="name" type="string">Workflow name.</ResponseField>
        <ResponseField name="nodes" type="array">Initial nodes (a `start` node).</ResponseField>
        <ResponseField name="published" type="boolean">`false` for a new draft.</ResponseField>
      </Expandable>
    </ResponseField>
  </Tab>

  <Tab title="401 Unauthorized">
    <ResponseField name="status_code" type="integer">HTTP status code.</ResponseField>
    <ResponseField name="http_error_type" type="string">Error category.</ResponseField>
    <ResponseField name="error" type="string">Internal error code.</ResponseField>
    <ResponseField name="message" type="string">Human-readable error description.</ResponseField>
  </Tab>
</Tabs>

<ResponseExample>
  ```json 200 theme={null}
  {
    "workflow": {
      "_id": "6a31545ed0aeb8165beb9a43",
      "name": "Lead Sync",
      "org_id": "6500a1b2c3d4e5f6a7b8c9d0",
      "nodes": [
        { "id": "1", "type": "start", "incoming_nodes": [], "outgoing_nodes": [], "data": null }
      ],
      "createdAt": "2026-06-16T13:49:18.390Z",
      "updatedAt": "2026-06-16T13:49:18.390Z"
    }
  }
  ```

  ```json 401 theme={null}
  {
    "status_code": 401,
    "http_error_type": "UNAUTHORIZED",
    "error": "SERVER_ERROR",
    "message": "Invalid Credentials"
  }
  ```
</ResponseExample>

<RequestExample>
  ```bash cURL (API key) theme={null}
  curl -X POST "https://app.refold.ai/api/v2/public/workflow" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "linked_account_id: YOUR_LINKED_ACCOUNT_ID" \
    -H "Content-Type: application/json" \
    -d '{ "name": "Lead Sync", "slug": "hubspot" }'
  ```

  ```bash cURL (session token) theme={null}
  curl -X POST "https://app.refold.ai/api/v2/public/workflow" \
    -H "Authorization: Bearer YOUR_SESSION_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{ "name": "Lead Sync" }'
  ```
</RequestExample>
