> ## 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 (Clocked)

> Create a one-time scheduled task that executes a webhook or workflow at a specific date and time

Create a one-time scheduled task that executes a webhook or workflow at a specific date and time. Clocked schedules are automatically one-off tasks (they execute once and then complete).

## 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_clocked_schedule/" \
    -H "x-hookpulse-api-key: {{x-hookpulse-api-key}}" \
    -H "x-brand-uuid: {{x-brand-uuid}}" \
    -H "Content-Type: application/json" \
    -d '{
      "clocked_run_at": "{{clocked_run_at}}",
      "clocked_timezone": "Asia/Kolkata",
      "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_clocked_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({
      clocked_run_at: '{{clocked_run_at}}',
      clocked_timezone: 'Asia/Kolkata',
      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_clocked_schedule/'
  headers = {
      'x-hookpulse-api-key': '{{x-hookpulse-api-key}}',
      'x-brand-uuid': '{{x-brand-uuid}}',
      'Content-Type': 'application/json'
  }
  payload = {
      'clocked_run_at': '{{clocked_run_at}}',
      'clocked_timezone': 'Asia/Kolkata',
      '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_clocked_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 = {
    clocked_run_at: '{{clocked_run_at}}',
    clocked_timezone: 'Asia/Kolkata',
    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_clocked_schedule/";
  $data = [
      'clocked_run_at' => '{{clocked_run_at}}',
      'clocked_timezone' => 'Asia/Kolkata',
      '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                                                                                                                |
| -------------------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------- |
| `clocked_run_at`           | string | Yes      | ISO 8601 datetime string for when to execute (e.g., `"2024-12-25T00:00:00Z"`)                                              |
| `clocked_timezone`         | string | Yes      | IANA timezone identifier (use [Get Timezone Options](/docs/api-reference/scheduling/timezone-options) to get valid values) |
| `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                                    |

## DateTime Format

The `clocked_run_at` field accepts ISO 8601 datetime strings:

* **Format**: `YYYY-MM-DDTHH:mm:ssZ` or `YYYY-MM-DDTHH:mm:ss+HH:mm`
* **Examples**:
  * `"2024-12-25T00:00:00Z"` - UTC timezone
  * `"2024-12-25T00:00:00+05:30"` - With timezone offset
  * `"2024-12-25T09:30:00Z"` - Specific time

The timezone specified in `clocked_timezone` is used to interpret the datetime if no timezone is specified in the string.

## Timezone Support

HookPulse supports all 500+ IANA timezones. Use the [Get Timezone Options](/docs/api-reference/scheduling/timezone-options) endpoint to get the complete list.

## One-Off Tasks

Clocked schedules are automatically one-off tasks that execute once at the specified time. After execution, the schedule status becomes `"completed"`. The `is_one_off_task` field is not required for clocked schedules as they are always one-time executions.

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

* **Scheduled Maintenance**: Run maintenance tasks at specific times
* **Future Operations**: Schedule operations for future dates
* **One-Time Events**: Execute tasks for specific events
* **Time-Sensitive Operations**: Operations that must run at exact times
* **Event-Based Triggers**: Trigger workflows at specific event times

## Examples

### Christmas Day Task

```json theme={null}
{
  "clocked_run_at": "{{clocked_run_at}}",
  "clocked_timezone": "UTC",
  "schedule_to": "webhook",
  "model_to_schedule_uuid": "{{model_to_schedule_uuid}}"
}
```

### New Year's Eve at Midnight

```json theme={null}
{
  "clocked_run_at": "{{clocked_run_at}}",
  "clocked_timezone": "America/New_York",
  "schedule_to": "workflow",
  "model_to_schedule_uuid": "{{model_to_schedule_uuid}}",
  "initial_context_template": {
    "event": "new_year",
    "year": "2025"
  }
}
```

### Specific Business Time

```json theme={null}
{
  "clocked_run_at": "{{clocked_run_at}}",
  "clocked_timezone": "Asia/Kolkata",
  "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
* [Get Timezone Options](/docs/api-reference/scheduling/timezone-options) - Get list of available timezones
* [Add Interval Schedule](/docs/api-reference/scheduling/add-interval-schedule) - Create recurring interval schedules


## OpenAPI

````yaml POST /v1/api/add_clocked_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_clocked_schedule/:
    post:
      description: >-
        Create a one-time scheduled task that executes a webhook or workflow at
        a specific date and time
      requestBody:
        description: Clocked schedule configuration
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddClockedScheduleRequest'
      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:
    AddClockedScheduleRequest:
      required:
        - clocked_run_at
        - clocked_timezone
        - is_one_off_task
        - schedule_to
        - model_to_schedule_uuid
      type: object
      properties:
        clocked_run_at:
          type: string
          format: date-time
          description: ISO 8601 datetime string for when to execute
        clocked_timezone:
          type: string
          description: IANA timezone identifier
        is_one_off_task:
          type: boolean
          description: Whether this is a one-time task
        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.

````