> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hookpulse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Workflow Template

> Create a new workflow template with FIFO or concurrent execution mode

Create a new workflow template with FIFO (First-In-First-Out) or concurrent execution mode. This endpoint creates the initial workflow structure; webhooks can be added to the workflow later using other APIs.

## Base URL

All API requests should be made to:

```
https://api.hookpulse.io
```

## Example request

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.hookpulse.io/v1/api/add_workflow_template/ \
    -H "x-hookpulse-api-key: {{x-hookpulse-api-key}}" \
    -H "x-brand-uuid: {{x-brand-uuid}}" \
    -H "Content-Type: application/json" \
    -d '{
      "workflow_name": "{{workflow_name}}",
      "workflow_description": "{{workflow_description}}",
      "runtype": "{{runtype}}"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.hookpulse.io/v1/api/add_workflow_template/', {
    method: 'POST',
    headers: {
      'x-hookpulse-api-key': '{{x-hookpulse-api-key}}',
      'x-brand-uuid': '{{x-brand-uuid}}',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      workflow_name: '{{workflow_name}}',
      workflow_description: '{{workflow_description}}',
      runtype: '{{runtype}}'
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  url = 'https://api.hookpulse.io/v1/api/add_workflow_template/'
  headers = {
      'x-hookpulse-api-key': '{{x-hookpulse-api-key}}',
      'x-brand-uuid': '{{x-brand-uuid}}',
      'Content-Type': 'application/json'
  }
  payload = {
      'workflow_name': '{{workflow_name}}',
      'workflow_description': '{{workflow_description}}',
      'runtype': '{{runtype}}'
  }

  response = requests.post(url, headers=headers, json=payload)
  print(response.json())
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  uri = URI('https://api.hookpulse.io/v1/api/add_workflow_template/')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri.path)
  request['x-hookpulse-api-key'] = '{{x-hookpulse-api-key}}'
  request['x-brand-uuid'] = '{{x-brand-uuid}}'
  request['Content-Type'] = 'application/json'
  request.body = {
    workflow_name: '{{workflow_name}}',
    workflow_description: '{{workflow_description}}',
    runtype: '{{runtype}}'
  }.to_json

  response = http.request(request)
  puts JSON.parse(response.body)
  ```

  ```php PHP theme={null}
  <?php

  $url = 'https://api.hookpulse.io/v1/api/add_workflow_template/';
  $data = [
      'workflow_name' => '{{workflow_name}}',
      'workflow_description' => '{{workflow_description}}',
      'runtype' => '{{runtype}}'
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      'x-hookpulse-api-key: {{x-hookpulse-api-key}}',
      'x-brand-uuid: {{x-brand-uuid}}',
      'Content-Type: application/json'
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  echo $response;
  ?>
  ```
</RequestExample>

## Request body

| Field                  | Type   | Required | Description                                                                                                 |
| ---------------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| `workflow_name`        | string | Yes      | Name of the workflow template                                                                               |
| `workflow_description` | string | Yes      | Description of the workflow template                                                                        |
| `runtype`              | string | Yes      | Execution mode: `"fifo_sequential"` for strict sequential order, or `"concurrently"` for parallel execution |

## Execution Modes

### FIFO Sequential Mode (`fifo_sequential`)

FIFO (First-In-First-Out) mode ensures steps execute in strict sequential order:

* **Guaranteed Order**: Steps execute one after another, in the exact order defined
* **Dependency Support**: Later steps can safely access variables from earlier steps using `{{ step.response.variable }}` and `{{ initial.variable }}`
* **Data Consistency**: Ensures data flows correctly through the workflow
* **Full Variable Support**: All template variables are available:
  * `{{ #key }}` - System secrets
  * `{{ variable }}` - Workflow variables
  * `{{ step.response.variable }}` - Previous step responses
  * `{{ initial.variable }}` - Initial workflow input

**Use Cases:**

* Payment processing workflows
* Data transformation pipelines
* Sequential API calls with dependencies
* Multi-step user onboarding

### Concurrent Mode (`concurrently`)

Concurrent mode allows multiple steps to execute simultaneously:

* **Parallel Execution**: Multiple steps run in parallel, reducing total execution time
* **Independent Operations**: Ideal when steps don't depend on each other
* **Limited Variable Support**: In concurrent mode, only system variables are evaluated:
  * ✅ `{{ #key }}` - System secrets (available)
  * ❌ `{{ variable }}` - Workflow variables (not available)
  * ❌ `{{ step.response.variable }}` - Previous step responses (not available)
  * ❌ `{{ initial.variable }}` - Initial workflow input (not available)

**Note**: The limitation exists because steps execute simultaneously, so there's no guarantee of execution order or availability of previous step data.

**Use Cases:**

* Sending notifications to multiple services simultaneously
* Parallel data processing
* Independent API calls
* Bulk operations

## Example response

<ResponseExample>
  ### Success Response

  ```json theme={null}
  {
    "success": true,
    "details": "Webhook Template added",
    "workflow_uuid": "{{workflow_uuid}}"
  }
  ```

  ### Error Response

  ```json theme={null}
  {
    "error": "Workflow with same name already registered",
    "success": false,
    "workflow_uuid": "{{workflow_uuid}}"
  }
  ```
</ResponseExample>

## Response fields

| Field           | Type    | Description                                                                   |
| --------------- | ------- | ----------------------------------------------------------------------------- |
| `success`       | boolean | Indicates if the request was successful                                       |
| `details`       | string  | Success message (only present on success)                                     |
| `workflow_uuid` | string  | Unique identifier for the created workflow template (only present on success) |
| `error`         | string  | Error message (only present on error)                                         |
| `workflow_uuid` | string  | UUID of the existing workflow with the same name (only present on error)      |

## Next Steps

After creating a workflow template, you can:

1. **Add Webhooks**: Use workflow-specific APIs to add webhook steps to your workflow
2. **Configure Failure Handling**: Set up failure handling and retry strategies
3. **Add Execution Conditions**: Configure step conditions for conditional execution
4. **Schedule Workflows**: Set up scheduling to run workflows automatically

## Related Documentation

* [Workflow Template Overview](/docs/api-reference/workflow-template/overview) - Learn about workflow templates, execution modes, and features
* [Webhook Template Overview](/docs/api-reference/webhook-template/overview) - Understand webhook templates that can be used in workflows
* [System Secret Vault Overview](/docs/api-reference/system-secret-vault/overview) - Manage secrets for use in workflows


## OpenAPI

````yaml POST /v1/api/add_workflow_template/
openapi: 3.0.3
info:
  title: Hookpulse API
  description: >-
    Complete API documentation for Hookpulse. Build powerful integrations with
    our RESTful API.
  version: 1.0.0
  contact:
    name: Hookpulse Support
    email: care@hookpulse.io
    url: https://hookpulse.io
servers:
  - url: https://api.hookpulse.io
    description: Production server
security:
  - apiKeyAuth: []
    brandUuidAuth: []
paths:
  /v1/api/add_workflow_template/:
    post:
      description: Create a new workflow template with FIFO or concurrent execution mode
      requestBody:
        description: Workflow template configuration
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddWorkflowTemplateRequest'
      responses:
        '200':
          description: Workflow template created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddWorkflowTemplateResponse'
        '400':
          description: Bad request (e.g., workflow with same name already exists)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddWorkflowTemplateErrorResponse'
components:
  schemas:
    AddWorkflowTemplateRequest:
      required:
        - workflow_name
        - workflow_description
        - runtype
      type: object
      properties:
        workflow_name:
          type: string
          description: Name of the workflow template
        workflow_description:
          type: string
          description: Description of the workflow template
        runtype:
          type: string
          enum:
            - fifo_sequential
            - concurrently
          description: >-
            Execution mode: 'fifo_sequential' for strict sequential order,
            'concurrently' for parallel execution (note: in concurrent mode,
            only system variables are evaluated; initial.variable, response, and
            header variables are not available)
    AddWorkflowTemplateResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates if the request was successful
        details:
          type: string
          description: Success message
        workflow_uuid:
          type: string
          description: Unique identifier for the created workflow template
    AddWorkflowTemplateErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error message
        success:
          type: boolean
          description: Indicates if the request was successful (false in error case)
        workflow_uuid:
          type: string
          description: UUID of the existing workflow with the same name
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-hookpulse-api-key
      description: >-
        API key for authentication. Get this from your dashboard by selecting a
        brand and going to API Keys section.
    brandUuidAuth:
      type: apiKey
      in: header
      name: x-brand-uuid
      description: >-
        Brand UUID for authentication. Get this from your dashboard after adding
        a brand - it will be displayed in the UI.

````