Docs/Agents

Your agent's first paid call

In five lines of TypeScript, your agent will pay a live API on Solana devnet and get data back. No wallet code, no blockchain libraries, no seed phrases — just an API key you paste into an env var.

Time to first paid call: ~3 minutes.

Create an agent + grab its API key

  1. Open the dashboard and sign in with Google.
  2. Press ⌘N (or click + New agent). Name your agent, pick a monthly spend cap in rupees, submit.
  3. A green banner appears with your agent's plaintext API key (format pk_…). Copy it now — it's shown only once. Obscura stores only a hash.
  4. Click Top up on the agent row and fund it with ₹500 via UPI or a test card. Funds arrive on devnet within ~30 seconds.
your-agent/.env·bash
OBSCURA_KEY=pk_abc…xyz
OBSCURA_BASE_URL=https://your-obscura-host.example.com

Write five lines

Create agent.ts and paste this in. Swap the URL for any paid endpoint — here we're hitting a demo merchant we run on Solana devnet that charges $0.01 per article.

agent.ts·ts
import { Obscura } from "@obscura-app/sdk";

const agent = new Obscura({
apiKey: process.env.OBSCURA_KEY!,
baseUrl: process.env.OBSCURA_BASE_URL!,
});

const res = await agent.fetch(
"https://your-merchant.example.com/article/42",
);
console.log(await res.json());

Run it:

terminal·bash
npx tsx --env-file=.env agent.ts

# You should see:
# { id: 42, headline: 'Solana breaks 10k TPS again', body: '…', publishedAt: '2026-04-28T…' }

What's next

  • How it works — the full x402 handshake, end to end.
  • Error handling — every ObscuraErrorCode and when to retry.
  • Advanced usage — custom fetch, pointing at a local Obscura instance, AbortSignal + RequestInit pass-through.