# Quickstart

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](/docs/self-enterprise/guides/using-mock-passports/)). Testnet accepts mock passports only; a real passport fails with `InvalidIdentityCommitmentRoot`.

## Pick a path

| Path                        | You need    | Ends with                                   |
| --------------------------- | ----------- | ------------------------------------------- |
| [SDK](#sdk)                 | Node.js 18+ | A signed request that your verifier accepts |
| [CLI](#cli)                 | Node.js 18+ | A registered agent and its private key      |
| [Postman](#postman-no-code) | 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](/docs/agent-id/guides/mcp-user/).

## SDK

Register, sign and verify in one script (~5 min).

1. Install the SDK:

   ```bash
   npm install @selfxyz/agent-sdk
   ```

2. Save this as `quickstart.mjs`:

   ```js
   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`.

:::note
No phone handy? Read the demo agent instead: `curl -s https://agent-api.self.xyz/api/agent/info/11142220/5`. Demo agents 1, 5 and 72 disclosed no age, so a verifier with `.requireAge(18)` rejects them with `Agent's human does not meet minimum age (required: 18, got: 0)`.
:::

Next: serve real requests with `verifier.auth()` in [Register an agent with the SDK](/docs/agent-id/register-an-agent/).

## CLI

The CLI generates the agent key on your machine and defaults to `testnet` (~5 min).

1. Create a session:

   ```bash
   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:

   ```bash
   npx -p @selfxyz/agent-sdk self-agent register open --session .self/session.json
   ```

3. Wait for the registry (exit code `0` when done):

   ```bash
   npx -p @selfxyz/agent-sdk self-agent register wait --session .self/session.json
   ```

4. Export the key:

   ```bash
   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](/docs/agent-id/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](https://www.postman.com/self-labs/self-agent-id/overview) 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](/docs/agent-id/postman/).

## Next

- [Registration modes](/docs/agent-id/registration-modes/): Ed25519 keys, linked wallets and the rest
- [Verifying agents in a service](/docs/agent-id/guides/service-operator/): add the verifier to your API
