> ## 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 Webhook Template

> Create a new webhook template with configurable retry logic, timeout settings, and template variable support

Create a new webhook template with configurable retry logic, timeout settings, and template variable support.

## 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_webhook_template/ \
    -H "x-hookpulse-api-key: {{x-hookpulse-api-key}}" \
    -H "x-brand-uuid: {{x-brand-uuid}}" \
    -H "Content-Type: application/json" \
    -d '{
      "webhook_name": "{{webhook_name}}",
      "webhook_description": "{{webhook_description}}",
      "method": "{{method}}",
      "path": "{{path}}",
      "domain_uuid": "{{domain_uuid}}",
      "retry_delay": {{retry_delay}},
      "retry_backoff_mode": "{{retry_backoff_mode}}",
      "max_retries": {{max_retries}},
      "request_timeout_in_milliseconds": {{request_timeout_in_milliseconds}},
      "request_body_json": {},
      "headers_json": {},
      "query_params_json": {}
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.hookpulse.io/v1/api/add_webhook_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({
      webhook_name: '{{webhook_name}}',
      webhook_description: '{{webhook_description}}',
      method: '{{method}}',
      path: '{{path}}',
      domain_uuid: '{{domain_uuid}}',
      retry_delay: {{retry_delay}},
      retry_backoff_mode: '{{retry_backoff_mode}}',
      max_retries: {{max_retries}},
      request_timeout_in_milliseconds: {{request_timeout_in_milliseconds}},
      request_body_json: {},
      headers_json: {},
      query_params_json: {}
    })
  });

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

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

  url = 'https://api.hookpulse.io/v1/api/add_webhook_template/'
  headers = {
      'x-hookpulse-api-key': '{{x-hookpulse-api-key}}',
      'x-brand-uuid': '{{x-brand-uuid}}',
      'Content-Type': 'application/json'
  }
  payload = {
      'webhook_name': '{{webhook_name}}',
      'webhook_description': '{{webhook_description}}',
      'method': '{{method}}',
      'path': '{{path}}',
      'domain_uuid': '{{domain_uuid}}',
      'retry_delay': {{retry_delay}},
      'retry_backoff_mode': '{{retry_backoff_mode}}',
      'max_retries': {{max_retries}},
      'request_timeout_in_milliseconds': {{request_timeout_in_milliseconds}},
      'request_body_json': {},
      'headers_json': {},
      'query_params_json': {}
  }

  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_webhook_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 = {
    webhook_name: '{{webhook_name}}',
    webhook_description: '{{webhook_description}}',
    method: '{{method}}',
    path: '{{path}}',
    domain_uuid: '{{domain_uuid}}',
    retry_delay: {{retry_delay}},
    retry_backoff_mode: '{{retry_backoff_mode}}',
    max_retries: {{max_retries}},
    request_timeout_in_milliseconds: {{request_timeout_in_milliseconds}},
    request_body_json: {},
    headers_json: {},
    query_params_json: {}
  }.to_json

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

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

  $url = 'https://api.hookpulse.io/v1/api/add_webhook_template/';
  $data = [
      'webhook_name' => '{{webhook_name}}',
      'webhook_description' => '{{webhook_description}}',
      'method' => '{{method}}',
      'path' => '{{path}}',
      'domain_uuid' => '{{domain_uuid}}',
      'retry_delay' => {{retry_delay}},
      'retry_backoff_mode' => '{{retry_backoff_mode}}',
      'max_retries' => {{max_retries}},
      'request_timeout_in_milliseconds' => {{request_timeout_in_milliseconds}},
      'request_body_json' => [],
      'headers_json' => [],
      'query_params_json' => []
  ];

  $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                                                                    |
| --------------------------------- | ------- | -------- | ------------------------------------------------------------------------------ |
| `webhook_name`                    | string  | Yes      | Name of the webhook template                                                   |
| `webhook_description`             | string  | Yes      | Description of the webhook template                                            |
| `method`                          | string  | Yes      | HTTP method. Allowed values: `"GET"`, `"POST"`, `"PUT"`, `"DELETE"`, `"PATCH"` |
| `path`                            | string  | Yes      | URL path for the webhook (e.g., "/hr/")                                        |
| `domain_uuid`                     | string  | Yes      | UUID of the domain associated with this webhook template                       |
| `retry_delay`                     | integer | Yes      | Delay in seconds between retry attempts                                        |
| `retry_backoff_mode`              | string  | Yes      | Retry backoff strategy: "linear" or "exponential"                              |
| `max_retries`                     | integer | Yes      | Maximum number of retry attempts                                               |
| `request_timeout_in_milliseconds` | integer | Yes      | Request timeout in milliseconds                                                |
| `request_body_json`               | object  | Yes      | Request body as JSON object (supports template variables)                      |
| `headers_json`                    | object  | Yes      | HTTP headers as JSON object (supports template variables)                      |
| `query_params_json`               | object  | Yes      | Query parameters as JSON object (supports template variables)                  |

## Template Variables

Webhook templates support dynamic variable substitution using the following syntax:

### Secret Vault Keys

Access keys from the secret vault:

```
{{ #key }}
```

Example:

```json theme={null}
{
  "Authorization": "Bearer {{ #api_key }}"
}
```

### Workflow Step Variables

Access variables from previous workflow steps:

```
{{ step.response.variable }}
```

Example:

```json theme={null}
{
  "user_id": "{{ step.response.user_id }}",
  "email": "{{ step.response.email }}"
}
```

### Initial Variables

Access variables from the initial workflow input:

```
{{ initial.variable }}
```

Example:

```json theme={null}
{
  "order_id": "{{ initial.order_id }}",
  "customer_name": "{{ initial.customer_name }}"
}
```

### Usage in Different Fields

Template variables can be used in:

* **Request Body** (`request_body_json`): Any field value can contain template variables
* **Headers** (`headers_json`): Header values can contain template variables
* **Query Parameters** (`query_params_json`): Query parameter values can contain template variables
* **Path** (`path`): The path itself can contain template variables

### Example with Template Variables

```json theme={null}
{
  "webhook_name": "Send User Notification",
  "webhook_description": "Sends notification to user after order creation",
  "method": "POST",
  "path": "/notifications/{{ initial.user_id }}",
  "domain_uuid": "aa3a5347-d334-4280-9361-f273d298468c",
  "retry_delay": 4,
  "retry_backoff_mode": "linear",
  "max_retries": 4,
  "request_timeout_in_milliseconds": 3000,
  "request_body_json": {
    "user_id": "{{ initial.user_id }}",
    "order_id": "{{ step.response.order_id }}",
    "message": "Your order has been created"
  },
  "headers_json": {
    "Authorization": "Bearer {{ #api_key }}",
    "X-User-ID": "{{ initial.user_id }}"
  },
  "query_params_json": {
    "timestamp": "{{ step.response.created_at }}"
  }
}
```

## Example response

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "webhook_template_id": "{{webhook_template_id}}",
    "message": "Webhook template created successfully"
  }
  ```
</ResponseExample>

## Response fields

| Field                 | Type    | Description                                        |
| --------------------- | ------- | -------------------------------------------------- |
| `success`             | boolean | Indicates if the request was successful            |
| `webhook_template_id` | string  | Unique identifier for the created webhook template |
| `message`             | string  | Success message or error details                   |


## OpenAPI

````yaml POST /v1/api/add_webhook_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_webhook_template/:
    post:
      description: >-
        Create a new webhook template with configurable retry logic, timeout
        settings, and template variable support
      requestBody:
        description: Webhook template configuration
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddWebhookTemplateRequest'
      responses:
        '200':
          description: Webhook template created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddWebhookTemplateResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AddWebhookTemplateRequest:
      required:
        - webhook_name
        - webhook_description
        - method
        - path
        - domain_uuid
        - retry_delay
        - retry_backoff_mode
        - max_retries
        - request_timeout_in_milliseconds
        - request_body_json
        - headers_json
        - query_params_json
      type: object
      properties:
        webhook_name:
          type: string
          description: Name of the webhook template
        webhook_description:
          type: string
          description: Description of the webhook template
        method:
          type: string
          description: HTTP method (e.g., 'GET', 'POST', 'PUT', 'DELETE')
          enum:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
        path:
          type: string
          description: URL path for the webhook (supports template variables)
        domain_uuid:
          type: string
          description: UUID of the domain associated with this webhook template
        retry_delay:
          type: integer
          description: Delay in seconds between retry attempts
        retry_backoff_mode:
          type: string
          description: Retry backoff strategy
          enum:
            - linear
            - exponential
        max_retries:
          type: integer
          description: Maximum number of retry attempts
        request_timeout_in_milliseconds:
          type: integer
          description: Request timeout in milliseconds
        request_body_json:
          type: object
          description: Request body as JSON object (supports template variables)
        headers_json:
          type: object
          description: HTTP headers as JSON object (supports template variables)
        query_params_json:
          type: object
          description: Query parameters as JSON object (supports template variables)
    AddWebhookTemplateResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates if the request was successful
        webhook_template_id:
          type: string
          description: Unique identifier for the created webhook template
        message:
          type: string
          description: Success message or error details
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
  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.

````