Coin price alert
POST /api/coin-alertGet one signed POST at your https URL when a coin's price crosses a level you set.
Details
Give "coin" (a coin id such as bitcoin), "level" (US dollars) and "url". The message says the level was crossed and which way, up or down; it never carries the price. It fires once, whichever way the price crosses from where it was when you made the alert. The price is checked about every 5 minutes, less often when many coins are watched or this server is near its daily reads, so a move that crosses and comes back between checks is missed. An alert lasts 30 days ("expiresAt") and ends then if the level was never crossed. The answer carries a secret; each POST is signed with it in X-Agent402-Signature. A POST your receiver does not accept is tried up to 5 times, with the same delivery id. One wallet holds up to 25. Cancel free with POST /api/coin-alert/cancel and the id and secret. Not investment advice, and not for automatic trading. Deterministic code, no model. Powered by CoinGecko (https://www.coingecko.com/en/api).
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
coin | string | yes | Coin id, such as bitcoin, ethereum or solana (not a ticker). Also accepted as symbol, id, ticker, asset, currency. Up to 100 characters. The example sends bitcoin. |
level | number | yes | The price in US dollars to watch for. The example sends 100000. |
url | string | yes | The https URL that receives the signed POST. No credentials in the URL; it must resolve to a public address. Also accepted as link, uri, href, page. Up to 2048 characters. The example sends https://example.com/. |
Example request
curl -i -X POST https://agent402.tools/api/coin-alert \
-H "Content-Type: application/json" \
-d '{"coin":"bitcoin","level":100000,"url":"https://example.com/"}'Watch a call get paid
POST /api/coin-alert$0.05 USDCPAYMENT-SIGNATUREon 14 chains200 OKAgent402-ReceiptEd25519Example response
{
"id": "ca_3f9a1c2e4b6d8f0a1c3e5a7b9d1f2e4c",
"url": "https://example.com/",
"coin": "bitcoin",
"level": 100000,
"currency": "usd",
"secret": "a402whsec_<64 hex characters>",
"signature": {
"header": "X-Agent402-Signature",
"scheme": "t=<unix seconds>,v1=<hex HMAC-SHA256, with the secret, of \"<t>.<body>\": the timestamp, a dot, and the body as sent>"
},
"event": "coin.level_crossed",
"unsubscribe": {
"method": "POST",
"url": "https://agent402.tools/api/coin-alert/cancel",
"body": {
"id": "ca_3f9a1c2e4b6d8f0a1c3e5a7b9d1f2e4c",
"secret": "<the secret above>"
}
},
"expiresAt": "2027-01-04T12:00:00.000Z",
"registered": false,
"delivers": false,
"note": "example.com is a documentation host: the registration is answered as a real one would be, and nothing is stored or sent.",
"credit": "Powered by CoinGecko (https://www.coingecko.com/en/api)."
}| Field | Type | Always present | In the example |
|---|---|---|---|
id | string | yes | ca_3f9a1c2e4b6d8f0a1c3e5a7b9d1f2e4c |
url | string | yes | https://example.com/ |
coin | string | yes | bitcoin |
level | number | yes | 100000 |
currency | string | yes | usd |
secret | string | yes | a402whsec_<64 hex characters> |
signature | object | yes | 2 fields: header, scheme |
event | string | yes | coin.level_crossed |
unsubscribe | object | yes | 3 fields: method, url, body |
expiresAt | string | yes | 2027-01-04T12:00:00.000Z |
registered | boolean | yes | false |
delivers | boolean | yes | false |
note | string | yes | example.com is a documentation host: the registration is answered as a real o... |
credit | string | yes | Powered by CoinGecko (https://www.coingecko.com/en/api). |
From an MCP client
catalog.call {
"slug": "coin-alert",
"params": {
"coin": "bitcoin",
"level": 100000,
"url": "https://example.com/"
}
}Hosted connector (https://agent402.tools/mcp): paid in the call. Stdio package (npx -y agent402-mcp@0.20.1): pays from a wallet or AGENT402_CREDITS_KEY.
Errors and behavior
- Pay $0.05 per call over x402 or MPP. Wallet-only: this tool reaches the network or stored state, so it has no proof-of-work tier. A prepaid card-credits key (
Authorization: Bearer a402_...) also pays it. - Required:
coin,levelandurl; a rejected input answers 4xx witherror,tool,expected,requiredandexample. - On this route, a call ending in any status of 400 or above is not charged over x402, MPP or a credits key. A Tempo push credential pays before the call; a failure is a refund owed.
- A bodyless
GETorHEADreturns the same 402 quote. - An
Idempotency-Keyreplays the first 200 uncharged (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.05" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/coin-alert", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"coin": "bitcoin",
"level": 100000,
"url": "https://example.com/"
}),
});Get a wallet or run npx -y agent402-mcp@0.20.1 wallet new.
The quote (Python)
import base64, json, urllib.error, urllib.request
req = urllib.request.Request("https://agent402.tools/api/coin-alert", method="POST", data="{\"coin\":\"bitcoin\",\"level\":100000,\"url\":\"https://example.com/\"}".encode(), headers={"Content-Type": "application/json"})
try:
urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
quote = json.loads(base64.b64decode(e.headers["PAYMENT-REQUIRED"]))
print(e.code, [(a["network"], a["amount"]) for a in quote["accepts"]]) # the price, per chain, in base units