Menu

Guides

Price alerts

A price alert watches one coin and sends a signed POST to your HTTPS address when its rule fires. Alerts are on the Starter, Basic and Pro plans, 5 alerts each. Free has none. Create and manage them in the dashboard or with your API key; the alert routes are not counted as calls in your month, only against your calls a minute.

What an alert watches

kindFires when
aboveThe price crosses up through level (US dollars).
belowThe price crosses down through level.
percentThe price moves by percent or more within window (1h or 24h), up or down. The 24h window uses the same 24-hour change as /v2/coins/markets; 1h compares with the price one hour earlier.
  • An alert fires once per cross. A level alert is armed again once the price is back on the other side of its level, at least a minute after it fired. A percent alert is armed again one window after it fired.
  • An alert created when the price is already past its level waits for the price to come back across first, so creating an alert never fires at once.
  • Prices are the ones /v2/simple/price returns, checked every 5 seconds. A coin with no price in the last 15 minutes does not fire.
  • Every delivery is signed with the alert’s own secret. A failed delivery is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then given up. Any 2xx answer counts as delivered; a redirect does not. We never read the answer.
  • A downgrade to Free, a lapsed payment or a closed account stops sending. Your alerts stay and send again when the plan does.

Create an alert

POST https://api.coinprice.dev/v2/alerts, with your live API key. The same routes work from the dashboard, signed in with your session.

curl -X POST "https://api.coinprice.dev/v2/alerts" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"coin":"bitcoin","kind":"above","level":100000,"url":"https://hooks.example.com/coinprice","description":"BTC 100k"}'

Response 201

{
  "alert": {
    "id": "0d6c2b1e-5f1a-4d52-9a8e-3b7f1c2d4e5f",
    "coin": "bitcoin",
    "symbol": "BTC",
    "name": "Bitcoin",
    "kind": "above",
    "level": 100000,
    "url": "https://hooks.example.com/coinprice",
    "description": "BTC 100k",
    "created_at": "2026-11-24T12:00:00Z",
    "last_delivery": null
  },
  "secret": "whsec_… (shown once)"
}

Keep the secret: it is shown once, and only an encrypted copy is stored. A percent alert sends "kind":"percent","percent":5,"window":"24h" instead of level.

Parameters

coinbodyrequired
Coin id, for example bitcoin. Find ids with /v2/coins/list or /v2/search.
kindbodyrequired
above, below or percent.
levelbodyabove and below
Price in US dollars, above 0.
percentbodypercent
Above 0 and at most 1000.
windowbodypercent
1h or 24h.
urlbodyrequired
Where to send alerts: https, port 443, a public host name. Up to 2,048 characters. It is checked when you create the alert and again at every delivery.
descriptionbodyoptional
Up to 200 characters, shown in the dashboard.

Every route

MethodPathWhat it does
POST/v2/alertsCreate an alert. 201 with the alert and its signing secret, shown once.
GET/v2/alertsYour alerts with each one’s last delivery, your plan’s limit and the 20 latest deliveries.
GET/v2/alerts/{id}One alert.
DELETE/v2/alerts/{id}Delete an alert. 204. It stops at once; deliveries not yet sent are dropped.
POST/v2/alerts/{id}/testQueue a test delivery (type webhook.test). 202. One per alert per minute.
POST/v2/alerts/{id}/rotate-secretA new signing secret, shown once. The alert keeps its id.

The delivery

When the rule fires we POST this to your url:

POST /coinprice HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
User-Agent: webhook-delivery/1
Webhook-Signature: t=1795615391,v1=<hex>
{
  "id": "evt_0d6c2b1e5f1a4d529a8e3b7f1c2d4e5f_1",
  "type": "price.alert",
  "created_at": "2026-11-24T14:03:11Z",
  "data": {
    "alert_id": "0d6c2b1e-5f1a-4d52-9a8e-3b7f1c2d4e5f",
    "coin": "bitcoin",
    "kind": "above",
    "level": 100000,
    "price": "100012.4",
    "at": "2026-11-24T14:03:10Z"
  }
}

A percent alert’s data reads:

{
  "alert_id": "…",
  "coin": "bitcoin",
  "kind": "percent",
  "percent": 5,
  "window": "24h",
  "change_percent": "5.21",
  "price": "63120.5",
  "at": "2026-11-24T14:03:10Z"
}
FieldMeaning
idUnique per alert and crossing. The same crossing is never sent under two ids, so use it to ignore a repeat.
typeprice.alert. A test delivery is webhook.test, with data {"alert_id": …}.
created_atWhen the alert fired (UTC).
data.alert_id, coin, kindThe alert, its coin id and its kind (above, below or percent).
data.levelabove and below: the level you set.
data.percent, window, change_percentpercent: the rule, and the change that fired it, in percent, to two decimals.
data.price, atThe price in US dollars that fired it, as text, and the time of that price (UTC).

Verify the signature

Every delivery carries Webhook-Signature: t=<unix seconds>,v1=<hex>. The v1 value is the HMAC-SHA256, with your signing secret as the key, of the text "<t>.<raw request body>". Compute it over the raw bytes you received, compare in constant time, and refuse a t more than 300 seconds from your clock.

Node

import { createHmac, timingSafeEqual } from 'node:crypto'

export function verify(secret, rawBody, header, nowSeconds = Math.floor(Date.now() / 1000)) {
  const parts = Object.fromEntries(header.split(',').map((p) => p.split('=')))
  if (!parts.t || !parts.v1 || Math.abs(nowSeconds - Number(parts.t)) > 300) return false
  const expected = createHmac('sha256', secret).update(parts.t + '.').update(rawBody).digest('hex')
  const a = Buffer.from(expected), b = Buffer.from(parts.v1)
  return a.length === b.length && timingSafeEqual(a, b)
}

Python

import hashlib, hmac, time

def verify(secret: str, raw_body: bytes, header: str) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    if "t" not in parts or "v1" not in parts or abs(time.time() - int(parts["t"])) > 300:
        return False
    expected = hmac.new(secret.encode(), parts["t"].encode() + b"." + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts["v1"])

Errors

Errors return JSON with error, message and request_id, as on every route.

StatuserrorWhen
400invalid_requestThe body is not valid: an unknown field, a missing level, percent or window, a value out of range, or a coin id we do not price.
400bad_urlThe url is not https on port 443, has a login in it, or its host does not resolve to a public address.
401unauthorizedNo key, or an invalid one.
403plan_limitYour plan holds no alerts (Free) or you have all it allows. Delete one or upgrade.
403forbiddenA test key. Alerts need a live key.
404not_foundNo such alert on your account.
429rate_limitedOver your calls a minute, or a second test within a minute (Retry-After says when).
429too_many_pendingThe alert has 20 deliveries waiting; try a test later.
503dns_busyThe host name did not resolve in time. Try again.
503unavailableAlerts are temporarily unavailable. Try again.