Signed webhook
Send each Kosken event as signed JSON to your own HTTPS endpoint, read the payload, and check the signature.
After you read this guide, you can receive Kosken events on your own endpoint and check that each request comes from Kosken.
Connect a webhook
Only an owner of the workspace can connect a channel. Your endpoint must use HTTPS on a public host. Kosken refuses localhost, names that end in .local or .internal, and addresses of private networks.
- In the sidebar, select Channels.
- Under Add a channel, on Signed webhook, select Connect.
- In Name, write a name for the channel, for example
ops-hook. - In Endpoint address, write the URL of your endpoint, for example
https://hooks.example.com/kosken. - Select Connect. The page Webhook signing key shows the key.
- Select Copy and store the key in your receiver. Then select Done.
Kosken shows the signing key one time. It stores the key and the address sealed and does not show them again. When you lose the key, delete the channel and connect it again to get a new key.
Then select Send test on the new row, and add a rule with this channel in Channel. See Send an event to a channel or to members.
The request
For each event, Kosken sends one POST request with these headers:
Content-Typeapplication/json; charset=utf-8X-Kosken-Timestamp- The time of the send, in Unix seconds, for example
1795354800. X-Kosken-Signaturesha256=and the HMAC-SHA256 of the request, in hexadecimal. See Check the signature.
The payload
An example body for an incident that opened:
{"body":"Kosken opened INC-12 on web-01. Severity: warning.","event":"incident.opened","link":"https://acme.workspace.kosken.ai/incidents/01936f0e-5a7b-7c1d-9e2f-3a4b5c6d7e8f","quoted":[{"label":"title","value":"nginx is not running"}],"subject":"INC-12 opened on web-01","v":1}
v- The version of the format. It is
1. event- The kind of event, for example
incident.openedorapproval.requested. A test message hastest. subjectandbody- The title and the text of the event, in English.
quoted- A list of quoted data. Each item has a
label, such astitleorcause, and avalue. The value comes from your machines and tools. Treat it as untrusted text. link- The page in Kosken. The field is missing when the event has no page.
Check the signature
Kosken signs the timestamp, a dot and the raw body with the signing key. Use the key exactly as Kosken showed it.
- Read the header
X-Kosken-Timestampand the raw bytes of the body. Do not parse and write the JSON again before you check it. - Join them: the timestamp, a
., then the body. - Compute the HMAC-SHA256 of the result with the signing key, in hexadecimal.
- Compare
sha256=and your result withX-Kosken-Signature. Use a constant-time comparison. - Refuse the request when the signatures differ, or when the timestamp is too old, for example older than 5 minutes.
To test by hand, with the values in shell variables:
printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$KEY"
Your answer and the retries
2xx: Kosken records the message as sent.429: Kosken waits for the time inRetry-After, or 30 seconds, and sends again.401,403,404or410: Kosken marks the channel Broken and stops sending to it. Delete the channel and connect it again.- Another answer, or no answer: Kosken sends again later, with a longer wait each time, up to 8 attempts in total. Each attempt has a new timestamp and a new signature.
Something here does not match the app? Tell us