# Cert Chief webhooks

import {Head} from "zudoku/components";

<Head>
  <title>Webhooks | Cert Chief</title>
</Head>

Cert Chief sends a webhook when a domain gets a different certificate, a certificate is about to expire, an issuer revokes a certificate, the DNSSEC or DANE status of a domain changes, or a domain gets a new Server Test grade. Use them to open a ticket before a certificate expires, alert the team that owns a service, or keep a certificate inventory in another system current without polling the API.

Deliveries are signed, retried, and logged the same way in every Chief Tools product. Read [Receive webhooks](/developers/webhooks) first for verification, responses, retries, and duplicates. This page covers what is specific to Cert Chief, most of all how its payloads are built.

## Set up an endpoint

Open **Notifications** in Cert Chief, choose **Webhooks**, and add an endpoint. Then send it a test event from the endpoint's page. Deliveries come with the `User-Agent` `CertChief-Webhooks/1.0`.

### Add an endpoint from code

Endpoints are managed through the [GraphQL API](/api/certchief) with a token that has the `certchief:webhooks:write` [scope](/developers/certchief/scopes#webhooks). [`webhookEndpointCreate`](/api/certchief/mutation/webhookEndpointCreate) adds one:

```http
POST /api/graphql HTTP/1.1
Host: cert.chief.app
Authorization: Bearer $TOKEN
Content-Type: application/json

{
  "query": "mutation ($input: WebhookEndpointCreateInput!) { webhookEndpointCreate(input: $input) { endpoint { id secret } status { success errors { name messages } } } }",
  "variables": {
    "input": {
      "url": "https://example.com/webhooks/chief",
      "description": "Certificate alerts",
      "events": ["certificate.expiring", "certificate.revoked"]
    }
  }
}
```

```json
{
  "data": {
    "webhookEndpointCreate": {
      "endpoint": {
        "id": "webhook_01m90mchwfnezcjb0zdn7pf3pm",
        "secret": "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw"
      },
      "status": {"success": true, "errors": null}
    }
  }
}
```

Use `["*"]` as `events` to receive every event, including types added later. Store the `secret` with your other secrets. You can read it again later through the endpoint's `secret` field, which also needs the write scope.

When `status.success` is `false`, `endpoint` is `null` and `status.errors` names the input field that is wrong, such as `url` or `events.0`. The same happens when your plan has no room for another endpoint.

### Send a test event

[`webhookEndpointSendTest`](/api/certchief/mutation/webhookEndpointSendTest) sends the endpoint a `webhook_endpoint.test` event, whether or not it subscribed to any event:

```json
{
  "query": "mutation ($input: WebhookEndpointInput!) { webhookEndpointSendTest(input: $input) { delivery { id status } status { success } } }",
  "variables": {"input": {"id": "$ENDPOINT_ID"}}
}
```

The test event's `data` holds the endpoint it was sent to:

```json
{
  "id": "event_01m90mcz0kx6fjr6bsq32brfb0",
  "type": "webhook_endpoint.test",
  "timestamp": "2026-12-04T13:37:48.050Z",
  "api_version": "v1",
  "data": {
    "endpoint": {
      "id": "webhook_01m90mchwfnezcjb0zdn7pf3pm",
      "url": "https://example.com/webhooks/chief",
      "description": "Certificate alerts"
    }
  }
}
```

### Which events an endpoint gets

Events are about domains, and every team that watches a domain gets its events on its own endpoints. A team that muted a domain gets no events for it, the same as for its notifications.

## How payloads are built

Other Chief Tools products send the resource an event is about as `data.object`. Cert Chief builds `data` with GraphQL instead. Every event type has its own payload type in the Cert Chief schema, and `data` is the result of a fragment on that type. The body reads like the `data` of a GraphQL response, and its fields have the same names and types as in the API.

For `certificate.changed`, the payload type is [`CertificateChangedWebhookEvent`](/api/certchief/object/CertificateChangedWebhookEvent), with the domain, the certificate it serves now, and the certificate it served before. The fragment picks these fields from it:

```graphql
fragment CertificateChanged on CertificateChangedWebhookEvent {
  domain {
    id
    display
    status
    permalink
    # more fields
  }
  certificate {
    id
    expiresAt
    issuer {
      o
    }
    # more fields
  }
  previousCertificate {
    # the same fields as certificate
  }
  valid
}
```

### Read the fragment of an event

[`webhookEventTypes`](/api/certchief/query/webhookEventTypes) lists every event type with its payload type and the complete fragment its `data` is built with. It needs no scope:

```json
{"query": "{ webhookEventTypes { type group description payloadType document } }"}
```

```json
{
  "data": {
    "webhookEventTypes": [
      {
        "type": "certificate.changed",
        "group": "Certificates",
        "description": "A domain serves a different certificate than before.",
        "payloadType": "CertificateChangedWebhookEvent",
        "document": "fragment CertificateChanged on CertificateChangedWebhookEvent { ... }"
      }
    ]
  }
}
```

### Generate types for your receiver

The fragment and the schema together describe exactly what `data` holds. Save the `document` of each event you handle as a `.graphql` file, download the schema from `https://cert.chief.app/api/graphql/schema`, and point your GraphQL code generator at both. You get a type for each payload without writing it by hand.

### Fields can be added

New fields can appear in a fragment, and with them in `data`. Ignore fields your receiver does not know. Enums such as `status` can get new values, so handle an unknown value without failing the whole event.

`data` shows the state at the moment the event happened. To get the current state of a domain or certificate, query it with the `id` from the payload, or open its `permalink` in Cert Chief.

## Events

Each event type links to its payload type in the [API reference](/api/certchief), with a description of every field.

### Certificates

| Type | Sent when |
|---|---|
| [`certificate.changed`](/api/certchief/object/CertificateChangedWebhookEvent) | A domain serves a different certificate than before, such as after a renewal. `valid` tells whether the new certificate is valid. |
| [`certificate.expiring`](/api/certchief/object/CertificateExpiringWebhookEvent) | The certificate of a domain expires soon or expired. See [Expiry reminders](#expiry-reminders). |
| [`certificate.installed`](/api/certchief/object/CertificateInstalledWebhookEvent) | A domain that served no certificate serves one. |
| [`certificate.removed`](/api/certchief/object/CertificateRemovedWebhookEvent) | A domain no longer serves a certificate. |
| [`certificate.revoked`](/api/certchief/object/CertificateRevokedWebhookEvent) | The issuer revoked the certificate of a domain. |
| [`certificate.unrevoked`](/api/certchief/object/CertificateUnrevokedWebhookEvent) | A revoked certificate is no longer revoked. |

### Domains

| Type | Sent when |
|---|---|
| [`domain.dnssec_changed`](/api/certchief/object/DomainDnssecChangedWebhookEvent) | The DNSSEC status of a domain changed. |
| [`domain.dane_changed`](/api/certchief/object/DomainDaneChangedWebhookEvent) | Whether the certificate matches the TLSA records of a domain changed. |

`valid` and `previousValid` are `true` when the check passes and `false` when it fails. They are `null` when the check does not apply, for a domain without DNSSEC or without TLSA records. DANE relies on DNSSEC, so `domain.dane_changed` also carries `dnssecValid`.

### Server Test

| Type | Sent when |
|---|---|
| [`server_test.grade_changed`](/api/certchief/object/ServerTestGradeChangedWebhookEvent) | A new Server Test of a domain finished with a different grade than the one before. |

`report` is the new test and `previousReport` the one before it. The `permalink` of a report opens the full test results. A test that could not grade the server, with the grade `-` or `E`, sends no event, and neither does the next test after one.

### Expiry reminders

Cert Chief checks expiry dates once a day. It sends `certificate.expiring` four, three, two, and one day before a certificate expires, on the day it expires, and one, two, three, four, seven, ten, and fourteen days after.

`daysLeft` counts down to `0` on the day the certificate expires and is negative after it, and `expired` is `true` once it has. Renewing the certificate stops the reminders, and the domain sends `certificate.changed` instead.

## Examples

### A certificate was renewed

```json
{
  "id": "event_01m90mdwzpe2ka1gpwn63v5ae5",
  "type": "certificate.changed",
  "timestamp": "2026-12-04T13:38:18.681Z",
  "api_version": "v1",
  "data": {
    "domain": {
      "id": "571528de-e944-4b72-acfb-2619451b0341",
      "domain": "shop.example.com",
      "port": 443,
      "display": "shop.example.com",
      "status": "VALID",
      "isMuted": false,
      "lastCrawl": "2026-12-04T13:38:16+00:00",
      "permalink": "https://cert.chief.app/team/acme1234/domains/shop.example.com"
    },
    "certificate": {
      "id": "a018adbb-f991-4bb8-9178-ea9455f43934",
      "display": "shop.example.com",
      "status": "OK",
      "isValid": true,
      "validFrom": "2026-12-04T09:29:16+00:00",
      "expiresAt": "2027-03-04T09:29:15+00:00",
      "issuer": {"cn": "YE2", "o": "Let's Encrypt"},
      "subject": {"cn": "shop.example.com", "san": ["shop.example.com"]},
      "permalink": "https://cert.chief.app/team/acme1234/certificates/a018adbb-f991-4bb8-9178-ea9455f43934",
      ...
    },
    "previousCertificate": {
      "id": "94098bf5-e3d1-4f29-8de2-e3b5ab7ac570",
      "expiresAt": "2026-12-10T03:39:32+00:00",
      ...
    },
    "valid": true
  }
}
```

### A certificate expires in four days

```json
{
  "id": "event_01m91a2h7k3q8x5c9vz4w6t1yb",
  "type": "certificate.expiring",
  "timestamp": "2026-12-06T06:00:04.218Z",
  "api_version": "v1",
  "data": {
    "domain": {
      "id": "571528de-e944-4b72-acfb-2619451b0341",
      "display": "shop.example.com",
      "permalink": "https://cert.chief.app/team/acme1234/domains/shop.example.com",
      ...
    },
    "certificate": {
      "id": "94098bf5-e3d1-4f29-8de2-e3b5ab7ac570",
      "expiresAt": "2026-12-10T03:39:32+00:00",
      "issuer": {"cn": "YE1", "o": "Let's Encrypt"},
      ...
    },
    "daysLeft": 4,
    "expired": false
  }
}
```

## Manage endpoints and deliveries

The [`team`](/api/certchief/object/Team) query has the team's webhook endpoints, events, and deliveries, with the `certchief:webhooks:read` scope. This request lists each endpoint with the attempts of the last 24 hours and its latest failed deliveries:

```json
{
  "query": "{ team { webhookEndpoints { id url status failingSince stats { attempts successRate } deliveries(status: FAILED, first: 5) { data { id event { type } lastResponseStatus } } } } }"
}
```

- [`webhookDelivery`](/api/certchief/object/Team) returns one delivery with every attempt, including the request headers and the response your receiver gave.
- [`webhookEvents`](/api/certchief/object/Team) lists events with the exact `payload` every delivery sent.
- [`webhookDeliveryResend`](/api/certchief/mutation/webhookDeliveryResend) sends a delivery again, and [`webhookEventResend`](/api/certchief/mutation/webhookEventResend) sends an event to another of the team's endpoints.

`payload`, `requestHeaders`, and the response `headers` are `JSON` fields. They arrive as JSON-encoded strings, so parse them before you use them.

## Common integrations

- **Expiry tickets.** Subscribe to `certificate.expiring` and open a ticket for the team that owns `data.domain.display`. Close it when the same domain sends `certificate.changed` with `valid` set to `true`.
- **Security alerts.** Subscribe to `certificate.revoked`, `certificate.removed`, and `domain.dane_changed`, and page someone when they arrive.
- **Certificate inventory.** Subscribe to `certificate.changed`, `certificate.installed`, and `certificate.removed`, and store the certificate from `data` by domain. Load the current state once with the domains and certificates of [`team`](/api/certchief/object/Team), and again to catch up after your receiver was down for longer than the retries last.

Events are kept for 30 days. For anything older, query the current state from the API.
