# Post into a chat with a webhook

> Send alerts from an alarm panel, a tracker or any other system into a Vigil chat with a webhook. One HTTP POST with a JSON body, and no token is needed.

Source: https://vigilsecure.net/docs/developers/webhooks/

A webhook is a secret URL on a group chat. Any system that can send an HTTP request can post
a message through it: an alarm panel, a vehicle tracker, a monitoring tool. It needs no
[access token](https://vigilsecure.net/docs/developers/api.md#authentication) and can do nothing except post into
that one chat.

## Create a webhook

Somebody who owns the group chat creates the webhook in the console:

1. Open the group's **Channel details** and, under **Webhooks**, choose **New**.
2. Enter a **Name**, such as `Alarm panel`. Messages appear under this name.
3. Choose **Create webhook** and copy the **Webhook URL**. It is shown once.

## Post a message

Send an HTTP `POST` with a JSON body to the URL:

```sh
curl -X POST "$WEBHOOK_URL" \
  -H "Content-Type: application/json" \
  --data '{"content": "Zone 4 alarm at Rosebank Mall, 02:14"}'
```

|                 |                                          |
| --------------- | ---------------------------------------- |
| **Body**        | `{ "content": "…" }`                     |
| **`content`**   | Plain text of up to 8,000 characters     |
| **Success**     | HTTP 204, and the message is in the chat |
| **Rate limit**  | 30 posts a minute for each webhook       |
| **Credentials** | None. The URL itself is the only secret. |

For a system that can only send email or SMS, use an automation service that turns the
email into a webhook.

## Keep it safe

- Anyone who has the URL can post into that chat. Store it as a secret in the other system.
- Use one webhook for each system. If a URL leaks, **Revoke** that webhook in **Channel
  details** and create a new one without disturbing the others.
- A webhook can only post text into its own chat. It cannot read anything.

## Webhooks and agents

A message from a webhook does not wake an [agent](https://vigilsecure.net/docs/concepts/agents.md) by itself. That is
deliberate: it stops an outside system from driving an agent directly. A person in the chat
can mention the agent, or the agent can read new alerts on a schedule.
[Alarm and system alerts](https://vigilsecure.net/docs/examples/alarm-integrations.md) shows both.

## Going the other way

To send what happens in Vigil to another system, for example to open a ticket when a patrol
is missed, read it from that system through the [Vigil API](https://vigilsecure.net/docs/developers/api.md).

## Related

- [Communication](https://vigilsecure.net/docs/concepts/communication.md#webhooks-let-another-system-post-into-a-chat)
- [Alarm and system alerts](https://vigilsecure.net/docs/examples/alarm-integrations.md)
