Agent Integration Guide
Humans buy identities. Agents rent certainty.
This guide explains how AI agents can integrate with Web3 Identity API to resolve identities, establish trust, and make autonomous decisions.
Why Agents Need Identity Infrastructureโ
When an AI agent encounters an ENS name or wallet address, it needs to answer:
- "Can I trust this entity?"
- "Is this address linked to a human, DAO, or service?"
- "What claims are authoritative?"
- "Should I allow access, deny, or escalate?"
The agent doesn't want identity. It wants certainty.
What We Provideโ
| Agent Need | Our Solution |
|---|---|
| Identity resolution | ENS + Farcaster + Lens + Gitcoin Passport |
| Trust verification | Cryptographically signed CCIP responses |
| Payment | x402 micropayments (no API keys needed) |
| Caching | Deterministic, reproducible results |
| Schema stability | OpenAPI documented, versioned |
The Trust Modelโ
Traditional API Trustโ
Agent โ API Key โ Provider โ Response
โ
Trust required at every step
Problems:
- API keys are secrets to manage
- Account setup requires human in the loop
- Trust is reputation-based
Our Model: Verifiable Trustโ
Agent โ Query โ CCIP Gateway โ Signed Response
โ
Agent verifies signature on-chain
โ
Trust verified mathematically
The agent doesn't trust us. It trusts math.
Integration Patternsโ
Pattern 1: Identity Resolutionโ
Resolve an ENS name to rich identity metadata:
curl https://api.web3identity.com/api/ens/resolve/garypalmerjr.eth
Response:
{
"name": "garypalmerjr.eth",
"address": "0x701B4937e6c943789ffA74CC8601813b2D87B454",
"avatar": "https://...",
"records": {
"description": "...",
"url": "...",
"twitter": "GaryPalmerJr"
},
"resolved": true
}
Pattern 2: Multi-Platform Identityโ
Get identity across ENS, Farcaster, and Lens in one call:
curl https://api.web3identity.com/api/identity/0x701B4937e6c943789ffA74CC8601813b2D87B454
Pattern 3: Trust Scoringโ
Check Gitcoin Passport score for Sybil resistance:
curl https://api.web3identity.com/api/gitcoin/passport/score/0x...
Pattern 4: CCIP-Read Resolutionโ
For agents that want cryptographic verification, query via CCIP-Read:
1. Query on-chain resolver for *.aboutme.eth
2. Resolver returns OffchainLookup with gateway URL
3. Agent queries gateway
4. Gateway returns signed response
5. Agent verifies signature matches resolver's signer
This provides the strongest trust guarantee.
Payment: x402 Protocolโ
Agents can pay for API access without API keys:
How It Worksโ
- Agent makes request
- If over free tier (100/day), server returns
402 Payment Required - Response includes payment details (amount, address, chain)
- Agent signs EIP-712 typed data with its wallet
- Agent retries with payment header
- Server verifies payment, returns data
Code Exampleโ
import { createWalletClient } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { base } from 'viem/chains';
const account = privateKeyToAccount(AGENT_PRIVATE_KEY);
// 1. Make initial request
const response = await fetch('https://api.web3identity.com/api/ens/resolve/vitalik.eth');
if (response.status === 402) {
// 2. Get payment requirements from response
const paymentInfo = response.headers.get('X-Payment-Required');
// 3. Sign payment authorization
const signature = await account.signTypedData({
// EIP-712 typed data for x402 payment
domain: { name: 'x402', chainId: 8453 },
types: { Payment: [/* ... */] },
message: { amount: '1000', recipient: '0x...' }
});
// 4. Retry with payment
const paidResponse = await fetch(url, {
headers: { 'X-Payment': signature }
});
}
Payment Economicsโ
| Tier | Daily Calls | Cost |
|---|---|---|
| Free | 100 | $0.00 |
| x402 | Unlimited | $0.005 - $0.08 per call |
No subscriptions. No accounts. Just wallet + signature.
Agent Auth Flowโ
Example: Verifying a user's identity claim
async function verifyIdentityClaim(claimedName) {
// 1. User claims "I am garypalmerjr.eth"
// 2. Agent queries our gateway
const identity = await fetch(
`https://api.web3identity.com/api/ens/resolve/${claimedName}`
).then(r => r.json());
// 3. Agent checks claims
const hasVerifiedTwitter = identity.records?.twitter;
const hasGitcoinPassport = await checkPassport(identity.address);
const accountAge = await checkFirstTx(identity.address);
// 4. Agent decides
if (hasVerifiedTwitter && hasGitcoinPassport && accountAge > 180) {
return { decision: 'ALLOW', confidence: 0.95 };
} else if (accountAge > 30) {
return { decision: 'ALLOW', confidence: 0.7 };
} else {
return { decision: 'ESCALATE', reason: 'New account, low verification' };
}
}
Schema Stabilityโ
We guarantee:
- Versioned API โ Breaking changes only in major versions
- OpenAPI spec โ Machine-readable schema at
/openapi.json - Consistent responses โ Same query = same response structure
- Deprecation notices โ 90 days before removing endpoints
Agents can cache our schema and rely on it.
Discoveryโ
Agents can discover our capabilities via:
| Method | URL |
|---|---|
| OpenAPI spec | https://api.web3identity.com/openapi.json |
| AI plugin manifest | https://api.web3identity.com/.well-known/ai-plugin.json |
| Agent info | https://api.web3identity.com/api/agent-info |
| Health check | https://api.web3identity.com/api/health |
Best Practicesโ
1. Cache Deterministic Resultsโ
Identity data changes slowly. Cache for 5-15 minutes:
const CACHE_TTL = 10 * 60 * 1000; // 10 minutes
const cache = new Map();
async function resolveWithCache(name) {
const cached = cache.get(name);
if (cached && Date.now() - cached.time < CACHE_TTL) {
return cached.data;
}
const data = await resolve(name);
cache.set(name, { data, time: Date.now() });
return data;
}
2. Use Batch Endpointsโ
Resolve multiple names in one request:
POST /api/ens/batch
Content-Type: application/json
{
"names": ["vitalik.eth", "nick.eth", "brantly.eth"]
}
3. Handle Rate Limits Gracefullyโ
if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After');
await sleep(retryAfter * 1000);
return retry();
}
4. Verify Critical Data On-Chainโ
For high-stakes decisions, verify our response against on-chain data:
// Our API response
const apiResult = await fetch('.../ens/resolve/name.eth');
// Verify on-chain
const onChainAddress = await ensContract.read.addr([namehash('name.eth')]);
if (apiResult.address !== onChainAddress) {
throw new Error('Data mismatch - escalate to human');
}
Example: Complete Agent Integrationโ
class IdentityAgent {
constructor(walletClient) {
this.wallet = walletClient;
this.apiBase = 'https://api.web3identity.com';
}
async resolveIdentity(nameOrAddress) {
const endpoint = nameOrAddress.endsWith('.eth')
? `/api/ens/resolve/${nameOrAddress}`
: `/api/identity/${nameOrAddress}`;
return this.fetchWithPayment(endpoint);
}
async assessTrust(address) {
const [identity, passport, history] = await Promise.all([
this.resolveIdentity(address),
this.fetchWithPayment(`/api/gitcoin/passport/score/${address}`),
this.fetchWithPayment(`/api/wallet/first-tx/${address}`)
]);
return {
hasENS: !!identity.name,
hasSocials: !!(identity.records?.twitter || identity.farcaster),
passportScore: passport.score,
accountAgeDays: this.daysSince(history.timestamp),
trustLevel: this.calculateTrust(identity, passport, history)
};
}
async fetchWithPayment(endpoint) {
let response = await fetch(this.apiBase + endpoint);
if (response.status === 402) {
const payment = await this.signPayment(response);
response = await fetch(this.apiBase + endpoint, {
headers: { 'X-Payment': payment }
});
}
return response.json();
}
calculateTrust(identity, passport, history) {
let score = 0;
if (identity.name) score += 20;
if (identity.records?.twitter) score += 15;
if (identity.farcaster) score += 15;
if (passport.score > 20) score += 25;
if (this.daysSince(history.timestamp) > 365) score += 25;
return score;
}
}
Supportโ
- Docs: docs.web3identity.com
- API Reference: api.web3identity.com/docs
- Status: status.web3identity.com
- Contact: support@web3identity.com
Built for the agent economy. Humans buy identities. Agents rent certainty.