Let your users pay in dollars.
Approved by them, every time.
Espresso Cash Connect links your website to your users' Espresso Cash wallets. Charge them and sell subscriptions in USDC on Solana. Every payment is approved by the user, in the Espresso Cash app or within a session they approved there. You never hold a key that can move their money.
charge("4.50"): approved in the app, or paid at once within a session the user started.How it works
Espresso Cash wallets are smart wallets on Solana, owned by a passkey (Face ID, fingerprint or device code). Your site talks to Espresso over HTTPS: your page through a small script, your backend with an API key.
Your page ── connect() ──▶ Espresso's window (@username → number → app) ──▶ connected
Your page ── charge("4.50") ──▶ approved in the app ──▶ paid (the user may also start a session)
Your page ── charge("2.00") ──▶ live session + Espresso's co-signer ──▶ paid at once
Your backend ── API key ──▶ server charges, subscriptions, creators
Espresso ── signed webhook ──▶ your backend (paid, declined, session ended, disconnected…)
| Term | What it means |
|---|---|
| Connection | Who the user is to your site. Identity only: nothing is paid, nothing is added to the wallet. It lasts until the user disconnects (or your backend does). |
| One-shot charge | The default. The user approves that one payment in the Espresso Cash app. |
| Session | A budget (USDC) and an end time the user gives your site while approving a payment. Charges within it are paid at once, if every co-signer rule passes. |
| Registered site | A site registered on connect.brij.fi/developers with a proven domain. It gets espresso_user_ids, the server API, webhooks, subscriptions and creators, and can show a verified badge. |
Quickstart
Connect a user and charge them from your page in a few lines.
- Add the script (served by Espresso, no build step):
<script src="https://connect.brij.fi/sdk.js"></script> <script> const espresso = EspressoConnect({ siteName: 'My shop' }); </script> - Connect, from a click.
connect()opens Espresso's window on connect.brij.fi. The user types their Espresso username (e.g.@alice). Their app gets a notification and shows two numbers; the window shows one of them. The user taps the same number in the app and confirms with Face ID or fingerprint. A wrong number cancels the request, so someone who types another person's username can't connect to them. The app shows your site's domain (and your name with a ✓ only once your domain is proven, see Register). The window shows "My shop wants to connect to your wallet"; connecting gives your site no access to their money.
The connection is kept in this browser (a non-extractable Ed25519 site key in IndexedDB that signs your page's requests). CallconnectButton.onclick = async () => { if (!(await espresso.isConnected())) { const { walletAddress, connectionId } = await espresso.connect(); } };connect()from a click, or the browser blocks the window. - Charge an amount in USDC:
payButton.onclick = async () => { try { const result = await espresso.charge('4.50', { // recipient: 'So1ana…', // required if your site isn't registered (else: your payout wallet) onApproval: ({ appUrl, payInBrowser }) => { showMessage('Approve it in the Espresso Cash app'); }, }); // { signature, chargeId, approved, session: { budget, left, expiresAt } | null } showPaid(result.signature); } catch (e) { if (e.code === 'declined') showMessage('Not approved'); else if (e.code !== 'cancelled') showMessage(e.message); } }; - Sessions come by themselves. When the user approves a charge in the app, they can also give your site a budget (e.g. 50 USDC for a day).
charge()then resolves withsessionset, and later charges within it are paid at once, with no approval, as long as Espresso's rules allow. Pass{ session: false }to never offer one.
SDK reference
| Call | What it does |
|---|---|
EspressoConnect({ siteName, pollInterval }) | Creates the client. siteName (default document.title, up to 60 characters) is what the user sees until your site is registered, then your registered name is shown. |
isConnected() | { walletAddress, connectionId } or null. |
connect() | Opens Espresso's window (from a click). Resolves with { walletAddress, connectionId }. |
charge(amount, options) | amount: a USDC string like "12.50" (up to 6 decimals). Options: recipient (default: your registered payout wallet), session (default true), onApproval, signal (an AbortSignal). Resolves with { signature, chargeId, approved, session }; session.budget and session.left are in base units (6 decimals). |
linkProof(nonce) | Proves this connection to your backend: see Link a user. |
payInBrowser(chargeId) | Deprecated: payments are approved in the Espresso Cash app. Opens Espresso's window on a charge waiting for approval, which asks the user to approve it on their phone (from a click). For a server charge, pass its espresso_charge_id. |
disconnect() | Forgets the connection in this browser. The user disconnects your site for good in the app or on connect.brij.fi. |
Errors are Errors with a code: cancelled (the user closed the window), blocked (the browser blocked the window), declined (declined, or not approved within 15 minutes), not_connected, needs_app, network, session_key_missing, invalid_amount, or any API error code.
Link a user to your account
Your page knows the user is connected; your backend needs proof before it trusts that. The page signs a nonce your backend issued, and your backend has Espresso check it. You get the user's espresso_user_id: stable for your site, and different on every site, so sites can't link users together. Registered sites only.
- Your backend makes a random
nonce(1 to 128 characters, no:or newline) and keeps it in the user's session. - Your page signs it and sends the proof to your backend:
const proof = await espresso.linkProof(nonce); // { siteKey, nonce, timestamp, signature } await fetch('/api/espresso/link', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(proof) }); - Your backend checks the nonce is the one it issued, then posts the proof, unchanged, within 5 minutes:
const res = await fetch('https://api.brij.fi/connect/v2/server/connections/verify', { method: 'POST', headers: { Authorization: `Bearer ${process.env.ESPRESSO_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ siteKey: proof.siteKey, nonce: proof.nonce, timestamp: proof.timestamp, signature: proof.signature }), }); if (!res.ok) throw new Error('not linked'); // 403 permission_denied: bad or old proof const { espresso_user_id, connection_id, connected_at } = await res.json(); // store espresso_user_id on your user
Espresso checks that the site key belongs to a live connection of your site and that it signed espresso-connect:link:v2:<the connection's origin>:<nonce>:<timestamp> less than 5 minutes ago. The nonce check is yours: it stops a proof from being replayed into another account.
You also get connection.created (with espresso_user_id) by webhook when a user connects, and connection.deleted when they disconnect.
Register your site
- Sign in on connect.brij.fi/developers with your Espresso Cash passkey (no wallet yet? get the Espresso Cash app). Your sites belong to that wallet.
- Register: a name, your website's https origin (e.g.
https://myshop.com), and optionally a logo URL and a webhook URL. You get your API key (esk_…) and webhook secret (whsec_…), shown once: save them on your servers. Lost them? Make new ones on the same page (the old one stops at once). - Prove your domain with either of these, then press Check my domain:
The page shows your site id and token. The file is fetched over https, without following redirects, up to 16 KB. Once proven, your site goes from# a file, served at https://myshop.com/.well-known/espresso.json {"site_id": "<your site id>", "token": "esp_…"} # or a DNS TXT record _espresso.myshop.com TXT "espresso-verify=esp_…"PENDINGtoACTIVE: the server API works, and users who connected from your site before get theirespresso_user_id. The proof is checked again every day. - Set your payout wallet: Pay me in this wallet makes the wallet you signed in with your payout wallet, where charges and subscriptions land. It must be one of your own wallets; nobody else sets it, and an API key can't change it.
The verified badge
Users see your name and logo with a ✓ while your site is ACTIVE, has a name and a logo, and its domain proof is less than 72 hours old. If a daily check fails, the badge drops (your site stays ACTIVE) until the proof is back.
What can be registered
https://hostonly: no port, path, query or credentials; a lower-case ASCII host with a dot (internationalized andxn--names are refused), no IP address, no_.- Not Espresso's or BRIJ's domains, nor any host containing
brijorespressocash; notlocalhost,example.com,testand the like; not wildcard-DNS services (nip.io,sslip.io…). - Lookalikes are refused: a host that reads like an active site's (
rn→m,1/i→l,0→o,vv→w, hyphens,www.and the TLD ignored; e.g.getIydi.comnext togetlydi.com) getslookalike_domain. - One site per host (
host_taken), at most 3 sites per owner and 10 registrations a day (too_many_sites). Logo and webhook URLs: https on port 443, hosts by the same rules.
Charge from your server
Your backend can charge a linked user directly: the money always goes to your payout wallet (or a creator you name). Amounts here are USDC decimal strings like "4.50".
curl https://api.brij.fi/connect/v2/server/charges \
-H "Authorization: Bearer $ESPRESSO_API_KEY" -H "Content-Type: application/json" \
-d '{"id":"order-9912","espresso_user_id":"eu_7Hq…","amount":"4.50","memo":"Day pass"}'
{ "charge": { "id": "order-9912", "espresso_charge_id": "6f1c…", "status": "awaiting_owner",
"amount": "4.50", "recipient": "<your payout wallet>", "memo": "Day pass",
"created_at": "2026-11-21T12:00:00Z", "expires_at": "2026-11-21T12:15:00Z" } }
idis your idempotency key (1 to 128 characters): the sameidalways answers the same charge, whatever else you send. Retry safely.- One-shot (
awaiting_owner): the user gets a push and approves in the app within 15 minutes. Follow it withGET /connect/v2/server/charges/{id}or thecharge.paid/charge.declinedwebhooks. A user without the app can pay it from your page:espresso.payInBrowser(espresso_charge_id). - Session (
prepared): the user has a live session your backend holds the key of, and every rule passes. Signmessagewith that key and post the signature within 90 seconds:sent, paid.
Paying through a session from your server
Send a fresh sessionKey (an Ed25519 public key, base58, that your backend holds) with a charge. It is offered to the user with the approval; if they start a session with it, your later charges are prepared and paid with no approval:
import crypto from 'node:crypto';
const B58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
function base58(bytes) {
let n = BigInt('0x' + (Buffer.from(bytes).toString('hex') || '0'));
let s = '';
while (n > 0n) { s = B58[Number(n % 58n)] + s; n /= 58n; }
for (const b of bytes) { if (b !== 0) break; s = '1' + s; }
return s;
}
// A fresh session key for this user: keep privateKey (encrypted) on your server.
export function newSessionKey() {
const { publicKey, privateKey } = crypto.generateKeyPairSync('ed25519');
const raw = Buffer.from(publicKey.export({ format: 'jwk' }).x, 'base64url');
return { publicKey: base58(raw), privateKey };
}
// Sign a prepared charge's message (base64) with the session key.
export function signMessage(messageB64, privateKey) {
return crypto.sign(null, Buffer.from(messageB64, 'base64'), privateKey).toString('base64');
}
// POST /connect/v2/server/charges { id, espresso_user_id, amount, sessionKey: key.publicKey }
// → status "prepared", with message and charge.session_key:
// POST /connect/v2/server/charges/{id}/sign { signature: signMessage(message, key.privateKey) }
A key is used once (session_key_used). A user has at most one session with your site: a session started from your page's charge() is held by that browser, not by your backend, so only sign when charge.session_key is a key you hold.
Statuses
| Status | Meaning |
|---|---|
prepared | A live session can pay: sign message with session_key within 90 s. |
sent | Paid through the session, confirmed on-chain (signature). |
awaiting_owner | Waiting for the user's approval, until expires_at (15 minutes). |
approved | The user approved and paid (signature; session set if they also started one). |
declined | Declined, or not answered in 15 minutes. |
failed | The payment failed. |
Paid means sent or approved: the charge.paid webhook says which. Page charges use the same statuses in upper case (SENT, AWAITING_OWNER…).
Sessions and the co-signer rules
A session is temporary spending power for one connection: a budget in USDC and an end time. It only starts when the user approves a real payment in the app and picks a budget (20, 50 or 100 USDC) and a duration (an hour, a day or 30 days) from the offer. Nothing is ever started behind their back.
- The budget is enforced on-chain by the wallet itself; the end time by Espresso's co-signer.
- A session charge needs two signatures: the session key's (held by your page or your backend) and Espresso's co-signer. A stolen session key alone can't pay anything.
- One session per site and user; a new one replaces the old.
- The user ends it any time in the app (Apps → your site); disconnecting ends it too. You get
session.startedandsession.endedwebhooks. - Sessions are in beta: for users outside it, every charge is one-shot.
When Espresso co-signs
Before co-signing any session charge, Espresso checks, in this order:
| Rule | In plain words |
|---|---|
session_not_live | The session is live and its end time hasn't passed. |
swig_instructions | The transaction does nothing else with the wallet: no other wallet instruction than the session's own payment. |
simulation_failed | The exact transaction simulates successfully. |
wallet_outflow | Only USDC leaves the wallet: no SOL, no other token, no account closed, no owner or authority changed. |
over_budget | The USDC leaving is within what's left of the budget. |
site_blocked | Your site isn't blocked by Espresso. |
velocity | At most 3 charges a minute per session. |
If any rule fails, the charge isn't lost: it becomes a one-shot charge the user approves in the app (awaiting_owner). The session and blocked-site rules are checked again right before co-signing. A blocked site's live sessions end at once (session.ended, reason blocked).
Creators
Platforms (memberships, fan clubs, courses, tips) can have a server charge or a subscription pay a creator directly and keep a fee. Add two fields: payee (the creator's espresso_user_id) and fee_percent.
- The creator connects their Espresso Cash wallet to your site, like any user, and you link them.
- They confirm you may pay them:
They get a push and confirm in the app within 24 h:curl https://api.brij.fi/connect/v2/server/payees \ -H "Authorization: Bearer $ESPRESSO_API_KEY" -H "Content-Type: application/json" \ -d '{"espresso_user_id":"eu_anna…","name":"@anna"}'payee.created(orpayee.declined). Asking again re-sends a pending or expired request, or renames an active creator. Only the creator can make their wallet a payee, so a leaked API key can't redirect anyone's money. - Charge for the creator:
The fan sees who is paid and your fee ($4.00 to @anna, $1.00 to you) and approves both transfers in one transaction.curl https://api.brij.fi/connect/v2/server/charges \ -H "Authorization: Bearer $ESPRESSO_API_KEY" -H "Content-Type: application/json" \ -d '{"id":"tip-881","espresso_user_id":"eu_fan42…","amount":"5.00","memo":"Tip for @anna", "payee":"eu_anna…","fee_percent":"20"}'charge.paidcomes only once both have landed.
fee_percent: a decimal string from"0"to"50"with at most 2 decimals ("12.5","0.25"; not"50.01","5%"or"1e1"). The fee is rounded down to the smallest USDC unit (0.000001); the creator gets the rest, which must be more than 0.fee_percentwithoutpayeeisinvalid_fee_percent.- The fee always goes to your payout wallet. The payee must be an active creator of your site, still connected, and not the payer.
- Creator charges are approved in the app: a wallet without the app gets
needs_appfrompayInBrowser. Page charges can't carry a creator split.
Send money to your users
Prizes, cashback, refunds: send USDC yourself to the user's wallet. Get its address from the server API (wallet_address on connections) and send USDC on Solana from any wallet you control. No approval needed: it's just a transfer.
curl https://api.brij.fi/connect/v2/server/connections/eu_7Hq… \
-H "Authorization: Bearer $ESPRESSO_API_KEY"
→ { "espresso_user_id": "eu_7Hq…", "connection_id": "…", "wallet_address": "9xQe…", "connected_at": "…", "human": {…} }
Subscriptions
Monthly plans that renew by themselves: the user approves once in the app, then is charged every 30 days, with no approval, until they or you cancel. Needs your payout wallet.
curl https://api.brij.fi/connect/v2/server/subscriptions \
-H "Authorization: Bearer $ESPRESSO_API_KEY" -H "Content-Type: application/json" \
-d '{"id":"sub-u831-pro","espresso_user_id":"eu_7Hq…","name":"Pro","amount":"9.99","period":"month"}'
{ "id": "sub-u831-pro", "espresso_user_id": "eu_7Hq…", "name": "Pro", "amount": "9.99", "period": "month",
"status": "pending", "created_at": "2026-11-21T12:00:00Z", "expires_at": "2026-11-22T12:00:00Z" }
- The user gets a push and approves in the app within 24 h (else
expired). You getsubscription.created. - The first period is charged as soon as the approval is on-chain:
subscription.paidwithfirst: true,paid_untilandsignature. - Every 30 days it renews:
subscription.paidagain. - A failed charge (e.g. not enough USDC) is retried daily:
subscription.payment_failed, thenpast_dueafter 3 failures, andcancelled(unpaid) after 30. - Cancelled by the user in the app (
user), by you withDELETE /connect/v2/server/subscriptions/{id}(site), or by a disconnect either way (disconnected):subscription.cancelled. Nothing more is charged.
Give access while paid_until is in the future. That is the one field to check.
How it is enforced
Approving adds a role to the user's wallet that can only send the price, in USDC, to your payout wallet (or to the creator and your fee), at most once every ~28 days, enforced on-chain. Espresso only relays each renewal on time and pays the network fees. The price can't change: a new price is a new subscription the user approves.
- Amount 0.01 to 1,000 USDC;
periodismonth;name1 to 40 characters;idup to 100. - No catalog: each request carries its own name and price. One live subscription per user and name (
subscription_exists). - For a creator, add
payeeandfee_percent(same rules); the name shown becomes "Fan club · @anna".
Webhooks
Espresso POSTs JSON events to your site's webhook URL:
POST /espresso/webhooks
Content-Type: application/json
User-Agent: Espresso-Webhooks/1
Espresso-Signature: t=1763726400,v1=4de355d3…
{"id":"evt_1","type":"charge.paid","created_at":"2026-11-21T12:00:00Z","data":{"amount":"4.50"}}
Events
Amounts are USDC decimal strings. Every connection, charge, session, subscription and creator event carries espresso_user_id.
| Type | data |
|---|---|
connection.created | espresso_user_id, connection_id |
connection.deleted | espresso_user_id, by: user | site |
charge.paid | id (your id for a server charge, else Espresso's), espresso_user_id, amount, status (sent | approved), signature?, payee?, fee_percent?, session?: {id, budget} |
charge.declined | id, espresso_user_id, amount, status: declined, reason: declined | expired |
charge.failed | id, espresso_user_id, amount, status: failed |
session.started | espresso_user_id, session: {id, budget, expires_at} |
session.ended | espresso_user_id, session, reason: user | disconnected | blocked | expired |
subscription.created, .paid, .payment_failed, .past_due, .cancelled | id, espresso_user_id, name, amount, status, paid_until?; .paid: signature, first; .payment_failed / .past_due: reason (insufficient_funds | error), attempts; .cancelled: reason (user | site | disconnected | unpaid) |
payee.created | espresso_user_id, name |
payee.declined | espresso_user_id |
charge.* and session.* cover page charges too. An approval nobody answered becomes charge.declined (expired), and a session past its end session.ended (expired), both within a minute.
Verify the signature
v1 is the hex HMAC-SHA256 of <t>.<raw body> with your webhook secret. Use the raw body bytes (not re-serialized JSON), compare in constant time, and reject an old t (each delivery attempt is signed afresh, so 5 minutes is safe). Each snippet below checks the test vector: secret whsec_test, t=1763726400, the body above → v1=4de355d35c7f9e8f72b544e9ba1f596dbc69294cbd9933a2ec283e675454e8dc.
import crypto from 'node:crypto';
export function verifyEspressoSignature(rawBody, header, secret, toleranceSeconds = 300, now = Date.now() / 1000) {
const parts = Object.fromEntries(header.split(',').map((p) => {
const i = p.indexOf('=');
return [p.slice(0, i).trim(), p.slice(i + 1).trim()];
}));
const t = Number(parts.t);
if (!Number.isInteger(t) || !/^[0-9a-f]{64}$/.test(parts.v1 || '')) return false;
if (Math.abs(now - t) > toleranceSeconds) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.`).update(rawBody).digest();
return crypto.timingSafeEqual(expected, Buffer.from(parts.v1, 'hex'));
}
// Test vector
const body = Buffer.from('{"id":"evt_1","type":"charge.paid","created_at":"2026-11-21T12:00:00Z","data":{"amount":"4.50"}}');
const header = 't=1763726400,v1=4de355d35c7f9e8f72b544e9ba1f596dbc69294cbd9933a2ec283e675454e8dc';
console.log(verifyEspressoSignature(body, header, 'whsec_test', 300, 1763726400)); // true
// Express: keep the raw body
// app.post('/espresso/webhooks', express.raw({ type: 'application/json' }), (req, res) => {
// if (!verifyEspressoSignature(req.body, req.get('Espresso-Signature') || '', process.env.ESPRESSO_WEBHOOK_SECRET))
// return res.sendStatus(400);
// const event = JSON.parse(req.body); // dedupe by event.id
// res.sendStatus(200);
// });
import hashlib, hmac, time
def verify_espresso_signature(raw_body: bytes, header: str, secret: str,
tolerance: int = 300, now: float | None = None) -> bool:
parts = dict(p.strip().split("=", 1) for p in header.split(",") if "=" in p)
try:
t = int(parts["t"])
received = bytes.fromhex(parts["v1"])
except (KeyError, ValueError):
return False
if abs((time.time() if now is None else now) - t) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).digest()
return hmac.compare_digest(expected, received)
# Test vector
body = b'{"id":"evt_1","type":"charge.paid","created_at":"2026-11-21T12:00:00Z","data":{"amount":"4.50"}}'
header = "t=1763726400,v1=4de355d35c7f9e8f72b544e9ba1f596dbc69294cbd9933a2ec283e675454e8dc"
print(verify_espresso_signature(body, header, "whsec_test", now=1763726400)) # True
# Flask: verify_espresso_signature(request.get_data(), request.headers.get("Espresso-Signature", ""), SECRET)
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"strconv"
"strings"
"time"
)
// VerifyEspressoSignature checks the Espresso-Signature header against the raw body.
func VerifyEspressoSignature(rawBody []byte, header, secret string, tolerance time.Duration, now time.Time) bool {
var t int64
var received []byte
for _, part := range strings.Split(header, ",") {
k, v, ok := strings.Cut(strings.TrimSpace(part), "=")
if !ok {
continue
}
switch k {
case "t":
t, _ = strconv.ParseInt(v, 10, 64)
case "v1":
received, _ = hex.DecodeString(v)
}
}
if t == 0 || len(received) != sha256.Size {
return false
}
if d := now.Sub(time.Unix(t, 0)); d > tolerance || d < -tolerance {
return false
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write([]byte(strconv.FormatInt(t, 10) + "."))
mac.Write(rawBody)
return hmac.Equal(mac.Sum(nil), received)
}
func main() {
// Test vector
body := []byte(`{"id":"evt_1","type":"charge.paid","created_at":"2026-11-21T12:00:00Z","data":{"amount":"4.50"}}`)
header := "t=1763726400,v1=4de355d35c7f9e8f72b544e9ba1f596dbc69294cbd9933a2ec283e675454e8dc"
fmt.Println(VerifyEspressoSignature(body, header, "whsec_test", 5*time.Minute, time.Unix(1763726400, 0))) // true
// In a handler: body, _ := io.ReadAll(r.Body); VerifyEspressoSignature(body, r.Header.Get("Espresso-Signature"), secret, 5*time.Minute, time.Now())
}
Delivery and retries
- Answer with a 2xx within 10 seconds. A redirect is not followed and counts as a failure.
- Failed deliveries are retried with backoff (10 s, 20 s, 40 s… up to 30 minutes apart) for 24 hours, then dropped. Use the API to catch up after a long outage.
- An event can arrive more than once: deduplicate by
id. - Your webhook URL must resolve to public addresses only (no private, loopback or link-local IPs).
API reference
Base URL https://api.brij.fi. Send Authorization: Bearer <API key> from your backend only. Only an ACTIVE site (domain proven) can call it: a PENDING one gets 422 site_not_verified. Bodies are JSON objects with only the documented fields (else 400 invalid_body), at most 64 KB. Amounts are USDC decimal strings ("4.50", 2 to 6 decimals); times RFC 3339 UTC. Every id is scoped to your site: another site's users and ids are unknown to you.
Connections
{"siteKey", "nonce", "timestamp", "signature"} (from linkProof) → {"espresso_user_id", "connection_id", "wallet_address", "connected_at"}. 403 permission_denied if the proof isn't valid, recent or yours.
{"connections": [{"espresso_user_id", "connection_id", "wallet_address", "connected_at"}]}: live connections, newest first, limit up to 200.
The same, plus "human": {"level", "wallet_age_days", "has_transacted"}. level: new_wallet or verified_wallet (at least 7 days old and has transacted). wallet_address is the user's wallet: send them USDC there.
Disconnects the user: ends their session, the connection and their subscriptions → {"status": "disconnected"}.
Charges
{"id" (1-128), "espresso_user_id", "amount", "memo"? (up to 120), "sessionKey"? (base58), "payee"?, "fee_percent"?} → {"charge": ServerCharge, "message"?: "<base64>"}.
{"signature": "<base64 Ed25519 of message>"} within 90 s → {"charge": ServerCharge}.
{"charge": ServerCharge, "message"?}.
ServerCharge = { "id", "espresso_charge_id", "status": "prepared|sent|failed|awaiting_owner|approved|declined",
"amount", "recipient", "memo", "created_at", "signature"?, "payee"?, "fee_percent"?,
"expires_at"?, (awaiting_owner)
"session_key"?, (prepared: the key that signs message)
"session"?: { "id", "session_key", "budget", "left", "expires_at" } }
Subscriptions
{"id" (up to 100), "espresso_user_id", "name" (1-40), "amount", "period"?: "month", "payee"?, "fee_percent"?} → Subscription.
{"subscriptions": [Subscription]}.
A subscription, with its charges; DELETE cancels it.
Subscription = { "id", "espresso_user_id", "name", "amount", "period": "month",
"status": "pending|active|past_due|cancelled|expired", "created_at",
"expires_at"?, "paid_until"?, "next_charge_at"?, "last_error"?,
"cancelled_by"?: "user|site|disconnected|unpaid", "payee"?, "fee_percent"?,
"charges"?: [{ "amount", "signature", "paid_until", "created_at" }] }
Creators
{"espresso_user_id", "name" (1-40)} → Payee.
{"payees": [Payee]} / Payee, where Payee = {"espresso_user_id", "name", "status": "pending|active|declined", "created_at"}.
Your site
{"id", "name", "logo_url", "origin", "hosts", "status": "active", "verified", "payout_wallet_set", "webhook_url"}.
Errors
HTTP status plus {"error": {"code": "…", "message": "…"}}.
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_<field>, invalid_body | A field is missing or malformed (e.g. invalid_amount, invalid_fee_percent), or the body has unknown fields |
| 401 | unauthenticated | Missing, wrong or disabled API key |
| 403 | permission_denied | A link proof that isn't valid, recent or yours |
| 404 | <resource>_not_found | No such charge, subscription, payee… for your site |
| 413 | body_too_large | Body over 64 KB |
| 422 | site_not_verified | Your domain isn't proven yet |
| 422 | not_connected | The user isn't connected to your site (or disconnected) |
| 422 | payout_wallet_not_set | Server charges and subscriptions need your payout wallet |
| 422 | site_has_no_payout_wallet | A page charge without recipient, and no payout wallet to default to |
| 422 | recipient_has_no_usdc_account | The receiving wallet has no USDC account |
| 422 | insufficient_funds | The user doesn't have enough USDC |
| 422 | too_many_approvals | The user already has 3 charges waiting for approval |
| 422 | session_key_used | That session key was already used: make a fresh one |
| 422 | site_blocked | Your site is blocked |
| 422 | payee_not_confirmed, invalid_payee | The creator hasn't confirmed, or can't be paid (not connected, the payer, your payout wallet) |
| 422 | needs_app | A creator's charge, paid only in the app |
| 422 | subscription_exists | The user already has a live subscription with that name |
| 422 | host_taken, lookalike_domain, too_many_sites | Registration refused (see Register) |
| 429 | rate_limited | Too many requests: retry after Retry-After |
| 500 | internal | Our side: retry with the same id |
Limits
| What | Limit |
|---|---|
| Server API | 10 requests a second per site (and 100 a second per IP); bodies up to 64 KB |
| Page requests (SDK) | 60 a minute per IP |
| Charges waiting for approval | 3 per user, 15 minutes each |
| Signing a prepared charge | 90 seconds |
| Session charges | 3 a minute per session; within the budget and before the end time |
| Link proofs | 5 minutes |
| Connect requests | 2 minutes once a username is entered; 3 requests per user per 10 minutes |
| Subscriptions | 0.01 to 1,000 USDC a month; approval within 24 h |
| Creator fee | 0 to 50% (fee_percent, 2 decimals) |
| Sites | 3 per owner, 10 registrations a day |
Security & privacy
- Users approve every payment. One at a time in the app, or within a session they started there, with a budget enforced on-chain and an end time. Subscriptions run on a limited role the wallet's owner approved once.
- Your keys can only ask. A leaked API key can't move a user's money or redirect it: server charges only pay your payout wallet (set by you, signed in with your passkey) or a creator who confirmed in the app.
- Session charges are co-signed. Espresso simulates every session transaction and refuses anything but USDC within what's left of the budget.
- Users stay in control. Connected sites are listed in the app and on connect.brij.fi; ending a session or disconnecting is instant.
- Pseudonymous.
espresso_user_iddiffers on every site. You don't see balances, activity or contact details;human.leveltells you whether the wallet is new or established. - Keep secrets on your servers. Your API key and webhook secret never belong in a page or an app; rotate them on connect.brij.fi/developers if they leak.
FAQ
Do my users need the Espresso Cash app?
Yes. The wallet lives in the Espresso Cash app (iOS and Android): users connect with their username and approve payments, sessions and subscriptions on their phone. Your site never handles keys or passwords.
Do I need to register?
Not to connect users and charge them from your page (name the recipient). Registering gives you espresso_user_ids, the server API, webhooks, subscriptions, creators and the verified badge. It's self-serve, on connect.brij.fi/developers.
Which currency and network?
USDC (digital dollars) on Solana mainnet. Users cash in and out to their local currency from the app. Test with small amounts like 0.01.
Does Apple or Google take a cut?
No. Purchases happen on your website; Espresso Cash is the wallet that pays, like a card would.
What happens if a session charge breaks a rule?
It isn't refused: it becomes a one-shot charge the user approves in the app, and your charge() (or server charge) waits for that approval.