Skip to content

Commit 22e08dd

Browse files
claudiacodacyclaude
andcommitted
docs: update webhooks payload for M1 wire contract changes [OD-702]
The M1 wire contract changed after this page was approved (outbound-hooks#15, codacy-events#260): - Drop the X-Codacy-Timestamp header. The signature covers only the body, so an unsigned timestamp header could be replayed or altered without detection. - Body timestamp is now an ISO 8601 UTC string, second precision, not a Unix timestamp. It's covered by the signature. - Add the body status field (success, partial_success, failure) and note that failed and partially failed analyses fire the event too. - Document the real retry behavior: a 5xx or timeout retries up to 2 more times (200 ms, 400 ms delay), a 4xx drops immediately, and a retry reuses the same X-Codacy-Delivery value. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent ff35796 commit 22e08dd

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎docs/organizations/integrations/webhooks.md‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ Codacy sends the `quality.analysis.completed` event to every webhook endpoint of
4242
- **A branch analysis finishes.** Codacy finished analyzing the newest commit of an enabled branch. Only the newest commit on a branch triggers a delivery, and reanalyzing that commit sends a new delivery.
4343
- **A pull request analysis finishes.**
4444

45+
Codacy sends the event regardless of the analysis outcome, not only when it succeeds. Check the body's `status` field for the outcome.
46+
4547
## Delivery payload {: id="delivery-payload"}
4648

4749
Each delivery is an HTTP `POST` request with a JSON body and these headers:
4850

4951
| Header | Description |
5052
|---|---|
5153
| `X-Codacy-Event` | The event type, always `quality.analysis.completed`. |
52-
| `X-Codacy-Delivery` | A UUID that uniquely identifies this delivery. A reanalysis of the same commit generates a new UUID. |
53-
| `X-Codacy-Timestamp` | The time Codacy sent the delivery, as a Unix timestamp in seconds. |
54+
| `X-Codacy-Delivery` | A UUID that uniquely identifies this delivery. A reanalysis of the same commit generates a new UUID, but a retry of the same delivery reuses it — see [delivery behavior](#delivery-behavior). |
5455
| `X-Codacy-Signature` | The [HMAC-SHA256 signature](#verifying-a-delivery) of the request body, in the form `sha256=<hex-encoded hash>`. |
5556

5657
The body identifies the organization, the repository, the commit, and either the branch or the pull request. It doesn't include the analysis results.
@@ -64,7 +65,8 @@ Branch analysis finished:
6465
"repository": { "name": "engine" },
6566
"target": { "type": "branch", "value": "master" },
6667
"commitSha": "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678",
67-
"timestamp": 1758150000
68+
"status": "success",
69+
"timestamp": "2025-09-17T23:00:00Z"
6870
}
6971
```
7072

@@ -77,13 +79,15 @@ Pull request analysis finished:
7779
"repository": { "name": "engine" },
7880
"target": { "type": "pullRequest", "value": "464" },
7981
"commitSha": "a1b2c3d4e5f60718293a4b5c6d7e8f9012345678",
80-
"timestamp": 1758150000
82+
"status": "success",
83+
"timestamp": "2025-09-17T23:00:00Z"
8184
}
8285
```
8386

8487
- **`target.type`** is `branch` for a branch analysis or `pullRequest` for a pull request analysis. `target.value` is always a string — the branch name, or the pull request number.
8588
- **`organization.provider`** is the Git provider short code: `gh` for GitHub, `gl` for GitLab, or `bb` for Bitbucket.
86-
- **`timestamp`** is a Unix timestamp in seconds, matching the `X-Codacy-Timestamp` header.
89+
- **`status`** is `success`, `partial_success`, or `failure` — whether all, some, or none of the analysis tasks completed.
90+
- **`timestamp`** is when Codacy sent the delivery, as an ISO 8601 UTC timestamp to the second (`2025-09-17T23:00:00Z`). There's no separate timestamp header: the signature covers the whole body, so verify this field instead of a header if you need to reject stale deliveries.
8791

8892
Codacy doesn't include an issue list or a link to the analysis result in the payload. Use the [Codacy API](../../codacy-api/using-the-codacy-api.md) to look up the analysis details for the commit or pull request.
8993

@@ -94,11 +98,13 @@ Verify that a delivery came from Codacy by recomputing its signature and compari
9498
1. Compute the HMAC-SHA256 hash of the raw request body, using the endpoint's signing secret as the key.
9599
1. Hex-encode the hash and prefix it with `sha256=`.
96100
1. Compare the result to the `X-Codacy-Signature` header using a constant-time comparison, and reject the delivery if they don't match.
101+
1. Optionally reject a delivery whose body `timestamp` is too old, to guard against a captured delivery being replayed.
97102

98103
## Delivery behavior {: id="delivery-behavior"}
99104

100-
- Codacy waits 10 seconds for your endpoint to respond. A timeout or a non-2xx response drops the delivery — Codacy doesn't retry it.
101-
- Codacy can send more than one delivery for the same commit, for example after a reanalysis. Each delivery has a distinct `X-Codacy-Delivery` value, so if you need to avoid processing the same commit twice, treat deliveries with the same `commitSha` as duplicates instead.
105+
- Codacy waits 10 seconds for your endpoint to respond. A `5xx` response or a timeout is retried up to 2 more times, waiting 200 ms before the first retry and 400 ms before the second. A `4xx` response drops the delivery immediately, without a retry.
106+
- A retry reuses the same `X-Codacy-Delivery` value as the original attempt, so treat retries with the same value as duplicates.
107+
- Codacy can also send more than one delivery for the same commit for other reasons, for example a reanalysis. Each of those deliveries has a distinct `X-Codacy-Delivery` value, so if you need to avoid processing the same commit twice, treat deliveries with the same `commitSha` as duplicates instead.
102108
- Codacy doesn't keep a delivery log or let you resend a delivery. Log deliveries on your own endpoint if you need a record of what Codacy sent.
103109

104110
## See also

0 commit comments

Comments
 (0)