Documentation / Portal · Monetize · Gateway

Gateway setup: your edge is the enforcement point.

The gateway calls the decision API per request, applies the result, and settles with your facilitator. Volance does not sit in the request path and never holds funds.

Last updated

The flow

  1. The agent requests a path.
  2. Your gateway calls POST /api/trace/agent/decide with the public key, the path, request signals, and any disclosure headers.
  3. The decision is allow, charge, or block.
  4. Allow: serve origin. Block: return 403. Charge: return 402 with the x402 challenge.
  5. After settlement, report it to POST /api/trace/agent/settlement.
Cloudflare WorkerReference gateway excerpt
const decision = await fetch('https://app.volance.com/api/trace/agent/decide', {
  method: 'POST',
  headers: {
    authorization: 'Bearer ' + env.VOLANCE_PUBLIC_KEY,
    'content-type': 'application/json',
  },
  body: JSON.stringify({
    path: new URL(request.url).pathname,
    method: request.method,
    requestSignals: {
      visitorIp: request.headers.get('cf-connecting-ip'),
      visitorUserAgent: request.headers.get('user-agent'),
      acceptLanguage: request.headers.get('accept-language'),
      secChUa: [request.headers.get('sec-ch-ua')].filter(Boolean),
      cookiePresent: Boolean(request.headers.get('cookie')),
    },
    disclosureHeaders: {
      'signature-input': request.headers.get('signature-input'),
      signature: request.headers.get('signature'),
      'signature-agent': request.headers.get('signature-agent'),
      authority: new URL(request.url).host,
    },
  }),
}).then((r) => r.json());

if (decision.decision === 'allow') return fetch(request);
if (decision.decision === 'block') return new Response('Forbidden', { status: 403 });
return new Response('Payment Required', {
  status: 402,
  headers: { 'PAYMENT-REQUIRED': JSON.stringify(decision.paymentRequired) },
});

What the gateway must not do

  • Do not hold funds. Settlement goes to your wallet through your facilitator.
  • Do not proxy the request through Volance. The decision is a call, not a hop.
  • Do not cache a charge or a block forever. A cached decision is a decision you did not just make.
  • Do not put the secret key in the browser. The decision endpoint uses the public key; settlement reporting uses the secret and belongs on the server.

Preview

Use dry-run IOU mode and testnet first. Live production settlement is not generally available. The agent monetization guide covers the decision fields and the settlement boundary.

Related

Free to start. 10,000 scores a month, one project, no credit card.

Get started free