Webhooks
Webhooks send a signed HTTPS POST to your server when a threshold rule of your organization fires. Use them to respond to a custom alert rule without polling the API.
Precip webhooks follow the Standard Webhooks spec, so you can verify them with the official libraries.
Webhooks and API-managed alert rules are included on Growth ($500/mo) and Enterprise API plans, and available on Starter + Webhooks ($150/mo). View plans & subscribe →. Free and personal (hobby) keys receive 403 commercial_tier_required, and Starter keys without webhooks receive 403 webhooks_plan_required.
What fires and when
You can create threshold alert rules via POST /api/v1/alert-rules (or the create_alert_rule MCP tool) as well as in the Precip app — for example "more than 25.4 mm of rain in 24 hours" or "wind above 15 m/s in the forecast". When a rule fires, Precip sends one threshold_rule.triggered event to each of your endpoints that listens to that rule. The event lists each location where the value crossed the threshold.
- Webhooks and alert rules belong to an organization. Only admins of the organization can manage them. If you are on a paid API plan and do not yet belong to an organization, Precip automatically creates a default organization for you and migrates any personal saved locations into it. When you belong to one organization,
orgIdis optional on all location, alert rule, and webhook requests. - Each endpoint gets at most one event per rule in each cooldown period. The cooldown follows the
frequencyof the rule (hourly,daily, orweekly). - An organization can have 10 endpoints (5 alert rules on Starter + Webhooks, 10 on Growth, and up to 1,000 on Enterprise).
Delivery channels & recipients
- API-created alert rules (
POST /api/v1/alert-rules): Created as webhook-only (delivery_medium: "webhook"). They do not send mobile push notifications or emails by default. When a rule fires, Precip delivers a signedthreshold_rule.triggeredPOST to every enabled webhook endpoint on the same organization that subscribes tothreshold_rule.triggeredand either hasruleIds: null(all organization rules, the default) or includes that rule'sidinruleIds. - Adding push or email in the Precip app: API-created alert rules also appear in Settings → Notifications in the Precip app with a Webhook badge. Organization admins can optionally add Push and/or Email channels there to notify specific team members (or all organization members) in addition to the webhook delivery.
- App-created alert rules: Rules created in the Precip app keep their push notifications and emails unchanged, and also trigger matching organization webhook endpoints as an additional channel.
Code
To route a rule to only one webhook endpoint (instead of every endpoint on the organization), pass the returned rule id in ruleIds when creating or updating that endpoint via POST /api/v1/webhooks or PATCH /api/v1/webhooks/:id.
Create an endpoint
Send your API key as Authorization: Bearer YOUR_API_KEY, as for all other requests. Copy your key from API Keys & Subscriptions (for self-serve Starter + Webhooks and Growth plans) or from Settings → API & AI assistants in the Precip app (for Enterprise account keys). The key must belong to an admin of the organization.
Code
The response has the endpoint and its signing secret:
Code
The times in API responses are UTC with milliseconds, for example 2026-11-01T09:30:00.000Z. The times in an event body have no milliseconds. Use an ISO 8601 parser for both.
| Field | Notes |
|---|---|
url | Required. See URL rules. |
description | A note for you, up to 200 characters. |
events | Leave it out to get threshold_rule.triggered. |
ruleIds | Only send events for these rules (1 to 200 IDs). Leave it out, or send null, to get every rule of the organization. An empty list is not valid. |
orgId | Which organization. Leave it out when you are an admin of only one organization or when using an organization-scoped commercial API key. |
If you are an admin of more than one organization and using a user-scoped commercial key, pass orgId (400 org_required otherwise). Organization-scoped commercial keys are bound to their organization automatically (passing a different orgId returns 403 org_key_mismatch). Call GET /api/v1/account or GET /api/v1/orgs (see the API reference) to list your organizations and their IDs.
See the API reference for all webhook requests: list, get, update, delete, rotate the secret, send a test event, and list deliveries.
The signing secret
The secret is shown only once: in the response of the create request and of the rotate request. Store it in your secret manager. List and get never return it.
To change the secret, rotate it:
Code
The response has the new secret. For the next 24 hours, the old secret stays valid: each delivery has two signatures, one from the new secret and one from the old secret. Put the new secret on your server within these 24 hours. After that, only the new secret signs.
Only the secret just before the latest rotation stays valid. If you rotate again within the 24 hours, the older secret stops at once. So if you lose the response of a rotation, put the secret of the next rotation on your server at once.
The request
Each delivery is a POST with a JSON body and these headers:
| Header | Value |
|---|---|
content-type | application/json |
user-agent | Precip-Webhooks/1.0 |
webhook-id | The delivery ID, for example msg_Fp4Rk8Wz2Ns6Qt9Lm3Xv5H. It is the same on each retry. |
webhook-timestamp | The time of this attempt, in Unix seconds. |
webhook-signature | One or more signatures, separated by a space: v1,<base64>. There are two during a rotation. |
threshold_rule.triggered
Code
| Field | Notes |
|---|---|
timestamp | When the rule fired (UTC). |
rule.alert_type | precipitation, wind, or temperature. |
rule.observation_type | observation (what fell or was measured) or forecast. |
rule.direction | above or below the threshold. |
rule.threshold, rule.unit | The threshold of the rule. |
rule.window_hours | The length of the window of the rule. |
rule.forecast_probability_pct | The minimum chance (0–100) for a precipitation forecast rule, else null. |
window | The hours that Precip checked, rounded to the hour. For observations, the last window_hours hours. For forecasts, the next window_hours hours. |
locations | Each location where the value crossed the threshold, with the value in that window. |
Units are always metric, whatever your app settings: mm for precipitation, m/s for wind, and C for temperature.
webhook.test
Sent by Send a Test Event:
Code
Ignore event types that you don't know. Precip can add types and fields later.
Verify the signature
Always verify the signature before you use an event. Use the raw body as you received it. If you parse the JSON and serialize it again, the bytes change and the signature fails.
With the Standard Webhooks library (recommended)
JavaScript (npm install standardwebhooks), with Express:
Code
Python (pip install standardwebhooks), with Flask:
Code
The libraries check the timestamp (5 minutes), compare in constant time, and accept any of the signatures in the header.
Without a library
The signature is an HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{raw body}. The key is the part of the secret after whsec_, decoded from base64. To verify:
- Reject the request if the timestamp is more than 5 minutes from your clock. This stops replays.
- Compute the signature and encode it in base64.
- Split
webhook-signatureat each space. Accept the request if anyv1,entry is equal to your signature. Compare in constant time.
Node:
Code
Python:
Code
Respond and retry
Return a 2xx status within 10 seconds. Do the work after you respond, for example in a queue. Precip reads only the first 1 KB of your response and doesn't follow redirects.
| Your response | What Precip does |
|---|---|
2xx | Success. |
408, 429, 5xx, a timeout, or a connection or TLS error | Retry. |
3xx or another 4xx | Failure. No retry. |
Precip makes up to 8 attempts. The wait after each failed attempt:
| After attempt | Wait |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 5 hours |
| 6 | 10 hours |
| 7 | 10 hours |
After the 8th failed attempt (about 28 hours after the first), the delivery has the status failed.
Skip duplicates
A retry can come after your server already handled the event, for example when your response was too slow. Each attempt of a delivery has the same webhook-id. Save the IDs that you handled, and skip an event with an ID that you already saw. Keep the IDs for at least 2 days.
Endpoints that fail are turned off
When 3 deliveries in a row end as failed, Precip turns the endpoint off (enabled: false, disabledReason: "failing") and sends an email to the admins of the organization. A success resets the count. While an endpoint is off, Precip sends it no events, and events of that time are not sent later.
Repair your server, then turn the endpoint on again. Then send a test event to check it:
Code
This also clears disabledReason and the failure count. You can turn an endpoint off yourself with {"enabled": false}.
Test and the delivery log
Send a webhook.test event to check your server:
Code
The response is 202 with the deliveryId. The event is signed and retried like a real event, and is usually sent within a minute.
Precip sends a test event only while the endpoint is on. On an endpoint that is off, the test delivery ends as failed with the error endpoint disabled, and no request goes to your server. After a repair, turn the endpoint on first, then send the test.
The delivery log shows the last deliveries, newest first, with the payload, the number of attempts, the last status code, the error, and the first 1 KB of your response:
Code
limit is 1 to 100 (default 20). status is pending, succeeded, or failed. Precip keeps deliveries for 30 days. You can't send a delivery again from the log.
URL rules
Precip checks the URL when you create or change an endpoint, and again before each attempt.
- Use
https://. Precip checks the TLS certificate of your host. - Use a public host. Precip refuses
localhost, names that end in.local,.internal, or.localhost, and private, loopback, link-local, and other non-public IP addresses (IPv4 and IPv6). Each address that your host name resolves to must be public. - Don't put a user name or password in the URL. To identify Precip, verify the signature.
- Up to 2,048 characters.
- Precip doesn't follow redirects. A
3xxresponse is a failure.
If your DNS points to a non-public address at the time of an attempt, Precip retries that attempt.
Errors
The error body has an error message and a code.
| Status | code | Meaning |
|---|---|---|
| 400 | invalid_webhook | A field or query value is not valid. The message tells which. |
| 400 | org_required | orgId is missing, and you are an admin of more than one organization, or of none. Pass orgId. If you are not an admin of that organization, you then get 403 webhook_forbidden. |
| 400 | invalid_rule_ids | A rule ID in ruleIds is not a rule of the organization. |
| 403 | commercial_tier_required | Your API key doesn't have commercial access. The body has an upgradeUrl. |
| 403 | webhooks_plan_required | Your Starter plan does not include webhooks. Upgrade to Starter + Webhooks, Growth, or Enterprise. |
| 403 | org_required | You are not in an organization. |
| 403 | org_key_mismatch | The API key is scoped to a different organization than orgId. |
| 403 | webhook_forbidden | You are not an admin of the organization. |
| 403 | account_required | The key isn't tied to a Precip user or organization. |
| 404 | webhook_not_found | No endpoint with this ID in your organizations. |
| 409 | webhook_limit_reached | The organization has 10 endpoints. Delete one to add another. |
| 409 | webhook_secret_conflict | Another rotation changed the secret while this call ran. Use the secret from that call, or rotate again. |
| 503 | webhooks_unavailable | Webhooks are not available right now. Try again later. |
Webhook requests count toward a limit of 30 requests a minute per account (429 with a Retry-After header).
Need help?
Contact [email protected].