PagerDuty Events API 400 invalid routing key in CI
The PagerDuty Events API v2 returns HTTP 400 with status invalid event and an error like "Length of 'routing_key' is incorrect (should be 32 characters)" or "routing_key not found" when the routing_key in the payload is missing, malformed, or from a non-Events-API integration.
What this error means
A trigger event to events.pagerduty.com returns HTTP 400 with a message about the routing key. No incident is created.
< HTTP/1.1 400 Bad Request
{"status":"invalid event","message":"Event object is invalid","errors":["Length of 'routing_key' is incorrect (should be 32 characters)"]}Common causes
The key is not an Events API v2 integration key
A REST API token or an integration key from a different integration type is not a valid 32-character Events API v2 routing key.
The secret is empty or truncated
A missing or partially pasted PAGERDUTY_ROUTING_KEY fails the length or lookup check.
How to fix it
Use the Events API v2 integration key
- On the PagerDuty service, add an integration of type Events API v2.
- Copy its 32-character Integration Key (routing key).
- Store it as
PAGERDUTY_ROUTING_KEYand send it in the payload.
jq -n --arg k "$PAGERDUTY_ROUTING_KEY" '{
routing_key:$k, event_action:"trigger",
payload:{summary:"CI build failed",source:"github-actions",severity:"error"}}' |
curl -sS -X POST https://events.pagerduty.com/v2/enqueue \
-H 'Content-Type: application/json' --data @-Reference the key from a secret
Inject the routing key through the step env so it is never hard-coded.
env:
PAGERDUTY_ROUTING_KEY: ${{ secrets.PAGERDUTY_ROUTING_KEY }}How to prevent it
- Use an Events API v2 integration key, not a REST token.
- Store the 32-character key in a secret and verify its length.
- Send a test trigger when wiring a new service integration.