# Send events to another system (webhooks)

Register your endpoint for signed POSTs when the events you pick happen, prove it end to end with a signed test delivery, and rotate the signing secret — the new one shows once.

Integrations · a play in 3 steps.

## The steps

1. Register the endpoint and the events — the signing secret shows once. — [createWebhookSubscription](/reference/system-and-integration-setup/createWebhookSubscription/)
2. Send a signed test delivery through the real lane. — [pingWebhookSubscription](/reference/system-and-integration-setup/pingWebhookSubscription/)
3. Rotate the secret — update your receiver first; no grace window. — [rotateWebhookSubscriptionSecret](/reference/system-and-integration-setup/rotateWebhookSubscriptionSecret/)

## The calls

Every operation this use case runs, in the order it first appears, with the request and the response its reference page shows.

### createWebhookSubscription

[createWebhookSubscription](/reference/system-and-integration-setup/createWebhookSubscription/) — mutation · Register a webhook — your endpoint gets signed POSTs when the events you pick happen.

**Example request**

```graphql
mutation ExampleCreateWebhookSubscription($input: CreateWebhookSubscriptionInput!) {
  createWebhookSubscription(input: $input) {
    secret
  }
}
```

Variables:

```json
{
  "input": {
    "caption": "Blue jeans",
    "targetUrl": "https://example.com/hook",
    "eventTypes": [
      "<event types>"
    ]
  }
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "createWebhookSubscription": {
      "secret": "<your key secret>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### pingWebhookSubscription

[pingWebhookSubscription](/reference/system-and-integration-setup/pingWebhookSubscription/) — mutation · Send a signed test delivery through the real webhook lane — prove your endpoint end to end.

**Example request**

```graphql
mutation ExamplePingWebhookSubscription($id: ID!) {
  pingWebhookSubscription(id: $id) {
    accepted
    pingId
  }
}
```

Variables:

```json
{
  "id": "01900000-0000-7000-8000-37386ae00000"
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "pingWebhookSubscription": {
      "accepted": true,
      "pingId": "01900000-0000-7000-8000-36c312ac0000"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```

### rotateWebhookSubscriptionSecret

[rotateWebhookSubscriptionSecret](/reference/system-and-integration-setup/rotateWebhookSubscriptionSecret/) — mutation · Mint a fresh signing secret for a webhook — the old one stops working immediately.

**Example request**

```graphql
mutation ExampleRotateWebhookSubscriptionSecret($id: ID!, $revision: ID!, $reason: String) {
  rotateWebhookSubscriptionSecret(id: $id, revision: $revision, reason: $reason) {
    secret
  }
}
```

Variables:

```json
{
  "id": "01900000-0000-7000-8000-37386ae00000",
  "revision": "01900000-0000-7000-8000-b7960e180000",
  "reason": "Correcting a miscount."
}
```

Send it with the envelope naming the version: `"extensions": {"at": {"version": {"name":"genesis","number":0}}}`.

**Example response**

```json
{
  "data": {
    "rotateWebhookSubscriptionSecret": {
      "secret": "<your key secret>"
    }
  },
  "extensions": {
    "at": {
      "callId": "01EXAMPLE-CALL-ID",
      "version": {
        "requested": {
          "name": "genesis",
          "number": 0
        },
        "serviced": {
          "name": "genesis",
          "number": 0
        }
      }
    }
  }
}
```
