# x402-notify
[](./LICENSE)
[](https://x402.org)
[](https://x402.org)
> One message, one payment, one receipt โ Telegram and SMTP email delivered per-message with the proof of delivery in the response.
`POST /telegram` delivers a message through a Telegram bot and returns the message id, the resolved chat, and the delivery timestamp. `POST /email` relays a message over SMTP and returns the **acceptance receipt** โ the literal line the receiving server sent back when it took responsibility for the message, plus the Message-ID and the per-recipient accepted/rejected split. Both cost $0.002 and both put the receipt in the 200 body.
## Why x402 for this
Notification providers sell in blocks: a monthly plan, a bundle of credits, a minimum commitment. An agent that needs to send eleven messages this month shouldn't be buying ten thousand. x402 prices a message at $0.002 and settles it in USDC at send time, so cost tracks sends exactly. And because the settlement receipt and the delivery receipt come back in the same response, the record of *what you paid for* and *what was delivered* is a single object.
## Quickstart
```bash
git clone https://github.com/nirholas/x402-notify
cd x402-notify
npm install
npm run dev # http://localhost:4025
```
No configuration needed โ the server ships with the suite's receive addresses and a dry-run mode that validates the request exactly as a live send would and returns the same receipt shape, so the demo works before you have a bot token or an SMTP server. Set `PAY_TO_ADDRESS` / `SOLANA_PAY_TO_ADDRESS` to receive funds yourself.
```bash
# 1. Unpaid โ 402 listing both rails
curl -i -X POST http://localhost:4025/telegram \
-H 'Content-Type: application/json' \
-d '{"chatId":"123456789","text":"Deploy finished - all 412 tests green."}'
# 2. Paid, via any x402 client
npm run client
```
## API
| Route | Price | What you get back |
|---|---|---|
| `POST /telegram` | **$0.002** | `{messageId, chat, deliveredAt}` โ the message id and the chat Telegram resolved, usable later to reply to or edit the message |
| `POST /email` | **$0.002** | the SMTP acceptance receipt โ raw `250 โฆ` response, reply code, Message-ID, host โ plus accepted/rejected recipients and the envelope as sent |
| `GET /health` | free | Liveness, active data source, configured rails |
| `GET /.well-known/x402` | free | Machine-readable discovery manifest |
Every paid route returns the purchased artifact **in the 200 body**. Nothing is deferred to a webhook or a later fetch.
Full reference: [docs/api.md](docs/api.md) ยท [openapi.json](openapi.json) ยท [skill.md](skill.md)
## How x402 works
```
agent x402-notify facilitator
โ GET /telegram โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโถโ โ
โ 402 + accepts[base, solana] โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ sign USDC authorization โ โ
โ retry + X-PAYMENT โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโถโ verify + settle โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโถโ
โ 200 + artifact โ โ
โ + X-PAYMENT-RESPONSE โ โโโ tx hash / signature โโโโโโโค
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค โ
```
**Pay in USDC on Base or Solana โ your client picks the rail.** The 402 challenge always lists both:
| Rail | Network | Asset | payTo |
|---|---|---|---|
| EVM | `base-sepolia` (`base` via `NETWORK=base`) | USDC | `0x40252CFDF8B20Ed757D61ff157719F33Ec332402` |
| Solana | `solana` | USDC (SPL) | `WwwuGbqHrwF5RG89KhUbmRWEvjnRH9k5kVM5p7T3WwW` |
The Solana rail's `extra.feePayer` is a public facilitator sponsor account that pays the SOL network fee, so a buyer needs only USDC โ no SOL for gas. Wallets that sign serialized transactions (Phantom, most agent SDKs) can use the built-in helpers at `POST /api/x402-checkout?action=prepare|encode`.
## Real backend / API keys
The two channels are configured independently, so you can enable either or both.
| Env var | Unlocks |
|---|---|
| `TELEGRAM_BOT_TOKEN` | Real Telegram delivery. Free from [@BotFather](https://t.me/botfather) โ send it `/newbot`. |
| `TELEGRAM_BASE_URL` | Point at a self-hosted Bot API server โ rarely needed. |
| `SMTP_HOST` | Real email relay. Works with any SMTP server. |
| `SMTP_PORT` | Default `587` (STARTTLS). `465` switches to implicit TLS automatically. |
| `SMTP_USER` / `SMTP_PASS` | Credentials. Omit both for an unauthenticated relay. |
| `SMTP_FROM` | Default From address. Falls back to `SMTP_USER`. |
| `SMTP_SECURE` | Force implicit TLS on or off, overriding the port heuristic. |
**Without them, everything still works โ and tells you so.** An unconfigured channel validates the request exactly as a live send would (address syntax, length limits, required fields), then returns `"delivered": false` with a `dryRunReason`. The receipt has the same shape as a live one, so you can build and test the whole flow, then flip a single env var to make it real. There is no mode in which this service claims a delivery it did not make.
To find a Telegram `chatId`: message your bot, then `GET https://api.telegram.org/bot<TOKEN>/getUpdates` and read `result[].message.chat.id`. For a channel, use `@channelusername` and make the bot an admin.
## Human checkout
For a browser-facing checkout, drop in [`@three-ws/x402-payment-modal`](https://www.npmjs.com/package/@three-ws/x402-payment-modal) โ it reads the 402 challenge and drives the whole connect โ sign โ settle flow for **both** rails (Phantom on Solana, any injected wallet on EVM), with SIWX re-entry so a returning buyer skips the wallet prompt, and client-side spending caps that stop an agent or a mis-click from over-spending. Reference it from npm or the CDN; it is a separate proprietary package and is never vendored here.
## For AI agents
- **[`skill.md`](skill.md)** โ the agent-facing contract: every endpoint, its price, its response schema, and how to pay. Point your agent at this file.
- **`GET /.well-known/x402`** โ machine-readable discovery ([manifest](public/.well-known/x402)). Lists both rails per resource.
- **[`examples/mcp-tool.md`](examples/mcp-tool.md)** โ expose this service as an MCP tool for Claude in about 30 lines.
- **[`examples/agent-client.ts`](examples/agent-client.ts)** โ a complete paid call with `x402-fetch`, printing the artifact and the decoded settlement receipt.
- **Discovery/listing** โ indexable by [x402scan.com](https://x402scan.com), the [x402 Bazaar](https://x402.org), and [agentic.market](https://agentic.market). Deploy, then submit your public base URL; all three read `/.well-known/x402`.
## Docs
<https://nirholas.github.io/x402-notify/> โ [tutorial](docs/tutorial.md) ยท [API reference](docs/api.md) ยท [for agents](docs/agents.md)
## Support
nichxbt@gmail.com
## License
Apache-2.0 โ see [LICENSE](LICENSE).
Part of the [x402 Suite](https://github.com/nirholas/x402-suite).
## Star History
[](https://www.star-history.com/#nirholas/x402-notify&Date)
<!-- three.ws:growth -->
## Support the project
If x402-notify saves you time, **[star it on GitHub](https://github.com/nirholas/x402-notify)**. Stars are how other developers and AI agents find the repositories worth trusting, and they cost you one click.
Know someone who would use it? [Post on X](https://twitter.com/intent/tweet?text=x402-notify%3A%20Real%20message%20delivery%20per-message%3A%20Telegram%20bot%20messages%20and%20SMTP%20email%20with%20delivery%20receipts&url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fx402-notify) ยท [Share on Bluesky](https://bsky.app/intent/compose?text=x402-notify%3A%20Real%20message%20delivery%20per-message%3A%20Telegram%20bot%20messages%20and%20SMTP%20email%20with%20delivery%20receipts%20https%3A%2F%2Fgithub.com%2Fnirholas%2Fx402-notify) ยท [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fx402-notify) ยท [Submit to Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fgithub.com%2Fnirholas%2Fx402-notify&t=x402-notify%3A%20Real%20message%20delivery%20per-message%3A%20Telegram%20bot%20messages%20and%20SMTP%20email%20with%20delivery%20receipts) ยท [Share on Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fx402-notify&title=x402-notify%3A%20Real%20message%20delivery%20per-message%3A%20Telegram%20bot%20messages%20and%20SMTP%20email%20with%20delivery%20receipts)
## Built for AI agents too
Coding agents and LLM tooling can read this repo directly: [AGENTS.md](./AGENTS.md), [llms.txt](./llms.txt), [llms-full.txt](./llms-full.txt). Point an agent at `https://github.com/nirholas/x402-notify` and it has the context it needs.
## More from the same author
- [All repositories by nirholas](https://github.com/nirholas/nirholas#readme): the full catalog, grouped by topic
- [three.ws](https://three.ws): the platform for 3D AI agents with Solana wallets, a skill marketplace and x402 payments
- Questions or ideas: [open an issue](https://github.com/nirholas/x402-notify/issues) or [start a discussion](https://github.com/nirholas/x402-notify/discussions)
## Contributors
[](https://github.com/nirholas/x402-notify/graphs/contributors)
<!-- /three.ws:growth -->
<!-- nirholas:watermark -->
---
<p align="center">
Built by <a href="https://github.com/nirholas"><b>nirholas</b></a> ยท <a href="https://x.com/nichxbt">@nichxbt</a> ยท <a href="https://github.com/nirholas">github.com/nirholas</a>
</p>
<!-- /nirholas:watermark -->