Skip to content

Start typing to search the documentation.

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).

  1. Install the SDK:

    npm install @selfxyz/agent-sdk
  2. 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 });
  3. Run node quickstart.mjs, open the printed scanUrl and scan it with the mock passport.

  4. Success: the script prints valid: true with your new agentId.

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).

  1. Create a session:

    npx -p @selfxyz/agent-sdk self-agent register init --mode wallet-free --out .self/session.json
  2. 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
  3. Wait for the registry (exit code 0 when done):

    npx -p @selfxyz/agent-sdk self-agent register wait --session .self/session.json
  4. Export the key:

    npx -p @selfxyz/agent-sdk self-agent register export --session .self/session.json --unsafe --print-private-key
  5. Success: wait printed "stage": "onchain_verified" and an agentId, and curl -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).

  1. Open the Self Agent ID Postman workspace and fork the Self Agent ID API collection.
  2. Send Query → Agent details. Success: 200 with "isVerified": true for demo agent 5.
  3. Send Registration → Start a registration session (wallet-free), then open the deepLink (or scanUrl) on your phone and scan with the mock passport.
  4. Send Poll a registration until stage is completed. The rotated sessionToken saves itself after every poll.
  5. Send Export the generated agent key. Success: the response holds privateKey and agentId.

Variables, folders and visa writes: Postman collection.

Next

Was this page helpful?