AlmondTill/G3N API

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
  2. Send a signed test delivery through the real lane. — pingWebhookSubscription
  3. Rotate the secret — update your receiver first; no grace window. — 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 — mutation · Register a webhook — your endpoint gets signed POSTs when the events you pick happen.

Example request

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

Variables:

{
  "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

{
  "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 — mutation · Send a signed test delivery through the real webhook lane — prove your endpoint end to end.

Example request

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

Variables:

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

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

Example response

{
  "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 — mutation · Mint a fresh signing secret for a webhook — the old one stops working immediately.

Example request

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

Variables:

{
  "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

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