---
title: "Create a contact point and an alert rule | Grafana documentation"
description: "End-to-end HTTP API workflow showing how to test and create a contact point, create a target folder, provision a Grafana-managed alert rule on /apis, and pause or inspect its evaluation state."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Create a contact point and an alert rule

This tutorial walks through an end-to-end Grafana Alerting workflow using `/apis` endpoints: testing and creating a webhook contact point (`Receiver`), creating a folder (`Folder`), provisioning a Grafana-managed alert rule (`AlertRule`) routed directly to that contact point, and pausing or inspecting the rule.

Every request has two tabs: one for `curl` and one for [`gcx`](https://grafana.com/docs/grafana/latest/ai-tools/grafana-cli/gcx/). Both send the same HTTP API request.

This workflow combines three `/apis` groups:

- **[Alert notifications HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/alert-notifications/) (`notifications.alerting.grafana.app/v1beta1`):** Tests and manages contact points (`receivers`).
- **[Folder HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/folder/) (`folder.grafana.app/v1`):** Creates the folder that holds the alert rule.
- **[Alert rules HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/alert-rules/) (`rules.alerting.grafana.app/v1beta1`):** Creates, inspects, pauses, and deletes standalone alert rules (`alertrules`).

> Note
> 
> The `notifications.alerting.grafana.app/v1beta1` (Grafana 13.0 and later) and `rules.alerting.grafana.app/v1beta1` (Grafana 13.3 and later) APIs are in `beta`. Verify that both API groups are available on `/swagger` in your Grafana instance before running these commands.

## Before you begin

Before you begin, ensure you have the following:

- **A Grafana instance:** Access to Grafana Cloud, Grafana Enterprise, or Grafana OSS with Grafana Alerting enabled.
- **A service account token:** A token with permissions to create folders, contact points, and alert rules, and to query the target data source (for example, the **Editor** or **Admin** basic role). Refer to [Configure RBAC for Grafana Alerting](https://grafana.com/docs/grafana/latest/alerting/set-up/configure-rbac/).
- **A Prometheus data source UID:** The `uid` of a Prometheus data source in your instance (list data sources with `GET /api/datasources` if you need to look it up).
- **A command-line tool:** `curl` or [`gcx`](https://grafana.com/docs/grafana/latest/ai-tools/grafana-cli/gcx/installation/) installed locally, plus `jq` to filter JSON output.

Export your environment variables for the session:

sh ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```sh
export GRAFANA_URL="<GRAFANA_URL>"
export GRAFANA_TOKEN="<SERVICE_ACCOUNT_TOKEN>"
export GRAFANA_NAMESPACE="<NAMESPACE>"
```

Replace the placeholders as follows:

- **`<GRAFANA_URL>`:** Base URL of your Grafana instance without a trailing slash, such as `https://my-stack.grafana.net` or `http://localhost:3000`.
- **`<SERVICE_ACCOUNT_TOKEN>`:** Bearer token for your service account.
- **`<NAMESPACE>`:** Resource namespace for `/apis` paths: `stacks-<STACK_ID>` in Grafana Cloud, `default` for organization `1` in self-managed Grafana, or `org-<ORG_ID>` for another organization.

If you use `gcx`, sign in once for the session (add `--org-id <ORG_ID>` when your namespace is `org-<ORG_ID>`):

sh ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```sh
gcx login --server "$GRAFANA_URL" --token "$GRAFANA_TOKEN" --yes
```

## Step 1: Test and create a contact point

Create the contact point before creating the alert rule, because Grafana validates that any receiver referenced by an alert rule already exists.

### Send a test notification before saving

Call `POST /apis/notifications.alerting.grafana.app/v1beta1/namespaces/{namespace}/receivers/-/test` with `-` as the receiver name to verify that your webhook endpoint is reachable before persisting the contact point:

curl gcx

![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

curl ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```curl
curl -sS -X POST \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  -d '{
    "integration": {
      "type": "webhook",
      "version": "1",
      "settings": {
        "url": "<WEBHOOK_URL>",
        "httpMethod": "POST"
      }
    },
    "alert": {
      "labels": {
        "alertname": "WebhookConnectivityTest",
        "severity": "warning"
      },
      "annotations": {
        "summary": "Verifying webhook delivery from Grafana Alerting"
      }
    }
  }' \
  "$GRAFANA_URL/apis/notifications.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/receivers/-/test"
```

gcx ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```gcx
gcx api "/apis/notifications.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/receivers/-/test" \
  -d '{
    "integration": {
      "type": "webhook",
      "version": "1",
      "settings": {
        "url": "<WEBHOOK_URL>",
        "httpMethod": "POST"
      }
    },
    "alert": {
      "labels": {
        "alertname": "WebhookConnectivityTest",
        "severity": "warning"
      },
      "annotations": {
        "summary": "Verifying webhook delivery from Grafana Alerting"
      }
    }
  }'
```

Replace `<WEBHOOK_URL>` with the HTTPS or HTTP endpoint that receives your alert payloads.

A successful delivery returns `200 OK`:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
{
  "status": "success",
  "duration": "118ms"
}
```

### Save the contact point

Call `POST /apis/notifications.alerting.grafana.app/v1beta1/namespaces/{namespace}/receivers` to create the `Receiver` resource:

curl gcx

![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

curl ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```curl
curl -sS -X POST \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  -d '{
    "apiVersion": "notifications.alerting.grafana.app/v1beta1",
    "kind": "Receiver",
    "metadata": {
      "name": "oncall-webhook"
    },
    "spec": {
      "title": "On-call webhook",
      "integrations": [
        {
          "type": "webhook",
          "version": "1",
          "disableResolveMessage": false,
          "settings": {
            "url": "<WEBHOOK_URL>",
            "httpMethod": "POST"
          }
        }
      ]
    }
  }' \
  "$GRAFANA_URL/apis/notifications.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/receivers"
```

gcx ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```gcx
gcx api "/apis/notifications.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/receivers" \
  -d '{
    "apiVersion": "notifications.alerting.grafana.app/v1beta1",
    "kind": "Receiver",
    "metadata": {
      "name": "oncall-webhook"
    },
    "spec": {
      "title": "On-call webhook",
      "integrations": [
        {
          "type": "webhook",
          "version": "1",
          "disableResolveMessage": false,
          "settings": {
            "url": "<WEBHOOK_URL>",
            "httpMethod": "POST"
          }
        }
      ]
    }
  }'
```

Replace `<WEBHOOK_URL>` with your webhook endpoint URL.

Grafana returns `201 Created` with the saved `Receiver` resource:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
{
  "kind": "Receiver",
  "apiVersion": "notifications.alerting.grafana.app/v1beta1",
  "metadata": {
    "name": "oncall-webhook",
    "namespace": "default",
    "uid": "7f3a9d2e-1b4c-4e8a-9c0d-2f4b6e8a0c12",
    "resourceVersion": "a1b2c3d4e5f60718"
  },
  "spec": {
    "title": "On-call webhook",
    "integrations": [
      {
        "uid": "d9e8f7a6b5c4",
        "type": "webhook",
        "version": "1",
        "disableResolveMessage": false,
        "settings": {
          "url": "https://example.com/alerts/webhook",
          "httpMethod": "POST"
        }
      }
    ]
  }
}
```

Pay attention to the two name fields on `Receiver`:

- **`metadata.name` (`oncall-webhook`):** Identifies the contact point in URL paths when you `GET`, `PUT`, `PATCH`, or `DELETE` the receiver.
- **`spec.title` (`On-call webhook`):** Identifies the contact point inside alert rule `notificationSettings.receiver` and notification policy trees.

## Step 2: Create a folder for your alert rules

Every `AlertRule` resource must belong to a folder (root-level placement isn’t supported). Call `POST /apis/folder.grafana.app/v1/namespaces/{namespace}/folders` to create a dedicated folder:

curl gcx

![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

curl ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```curl
curl -sS -X POST \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  -d '{
    "metadata": {
      "name": "alerts-production"
    },
    "spec": {
      "title": "Production Alerts"
    }
  }' \
  "$GRAFANA_URL/apis/folder.grafana.app/v1/namespaces/$GRAFANA_NAMESPACE/folders"
```

gcx ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```gcx
gcx api "/apis/folder.grafana.app/v1/namespaces/$GRAFANA_NAMESPACE/folders" \
  -d '{
    "metadata": {
      "name": "alerts-production"
    },
    "spec": {
      "title": "Production Alerts"
    }
  }'
```

Grafana returns `201 Created` with the `Folder` resource (`metadata.name` is `alerts-production`).

## Step 3: Create an alert rule routed to the contact point

Save the following `AlertRule` definition to `alert-rule.json`. Notice how the fields fit together:

- **`metadata.annotations["grafana.app/folder"]`:** Set to `alerts-production` (the folder’s `metadata.name` from Step 2).
- **`spec.notificationSettings`:** Uses `"type": "SimplifiedRouting"` (required in `v1beta1`) and sets `"receiver": "On-call webhook"` to match `spec.title` from Step 1.
- **`spec.expressions`:** Query `A` fetches CPU usage from Prometheus, expression `B` reduces each series to its latest value, and expression `C` applies the `> 80` threshold with `"source": true` to mark it as the firing condition.

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
{
  "apiVersion": "rules.alerting.grafana.app/v1beta1",
  "kind": "AlertRule",
  "metadata": {
    "name": "high-cpu-usage",
    "annotations": {
      "grafana.app/folder": "alerts-production"
    }
  },
  "spec": {
    "title": "High CPU usage",
    "trigger": {
      "interval": "1m"
    },
    "for": "5m",
    "noDataState": "NoData",
    "execErrState": "Error",
    "labels": {
      "severity": "warning",
      "team": "platform"
    },
    "annotations": {
      "summary": "CPU usage is above 80% for 5 minutes"
    },
    "notificationSettings": {
      "type": "SimplifiedRouting",
      "receiver": "On-call webhook"
    },
    "expressions": {
      "A": {
        "queryType": "",
        "datasourceUID": "<PROMETHEUS_DATASOURCE_UID>",
        "relativeTimeRange": {
          "from": "5m",
          "to": "0s"
        },
        "model": {
          "expr": "100 - (avg by (instance) (rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100)"
        }
      },
      "B": {
        "model": {
          "type": "reduce",
          "expression": "A",
          "reducer": "last"
        }
      },
      "C": {
        "source": true,
        "model": {
          "type": "threshold",
          "expression": "B",
          "conditions": [
            {
              "evaluator": {
                "type": "gt",
                "params": [80]
              }
            }
          ]
        }
      }
    }
  }
}
```

Replace `<PROMETHEUS_DATASOURCE_UID>` with the `uid` of your Prometheus data source. If you want to lock the rule so it can’t be edited in the Grafana UI, also add `"grafana.com/provenance": "api"` inside `metadata.annotations`.

Create the rule with `POST /apis/rules.alerting.grafana.app/v1beta1/namespaces/{namespace}/alertrules`:

curl gcx

![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

curl ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```curl
curl -sS -X POST \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  -d @alert-rule.json \
  "$GRAFANA_URL/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules"
```

gcx ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```gcx
gcx api "/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules" \
  -d @alert-rule.json
```

Grafana returns `201 Created` with the saved `AlertRule` resource (`metadata.name` is `high-cpu-usage`).

## Step 4: Inspect evaluation status, pause, and clean up

After the alert rule exists, you can read its live evaluation `status`, pause evaluation with a partial `PATCH`, or remove the resources in dependency order.

### Check runtime evaluation status

Call `GET /apis/rules.alerting.grafana.app/v1beta1/namespaces/{namespace}/alertrules/{name}` and inspect `status` with `jq`:

curl gcx

![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

curl ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```curl
curl -sS \
  -H "Accept: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  "$GRAFANA_URL/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules/high-cpu-usage" \
  | jq '{name: .metadata.name, title: .spec.title, health: .status.health, state: .status.state, lastEvaluationTime: .status.lastEvaluationTime}'
```

gcx ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```gcx
gcx api "/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules/high-cpu-usage" \
  | jq '{name: .metadata.name, title: .spec.title, health: .status.health, state: .status.state, lastEvaluationTime: .status.lastEvaluationTime}'
```

After the first evaluation cycle completes, the response reports the rule’s health and state:

JSON ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```json
{
  "name": "high-cpu-usage",
  "title": "High CPU usage",
  "health": "OK",
  "state": "Healthy",
  "lastEvaluationTime": "2026-11-12T09:01:00Z"
}
```

### Pause evaluation with a merge patch

Instead of sending the entire rule definition with `PUT`, send a `PATCH` request with `Content-Type: application/merge-patch+json` to pause evaluation during a maintenance window:

curl gcx

![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

curl ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```curl
curl -sS -X PATCH \
  -H "Accept: application/json" \
  -H "Content-Type: application/merge-patch+json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  -d '{
    "spec": {
      "paused": true
    }
  }' \
  "$GRAFANA_URL/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules/high-cpu-usage"
```

gcx ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```gcx
gcx api "/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules/high-cpu-usage" \
  -X PATCH \
  -H "Content-Type: application/merge-patch+json" \
  -d '{
    "spec": {
      "paused": true
    }
  }'
```

Set `"paused": false` with the same `PATCH` request to resume evaluation.

### Clean up resources in order

If you created these resources for testing, delete the alert rule first, then the contact point, and finally the empty folder. Deleting a contact point that is still referenced by an alert rule or deleting a non-empty folder fails with an error.

curl gcx

![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

curl ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```curl
curl -sS -X DELETE \
  -H "Accept: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  "$GRAFANA_URL/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules/high-cpu-usage"

curl -sS -X DELETE \
  -H "Accept: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  "$GRAFANA_URL/apis/notifications.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/receivers/oncall-webhook"

curl -sS -X DELETE \
  -H "Accept: application/json" \
  -H "Authorization: Bearer $GRAFANA_TOKEN" \
  "$GRAFANA_URL/apis/folder.grafana.app/v1/namespaces/$GRAFANA_NAMESPACE/folders/alerts-production"
```

gcx ![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg) Copy

```gcx
gcx api "/apis/rules.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/alertrules/high-cpu-usage" \
  -X DELETE

gcx api "/apis/notifications.alerting.grafana.app/v1beta1/namespaces/$GRAFANA_NAMESPACE/receivers/oncall-webhook" \
  -X DELETE

gcx api "/apis/folder.grafana.app/v1/namespaces/$GRAFANA_NAMESPACE/folders/alerts-production" \
  -X DELETE
```

## Related resources

To customize routing policies, mute timings, recording rules, or RBAC scopes, refer to the following guides:

- **Alert rules, recording rules, and rule sequences:** Refer to [Alert rules HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/alert-rules/).
- **Contact points, notification policy trees, and mute timings:** Refer to [Alert notifications HTTP API](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/alert-notifications/).
- **CLI fundamentals and error handling:** Refer to [CLI examples](https://grafana.com/docs/grafana/latest/developer-resources/api-reference/http-api/examples/curl-examples/).
- **Manage alerting with dedicated CLI commands:** Refer to [Provision alerting resources with `gcx`](https://grafana.com/docs/grafana/latest/alerting/set-up/provision-alerting-resources/gcx-provisioning/).
- **Granular alerting permissions:** Refer to [Configure RBAC for Grafana Alerting](https://grafana.com/docs/grafana/latest/alerting/set-up/configure-rbac/).
