> ## 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 Schedule (Interval)

> Create a new interval-based schedule that executes a webhook or workflow at regular intervals

Create a new interval-based schedule that executes a webhook or workflow at regular intervals (every N seconds, minutes, or hours).

## 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_interval_schedule/" \
    -H "x-hookpulse-api-key: {{x-hookpulse-api-key}}" \
    -H "x-brand-uuid: {{x-brand-uuid}}" \
    -H "Content-Type: application/json" \
    -d '{
      "interval_value": 5,
      "is_one_off_task": false,
      "interval_period": "second",
      "schedule_to": "webhook",
      "model_to_schedule_uuid": "{{model_to_schedule_uuid}}",
      "initial_context_template": {
        "key": "value"
      }
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.hookpulse.io/v1/api/add_interval_schedule/', {
    method: 'POST',
    headers: {
      'x-hookpulse-api-key': '{{x-hookpulse-api-key}}',
      'x-brand-uuid': '{{x-brand-uuid}}',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      interval_value: 5,
      is_one_off_task: false,
      interval_period: 'second',
      schedule_to: 'webhook',
      model_to_schedule_uuid: '{{model_to_schedule_uuid}}',
      initial_context_template: {
        key: 'value'
      }
    })
  });

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

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

  url = 'https://api.hookpulse.io/v1/api/add_interval_schedule/'
  headers = {
      'x-hookpulse-api-key': '{{x-hookpulse-api-key}}',
      'x-brand-uuid': '{{x-brand-uuid}}',
      'Content-Type': 'application/json'
  }
  payload = {
      'interval_value': 5,
      'is_one_off_task': False,
      'interval_period': 'second',
      'schedule_to': 'webhook',
      'model_to_schedule_uuid': '{{model_to_schedule_uuid}}',
      'initial_context_template': {
          'key': 'value'
      }
  }

  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_interval_schedule/')
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(uri)
  request['x-hookpulse-api-key'] = '{{x-hookpulse-api-key}}'
  request['x-brand-uuid'] = '{{x-brand-uuid}}'
  request['Content-Type'] = 'application/json'
  request.body = {
    interval_value: 5,
    is_one_off_task: false,
    interval_period: 'second',
    schedule_to: 'webhook',
    model_to_schedule_uuid: '{{model_to_schedule_uuid}}',
    initial_context_template: {
      key: 'value'
    }
  }.to_json

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

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

  $url = "https://api.hookpulse.io/v1/api/add_interval_schedule/";
  $data = [
      'interval_value' => 5,
      'is_one_off_task' => false,
      'interval_period' => 'second',
      'schedule_to' => 'webhook',
      'model_to_schedule_uuid' => '{{model_to_schedule_uuid}}',
      'initial_context_template' => [
          'key' => 'value'
      ]
  ];

  $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                                                                         |
| -------------------------- | ------- | -------- | ----------------------------------------------------------------------------------- |
| `interval_value`           | integer | Yes      | Number of time units between executions (must be > 0)                               |
| `is_one_off_task`          | boolean | Yes      | Set to `true` if the schedule should run only once, `false` for recurring execution |
| `interval_period`          | string  | Yes      | Unit of time: `"second"`, `"minute"`, or `"hour"`                                   |
| `schedule_to`              | string  | Yes      | Target type: `"webhook"` or `"workflow"`                                            |
| `model_to_schedule_uuid`   | string  | Yes      | UUID of the webhook or workflow template to schedule (as per `schedule_to`)         |
| `initial_context_template` | object  | No       | Key-value pairs passed as `{{ initial.key }}` variables to the webhook/workflow     |

## Example response

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "details": "Schedule added successfully"
  }
  ```
</ResponseExample>

## Response fields

| Field     | Type    | Description                                        |
| --------- | ------- | -------------------------------------------------- |
| `success` | boolean | Indicates if the schedule was created successfully |
| `details` | string  | Success message                                    |

## Interval Period Options

* **`"second"`**: Execute every N seconds (e.g., every 5 seconds)
* **`"minute"`**: Execute every N minutes (e.g., every 15 minutes)
* **`"hour"`**: Execute every N hours (e.g., every 2 hours)

## Initial Context Template

The `initial_context_template` object allows you to pass variables to your webhook or workflow that can be accessed using `{{ initial.key }}` syntax:

* **In request body**: `{{ initial.key }}` will be replaced with the value
* **In headers**: `{{ initial.key }}` can be used in header values
* **In query params**: `{{ initial.key }}` can be used in query parameters
* **In path**: `{{ initial.key }}` can be used in URL paths

You can also combine with:

* **System secrets**: `{{ #secret_key }}` for vault secrets
* **Workflow step responses**: `{{ step.response.variable }}` in workflows

## Use Cases

* **Health Checks**: Execute every 30 seconds to monitor system health
* **Data Sync**: Sync data every 5 minutes
* **Cache Refresh**: Refresh cache every hour
* **Periodic Reports**: Generate reports every 6 hours
* **Status Updates**: Update status every 2 minutes

## Examples

### Every 30 seconds (recurring)

```json theme={null}
{
  "interval_value": 30,
  "is_one_off_task": false,
  "interval_period": "second",
  "schedule_to": "webhook",
  "model_to_schedule_uuid": "{{model_to_schedule_uuid}}"
}
```

### Every 15 minutes (recurring)

```json theme={null}
{
  "interval_value": 15,
  "is_one_off_task": false,
  "interval_period": "minute",
  "schedule_to": "webhook",
  "model_to_schedule_uuid": "{{model_to_schedule_uuid}}"
}
```

### Every 2 hours with initial context (recurring)

```json theme={null}
{
  "interval_value": 2,
  "is_one_off_task": false,
  "interval_period": "hour",
  "schedule_to": "workflow",
  "model_to_schedule_uuid": "{{model_to_schedule_uuid}}",
  "initial_context_template": {
    "report_type": "hourly",
    "timezone": "UTC"
  }
}
```

### One-time execution after 5 minutes

```json theme={null}
{
  "interval_value": 5,
  "is_one_off_task": true,
  "interval_period": "minute",
  "schedule_to": "webhook",
  "model_to_schedule_uuid": "{{model_to_schedule_uuid}}"
}
```

## Related Documentation

* [Scheduling Overview](/docs/api-reference/scheduling/overview) - Learn about all scheduling types
* [Add Cron Schedule](/docs/api-reference/scheduling/add-cron-schedule) - Create cron-based schedules
* [Get Timezone Options](/docs/api-reference/scheduling/timezone-options) - Get list of available timezones


## OpenAPI

````yaml POST /v1/api/add_interval_schedule/
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_interval_schedule/:
    post:
      description: >-
        Create a new interval-based schedule that executes a webhook or workflow
        at regular intervals
      requestBody:
        description: Interval schedule configuration
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddIntervalScheduleRequest'
      responses:
        '200':
          description: Schedule created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScheduleResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AddIntervalScheduleRequest:
      required:
        - interval_value
        - interval_period
        - schedule_to
        - model_to_schedule_uuid
      type: object
      properties:
        interval_value:
          type: integer
          description: Number of time units between executions (must be > 0)
          minimum: 1
        interval_period:
          type: string
          enum:
            - second
            - minute
            - hour
          description: 'Unit of time: ''second'', ''minute'', or ''hour'''
        schedule_to:
          type: string
          enum:
            - webhook
            - workflow
          description: 'Target type: ''webhook'' or ''workflow'''
        model_to_schedule_uuid:
          type: string
          description: UUID of the webhook or workflow template to schedule
        initial_context_template:
          type: object
          description: >-
            Key-value pairs passed as {{ initial.key }} variables to the
            webhook/workflow
          additionalProperties: true
    ScheduleResponse:
      type: object
      properties:
        success:
          type: boolean
          description: Indicates if the schedule was created successfully
        details:
          type: string
          description: Success message
    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.

````