---
type: api
title: Schedule a backfill for rules
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v9/operation/operation-post-alerting-rules-backfill-schedule
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v9/operation/operation-post-alerting-rules-backfill-schedule
products:
  - Kibana
---

# Schedule a backfill for rules

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/alerting/rules/backfill/_schedule`
- `POST` `/s/{space_id}/api/alerting/rules/backfill/_schedule`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v9/authentication#basicauth)

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Request Body

`application/json`

Type: `[] object · min: 1 · max: 100`


## Responses

#### `200`

Indicates a successful call.

`application/json`

An array; each item is any of:
- **Kibana_HTTP_APIs_backfill_response**
  - `created_at` (string)
  - `duration` (string)
  - `enabled` (boolean)
  - `end` (string)
  - `id` (string)
  - `initiator` (enum)
    Values: `user`, `system`
  - `initiator_id` (string)
  - `rule` (object)
    - `api_key_created_by_user` (boolean) — nullable
    - `api_key_owner` (string · default: null) — nullable
    - `consumer` (string)
    - `created_at` (string)
    - `created_by` (string · default: null) — nullable
    - `enabled` (boolean)
    - `id` (string)
    - `name` (string)
    - `params` (map string to object)
      The parameters for the rule.
    - `revision` (number)
    - `rule_type_id` (string)
    - `schedule` (object)
      - `interval` (string)
    - `tags` ([] string)
    - `updated_at` (string)
    - `updated_by` (string · default: null) — nullable
  - `schedule` ([] object)
    - `interval` (string)
    - `run_at` (string)
    - `status` (enum)
      Values: `complete`, `pending`, `running`, `error`, `timeout`
  - `space_id` (string)
  - `start` (string)
  - `status` (enum)
    Values: `complete`, `pending`, `running`, `error`, `timeout`
- **Kibana_HTTP_APIs_backfill_error_response**
  - `error` (object)
    - `message` (string)
    - `rule` (object)
      - `id` (string)
      - `name` (string)
    - `status` (number)
#### `400`

Indicates an invalid schema or parameters.

#### `403`

Indicates that this call is forbidden.

#### `404`

Indicates a rule with the given ID does not exist.

## Code Examples

#### Console

```console
POST /api/alerting/rules/backfill/_schedule
[
  {
    "ranges": [
      {
        "end": "2024-01-02T00:00:00.000Z",
        "start": "2024-01-01T00:00:00.000Z"
      }
    ],
    "rule_id": "3583a470-74f6-11ed-9801-35303b735aef"
  }
]
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/alerting/rules/backfill/_schedule" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '[
  {
    "ranges": [
      {
        "end": "2024-01-02T00:00:00.000Z",
        "start": "2024-01-01T00:00:00.000Z"
      }
    ],
    "rule_id": "3583a470-74f6-11ed-9801-35303b735aef"
  }
]'
```

## Response Examples

#### Schedule backfill response

```json
[
  {
    "created_at": "2024-01-30T00:00:00.000Z",
    "duration": "12h",
    "enabled": true,
    "id": "85bdf571-f4fb-4666-a8d2-e05e1220ebc6",
    "initiator": "user",
    "rule": {
      "api_key_owner": "elastic",
      "consumer": "alerts",
      "created_at": "2022-12-05T23:40:33.132Z",
      "created_by": "elastic",
      "enabled": true,
      "id": "3583a470-74f6-11ed-9801-35303b735aef",
      "name": "my alert",
      "params": {
        "aggField": "sheet.version",
        "aggType": "avg",
        "groupBy": "top",
        "index": [
          "test-index"
        ],
        "termField": "name.keyword",
        "termSize": 6,
        "threshold": [
          1000
        ],
        "thresholdComparator": "\u003E",
        "timeField": "@timestamp",
        "timeWindowSize": 5,
        "timeWindowUnit": "m"
      },
      "revision": 0,
      "rule_type_id": ".index-threshold",
      "schedule": {
        "interval": "1m"
      },
      "tags": [
        "cpu"
      ],
      "updated_at": "2022-12-05T23:40:33.132Z",
      "updated_by": "elastic"
    },
    "schedule": [
      {
        "interval": "12h",
        "run_at": "2024-01-01T12:00:00.000Z",
        "status": "pending"
      },
      {
        "interval": "12h",
        "run_at": "2024-01-02T00:00:00.000Z",
        "status": "pending"
      }
    ],
    "space_id": "default",
    "start": "2024-01-01T00:00:00.000Z",
    "status": "pending"
  }
]
```

