Get Started

Set up the aTIProto agent to integrate payments and subscriptions into your ATProto application.

Installation

Install the agent and lexicons packages:

bash
npm install @atiproto/agent @atiproto/lexicons

Create an Authenticated Agent

The Agent from @atiproto/agent wraps any XrpcClient and proxies requests to the atiproto tipping service. It automatically injects the atproto-proxy header so requests are routed through your PDS to our service.

With @atproto/api Agent

If you're using the official @atproto/api package, restore an OAuth session and pass the agent directly:

typescript
import { Agent as BskyAgent } from "@atproto/api";
import { Agent as TipAgent } from "@atiproto/agent";
// See: https://github.com/bluesky-social/atproto/tree/main/packages/oauth/oauth-client#readme
import { OAuthClient } from "@atproto/oauth-client";
const oauthClient = new OAuthClient({
// ...
});
// Restore an authenticated session
const oauthSession = await oauthClient.restore("did:plc:123");
const bskyAgent = new BskyAgent(oauthSession);
// Create a TipAgent — automatically uses withProxy()
const paymentAgent = new TipAgent(bskyAgent);
// Now you can call tipping APIs
const profile = await paymentAgent.com.atiproto.recipient.profile.get();

With Any XrpcClient

You can use any XrpcClient instance. The TipAgent will wrap it and add the proxy header for routing:

typescript
import { XrpcClient } from "@atproto/xrpc";
import { Agent as TipAgent } from "@atiproto/agent";
// Create any XrpcClient with your PDS
const client = new XrpcClient("https://your-pds.example.com", mySchemas);
// Wrap it with the TipAgent
const paymentAgent = new TipAgent(client);

How It Works

When you create a TipAgent, it sets up a proxy to did:web:atiproto.com#tips_service. Your PDS receives the request, sees the proxy header, and forwards it to our service for processing.

The agent also provides full TypeScript types for all API methods, generated from the ATProto lexicon definitions. Every call is type-checked at compile time.

typescript
// All methods are fully typed
const { data } = await paymentAgent.com.atiproto.payment.item.create({
subject: "did:plc:recipient123",
amount: 500, // 500 cents = $5.00
currency: "USD",
});
// data.tipUri, data.cartUri, data.checkoutUrl are all typed
console.log(data.checkoutUrl);

Next Steps