Quickstart
On this page
Give an AI agent an on-chain proof that a real human stands behind it, on Celo Sepolia (testnet), in about 5 minutes.
Before you start (~2 min): install the Self app and add a mock passport: Settings → Manage ID documents → Generate Mock Document (guide). Testnet accepts mock passports only; a real passport fails with InvalidIdentityCommitmentRoot.
Pick a path
| Path | You need | Ends with |
|---|---|---|
| SDK | Node.js 18+ | A signed request that your verifier accepts |
| CLI | Node.js 18+ | A registered agent and its private key |
| Postman | A browser | A registered agent, no code |
Using Claude Code, Cursor or another MCP client? Ask it to register for you: Using the MCP server.
SDK
Register, sign and verify in one script (~5 min).
-
Install the SDK:
npm install @selfxyz/agent-sdk -
Save this as
quickstart.mjs:import { requestRegistration, SelfAgent, SelfAgentVerifier } from '@selfxyz/agent-sdk'; // 1. Register: the human scans the QR code with the Self app const session = await requestRegistration({ mode: 'wallet-free', network: 'testnet' }); console.log('Open and scan:', session.scanUrl); const { agentId } = await session.waitForCompletion(); const privateKey = await session.exportKey(); // the agent's identity: store it as a secret // 2. Sign a request as the agent const agent = new SelfAgent({ privateKey, network: 'testnet' }); const url = 'https://api.example.com/hello'; const body = JSON.stringify({ hello: 'world' }); const headers = await agent.signRequest('POST', url, body); // 3. Verify it the way a service would const verifier = SelfAgentVerifier.create() .network('testnet') .sybilLimit(0) // the default (1 agent per human) rejects humans who hold several agents .build(); const result = await verifier.verify({ signature: headers['x-self-agent-signature'], timestamp: headers['x-self-agent-timestamp'], method: 'POST', url, body, }); console.log({ agentId, valid: result.valid, error: result.error }); -
Run
node quickstart.mjs, open the printedscanUrland scan it with the mock passport. -
Success: the script prints
valid: truewith your newagentId.
Next: serve real requests with verifier.auth() in Register an agent with the SDK.
CLI
The CLI generates the agent key on your machine and defaults to testnet (~5 min).
-
Create a session:
npx -p @selfxyz/agent-sdk self-agent register init --mode wallet-free --out .self/session.json -
Print the QR URL, open it, and scan the QR code with the mock passport:
npx -p @selfxyz/agent-sdk self-agent register open --session .self/session.json -
Wait for the registry (exit code
0when done):npx -p @selfxyz/agent-sdk self-agent register wait --session .self/session.json -
Export the key:
npx -p @selfxyz/agent-sdk self-agent register export --session .self/session.json --unsafe --print-private-key -
Success:
waitprinted"stage": "onchain_verified"and anagentId, andcurl -s https://agent-api.self.xyz/api/agent/info/11142220/<agentId>returns"isVerified": true.
Bare npx self-agent fails: there is no npm package by that name. Flags and exit codes: CLI.
Postman (no code)
Every endpoint as a ready-made request, with real saved responses (~5 min).
- Open the Self Agent ID Postman workspace and fork the Self Agent ID API collection.
- Send Query → Agent details. Success:
200with"isVerified": truefor demo agent5. - Send Registration → Start a registration session (wallet-free), then open the
deepLink(orscanUrl) on your phone and scan with the mock passport. - Send Poll a registration until
stageiscompleted. The rotatedsessionTokensaves itself after every poll. - Send Export the generated agent key. Success: the response holds
privateKeyandagentId.
Variables, folders and visa writes: Postman collection.
Next
- Registration modes: Ed25519 keys, linked wallets and the rest
- Verifying agents in a service: add the verifier to your API
Thanks. What went wrong?
Thanks for your feedback!