> For the complete documentation index, see [llms.txt](https://docs.channex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.channex.io/api-v.1-documentation/webhook-collection/rotate-a-signing-key-api.md). Agents can also search and read this documentation through its [MCP server](https://docs.channex.io/~gitbook/mcp).

# Rotate a Signing Key API

## Rotate a signing key

> Rotate the key: promote the pending secret version to be the sole current version and\
> retire the others. Afterwards deliveries are signed with the promoted secret only, so\
> switch verification to it — announced by its masked label in the \`x-hmac-keys-256\`\
> header — before rotating. No new secret is created and none is revealed: the response\
> masks the version secrets. A successful rotation stamps the\
> key's \`rotated\_at\`. A key with no pending version cannot be rotated — generate one\
> first.

```json
{"openapi":"3.1.0","info":{"title":"Channex.io — Public API","version":"0.0.0"},"tags":[{"name":"Webhook Signing Keys","description":"HMAC keys that sign webhook deliveries, so that a receiving endpoint can tell that a\ncallback came from Channex and that its body was not altered on the way.\n\nA key is a shared secret: Channex holds it and so do you. It is not an API credential\n— it authenticates nothing against this API and grants no access. It is used in one\ndirection only, on the callbacks Channex sends to you.\n\nA key belongs to a billing account and holds up to two secret versions — the current\none plus an optional pending one, which is what makes rotation zero-downtime. To turn\nsigning on, point a webhook at the key with `signing_key_id` and set `is_signed`.\n\n## What is signed\n\nEvery delivery of a signed webhook — the `POST` Channex makes to the webhook's\n`callback_url` — carries three headers:\n\n- `x-hmac-timestamp` — Unix timestamp (seconds) taken when the delivery was signed.\n- `x-hmac-signature-256` — comma-separated lowercase-hex HMAC-SHA256 signatures, one\n  per secret version of the key, the current version first.\n- `x-hmac-keys-256` — comma-separated version labels (`...` followed by each secret's\n  last 6 characters), in the same order as the signatures.\n\nEach signature is computed over the string `{timestamp}.{raw request body}`: the value\nof `x-hmac-timestamp`, a dot, and the exact bytes of that delivery's body. Nothing else\nenters it — neither the callback URL nor the webhook's `request_params` and `headers`.\n\n## Verifying a delivery\n\nRecompute HMAC-SHA256 over `{timestamp}.{raw body}` with your stored secret, then\ncompare it against the signature at the position whose label in `x-hmac-keys-256` ends\nwith your secret's last 6 characters.\n\n## Rotating a key\n\n`generate` adds a pending secret version beside the current one, and deliveries are\nthen signed with both — so verification against the current secret keeps working while\nthe new secret is stored on your side. `rotate` promotes the newest version to be the\nsole current version, after which deliveries carry its signature alone."}],"servers":[{"url":"https://app.channex.io/api/v1","description":"Production server","variables":{}},{"url":"https://staging.channex.io/api/v1","description":"Staging server","variables":{}}],"security":[{"UserApiKeyAuth":[]}],"components":{"securitySchemes":{"UserApiKeyAuth":{"type":"apiKey","in":"header","name":"user-api-key","description":"API key for programmatic access, sent in the `user-api-key` header."}},"schemas":{"Common.Scalars.id":{"type":"string","format":"uuid"},"SigningKeys.SigningKeyResource":{"type":"object","required":["type","id","attributes","relationships"],"properties":{"type":{"type":"string","enum":["signing_key"]},"id":{"$ref":"#/components/schemas/Common.Scalars.id"},"attributes":{"$ref":"#/components/schemas/SigningKeys.SigningKey"},"relationships":{"$ref":"#/components/schemas/SigningKeys.SigningKeyRelationships"}},"description":"A signing key resource with its masked versions."},"SigningKeys.SigningKey":{"type":"object","required":["id","inserted_at","updated_at","rotated_at","title"],"properties":{"id":{"allOf":[{"$ref":"#/components/schemas/Common.Scalars.id"}],"description":"Unique signing key identifier. Mirrors the top-level resource `id`."},"inserted_at":{"type":"string","format":"date-time","description":"When the key was created (ISO 8601, no timezone offset)."},"updated_at":{"type":"string","format":"date-time","description":"When the key was last updated (ISO 8601, no timezone offset)."},"rotated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"format":"date-time","description":"When the key was last rotated (ISO 8601, no timezone offset). Null until the first rotation."},"title":{"type":"string","description":"Human-readable name of the key."}},"description":"An HMAC signing key for webhook deliveries. The secrets live in the key's\nversions and are masked to `...` + last 6 everywhere except the create\nand generate responses."},"SigningKeys.SigningKeyRelationships":{"type":"object","required":["signing_key_versions","webhooks"],"properties":{"signing_key_versions":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SigningKeys.SigningKeyVersionResource"}}},"required":["data"],"description":"The key's secret versions — the current one first, then oldest first. Secrets are masked to `...` plus their last 6 characters."},"webhooks":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SigningKeys.SigningKeyWebhookResource"}}},"required":["data"],"description":"The webhooks that sign their deliveries with the key, oldest first. Empty when no webhook uses it."}},"description":"Relationships of a signing key: its secret versions and the webhooks using it."},"SigningKeys.SigningKeyVersionResource":{"type":"object","required":["type","id","attributes"],"properties":{"type":{"type":"string","enum":["signing_key_version"]},"id":{"$ref":"#/components/schemas/Common.Scalars.id"},"attributes":{"$ref":"#/components/schemas/SigningKeys.SigningKeyVersion"}},"description":"A secret version of a signing key. Carries no relationships."},"SigningKeys.SigningKeyVersion":{"type":"object","required":["id","is_current","secret","inserted_at"],"properties":{"id":{"allOf":[{"$ref":"#/components/schemas/Common.Scalars.id"}],"description":"Unique version identifier. Mirrors the resource `id`."},"is_current":{"type":"boolean","description":"Whether this is the key's current version. A key has one current version and at most\none pending version awaiting rotation."},"secret":{"type":"string","description":"The version's secret masked to `...` plus its last 6 characters — the label\nidentifying the version in the `x-hmac-keys-256` delivery header and in API\nresponses. The full secret is never rendered here."},"inserted_at":{"type":"string","format":"date-time","description":"When the version was created (ISO 8601, no timezone offset)."}},"description":"A secret version of a signing key."},"SigningKeys.SigningKeyWebhookResource":{"type":"object","required":["type","id","attributes"],"properties":{"type":{"type":"string","enum":["webhook"]},"id":{"$ref":"#/components/schemas/Common.Scalars.id"},"attributes":{"$ref":"#/components/schemas/SigningKeys.SigningKeyWebhook"}},"description":"A webhook that signs its deliveries with the key."},"SigningKeys.SigningKeyWebhook":{"type":"object","required":["id","callback_url","event_mask","is_global"],"properties":{"id":{"allOf":[{"$ref":"#/components/schemas/Common.Scalars.id"}],"description":"Unique webhook identifier. Mirrors the resource `id`."},"callback_url":{"type":"string","format":"uri","description":"URL the webhook delivers to."},"event_mask":{"type":"string","description":"Events the webhook subscribes to: `*` for every event, or a semicolon-separated list of event names."},"is_global":{"type":"boolean","description":"Whether the webhook covers every property of its billing account rather than one."}},"description":"A webhook using the signing key, reduced to its identifying attributes."},"Common.Errors.Unauthorized":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","required":["code","title"],"properties":{"code":{"type":"string","enum":["unauthorized"]},"title":{"type":"string","enum":["Unauthorized"]}},"description":"Shape of a single JSON:API error object: a stable machine code plus a human-readable title."}},"description":"Authentication credentials are missing or invalid."},"Common.Errors.Forbidden":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","required":["code","title"],"properties":{"code":{"type":"string","enum":["forbidden"]},"title":{"type":"string","enum":["Forbidden"]}},"description":"Shape of a single JSON:API error object: a stable machine code plus a human-readable title."}},"description":"The authenticated user lacks permission to perform this action."},"Common.Errors.NotFound":{"type":"object","required":["errors"],"properties":{"errors":{"type":"object","required":["code","title"],"properties":{"code":{"type":"string","enum":["resource_not_found"]},"title":{"type":"string","enum":["Resource Not Found"]}},"description":"Shape of a single JSON:API error object: a stable machine code plus a human-readable title."}},"description":"The requested resource does not exist."},"Common.Errors.InvalidArguments":{"type":"object","required":["errors"],"properties":{"errors":{"$ref":"#/components/schemas/Common.Errors.InvalidArgumentsObject"}},"description":"The request has missing or invalid arguments; `details` lists the messages per argument."},"Common.Errors.InvalidArgumentsObject":{"type":"object","required":["code","title","details"],"properties":{"code":{"type":"string","enum":["bad_request"]},"title":{"type":"string","enum":["Bad Request"]},"details":{"type":"object","unevaluatedProperties":{"type":"array","items":{"type":"string"}},"description":"Maps each invalid argument to the list of validation messages for that argument."}},"description":"Error object for invalid request arguments, adding per-argument messages."},"Common.Errors.ValidationError":{"type":"object","required":["errors"],"properties":{"errors":{"$ref":"#/components/schemas/Common.Errors.ValidationErrorObject"}},"description":"The request body failed validation."},"Common.Errors.ValidationErrorObject":{"type":"object","required":["code","title","details"],"properties":{"code":{"type":"string","enum":["validation_error"]},"title":{"type":"string","enum":["Validation Error"]},"details":{"type":"object","unevaluatedProperties":{"type":"array","items":{"type":"string"}},"description":"Maps each invalid field to the list of validation messages for that field."}},"description":"Error object for a failed validation, adding per-field messages."}}},"paths":{"/signing_keys/{id}/rotate":{"post":{"operationId":"SigningKeys_rotate","summary":"Rotate a signing key","description":"Rotate the key: promote the pending secret version to be the sole current version and\nretire the others. Afterwards deliveries are signed with the promoted secret only, so\nswitch verification to it — announced by its masked label in the `x-hmac-keys-256`\nheader — before rotating. No new secret is created and none is revealed: the response\nmasks the version secrets. A successful rotation stamps the\nkey's `rotated_at`. A key with no pending version cannot be rotated — generate one\nfirst.","parameters":[{"name":"id","in":"path","required":true,"schema":{"$ref":"#/components/schemas/Common.Scalars.id"}}],"responses":{"200":{"description":"The request has succeeded.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"$ref":"#/components/schemas/SigningKeys.SigningKeyResource"}},"description":"JSON:API document wrapping a single resource."}}}},"401":{"description":"Authentication credentials are missing or invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Common.Errors.Unauthorized"}}}},"403":{"description":"The authenticated user lacks permission to perform this action.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Common.Errors.Forbidden"}}}},"404":{"description":"The requested resource does not exist.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Common.Errors.NotFound"}}}},"422":{"description":"The request has missing or invalid arguments; `details` lists the messages per argument.","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/Common.Errors.InvalidArguments"},{"$ref":"#/components/schemas/Common.Errors.ValidationError"}]}}}}},"tags":["Webhook Signing Keys"]}}}}
```
