---
title: "Register a webhook"
description: "Other routes API"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.certinvo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Register a webhook

{/* Generated by apps/docs/scripts/generate.ts from contracts/api/openapi.yaml. Do not edit. */}
<div class="cvo-op">
<div class="cvo-op-main">

<div class="cvo-op-header">
<div class="cvo-op-path-row">
<span class="cvo-method" data-method="post">POST</span>
<code class="cvo-op-path-code">/v1/webhooks</code>
</div>
</div>

Registers a URL that hears the steps of this company's invoices: each event added to an invoice's history (`GET /v1/invoices/{id}/events`) is posted to it as JSON. Send `events` to hear only some codes; leave it out to hear every step.

The body is `{"type": "<event code>", "invoiceId": "<id>", "event": {<the event, as the history route returns it>}}`. Use `event.id` to recognise a step you already have: a step may arrive more than once, and steps may arrive out of order.

Each post is signed as Standard Webhooks specifies (standardwebhooks.com), so its reference library checks it in any language. It carries `webhook-id` (the same on every attempt of one delivery), `webhook-timestamp` (unix seconds) and `webhook-signature: v1,<base64>`, the HMAC-SHA256 of `<webhook-id>.<webhook-timestamp>.<body>` keyed with the bytes of the secret after `whsec_`, read as base64. Check it, and refuse a timestamp that is old.

A 2xx answer is delivered. Any other answer, or none within 10 seconds, is tried again 1, 4, 16, 64 and 256 minutes later; after the sixth failed attempt the step is not posted again. The step stays in the history.

**The secret is in this response and nowhere else.** A caller that loses it stops the webhook and registers it again.

The URL is https to a public host. A local or private address is refused, and so is a name that resolves to one when a step is posted. A company has at most 10 live webhooks.

## Request body

`application/json`, required

## Response

A `201` answer carries these fields.

## Status codes

| Status | Meaning |
|---|---|
| `201` | The webhook, with its signing secret. The secret is not returned again by any route. |
| `400` | The URL is not https to a public host (`invalid_webhook_url`), `events` names a code that is not in the history's list, is empty or names one twice (`invalid_webhook_events`), or this company already has 10 live webhooks (`too_many_webhooks`). |
| `401` | No usable credential was sent (`invalid_credentials`). |

</div>
<div class="cvo-op-aside">

</div>
</div>

Source: https://docs.certinvo.com/reference/api/other/register-a-webhook/index.mdx
