Agent Self-Onboarding
This guide covers the full journey from an agent's perspective: self-enroll with zero credentials, receive access from your human, create and read secrets, and share them back.
Try out the example in this repo: Basic (includes enrollment and sharing). The examples README lists all runnable demos.
Overview
Agent (no credentials)
│
├── 1. POST /v1/agents/enroll (public, no auth)
│ └── Pending enrollment; human approves via email link or approval_url
│ └── Credentials emailed to the human after approval
│
├── 2. Access: what the agent asked for (requested_access), the default
│ starter grant, or policies the human creates in the dashboard
│
├── 3. Agent exchanges API key for JWT
│ └── POST /v1/auth/agent-token
│
├── 4. Agent reads / writes secrets
│ └── GET/PUT /v1/vaults/:id/secrets/:path
│
└── 5. Agent shares secrets back to human
└── POST /v1/secrets/:id/share { recipient_type: "creator" }
1. Self-enroll
The enrollment endpoint is public — no authentication required. Provide name and optionally human_email:
- With email: A pending enrollment is created for that account; Allow/Deny links are emailed, and the response may include
approval_urlas a fallback. - Name only: A link-only pending enrollment is created; the response includes
approval_urlfor the human to open while signed in (no email required to start).
- curl
- TypeScript SDK
- Python
- CLI
curl -s -X POST https://api.1claw.co/v1/agents/enroll \
-H "Content-Type: application/json" \
-d '{
"name": "my-agent",
"human_email": "alice@example.com",
"description": "CI pipeline agent"
}'
import { AgentsResource } from "@1claw/sdk";
const result = await AgentsResource.enroll(
"https://api.1claw.co",
{
name: "my-agent",
human_email: "alice@example.com",
description: "CI pipeline agent",
},
);
console.log("Agent ID:", result.agent_id);
from oneclaw import create_client
client = create_client()
resp = client.agents.enroll(
"my-agent",
"alice@example.com",
description="CI pipeline agent",
)
print(resp.data.get("agent_id"), resp.data.get("approval_url"))
npx @1claw/cli agent enroll my-agent --email alice@example.com
Link-only (no email):
curl -s -X POST https://api.1claw.co/v1/agents/enroll \
-H "Content-Type: application/json" \
-d '{"name":"my-agent"}'
npx @1claw/cli agent enroll my-agent
What happens:
- The API creates a pending enrollment (email-bound or link-only).
- The human approves via the emailed link or by opening
approval_urlwhile signed in. - After approval, an agent is created in the approver's organization; an API key is generated and emailed — the plaintext key is never returned from
POST /v1/agents/enroll. - Responses use a uniform
201shape where needed to limit email enumeration (some branches omitapproval_url).
Rate limits: One enrollment per email per 10 minutes (when email is used), caps on pending enrollments, plus IP-based rate limiting.
Pairing with a fingerprint (no email, nothing to copy)
An agent that enrols with its own public key gets a pairing ceremony instead of an emailed key: the human sees the key's fingerprint on the approval page and compares it with what the agent printed — a mutual check that the right agent is talking to the right account — and the agent collects its API key itself by polling.
npx @1claw/cli agent enroll my-agent --pair
# Fingerprint (the human must see exactly this on the approval page):
# SHA256:Q2hlY2sgdGhpcyBmaW5nZXJwcmludCBvbiB0aGUgcGFn
# Waiting for the account holder to allow or deny…
By hand:
# 1. Enrol with an Ed25519 public key (ssh-ed25519 line or base64 of the raw 32 bytes)
curl -s -X POST https://api.1claw.co/v1/agents/enroll \
-H "Content-Type: application/json" \
-d '{"name":"my-agent","public_key":"ssh-ed25519 AAAAC3Nza…"}'
# → { pairing_id, fingerprint: "SHA256:…", poll_token, approval_url, expires_at }
# 2. Show `fingerprint` to the human; they open approval_url and compare.
# 3. Poll until the decision (3 s is fine). The first `approved` response carries the key, once.
curl -s "https://api.1claw.co/v1/agents/enroll/$PAIRING_ID/status?poll=$POLL_TOKEN"
# → { status: "pending" | "approved" | "denied" | "expired", api_key?, agent_id?, vault_ids? }
Pairing works for any signed-in account, including wallet-login accounts that have no email address: the agent enrolls link-only with its public key, and the human opens approval_url while signed in.
The SDKs wrap this: AgentsResource.pair(baseUrl, { name, public_key }, onFingerprint) in TypeScript, agents.enroll(name, public_key=…) + agents.enrollment_status(pairing_id, poll_token) in Python. The public key becomes the agent's identity key (ssh_public_key) on approval. The parked key expires 15 minutes after approval if never collected.
Asking for specific access (requested_access)
An enrolling agent can say what it needs: one vault (by name), one secret path pattern in it, and permissions. The approval page shows the request to the human before they decide, and approving grants exactly that, instead of the default starter grant.
curl -s -X POST https://api.1claw.co/v1/agents/enroll \
-H "Content-Type: application/json" \
-d '{
"name": "harness-relay",
"public_key": "ssh-ed25519 AAAAC3Nza…",
"requested_access": {
"vault": "Harness",
"path": "harness/**",
"permissions": ["read", "write"]
}
}'
| Field | Default | Rules |
|---|---|---|
vault | default | Vault name, 1 to 64 characters. System vaults (names starting with __) are refused. Created on approval if the org does not have it. |
path | (required) | Secret path pattern, such as harness/**. Traversal (..), zero-width and confusable characters are refused. |
permissions | ["read", "write"] | Any of read, write, delete, share. list is accepted and granted as read (listing secrets needs read). |
A bad request is refused with 400 at POST /v1/agents/enroll, so the agent learns about it before the human sees anything. The request is only a request: nothing is granted until a signed-in human approves.
The human's side:
GET /v1/agents/enroll/pending?token=…returnsrequested_accessand, when the pattern covers the whole vault (**,**/*or*, with or without a leading/),requested_access_whole_vault: true. The approval page warns about a whole-vault request.POST /v1/agents/enroll/approvetakes an optionalgrant_requested_access(defaulttrue). Withtrue, the vault is created if missing, a policy for the agent is written onpathwithpermissions, and the vault is bound to the agent. Withfalse(the approval page's "Grant this access" checkbox unticked), the agent gets the default starter grant instead. The response gainsgranted_access. Granting the request answers to your org'spolicy.createconsensus policy (andvault.createwhen the vault is created), the same as writing the policy yourself: a hold returns the pending-approval response, and once it is approved you callapproveagain withapproval_id.
The agent's side: the first approved poll returns granted_access next to api_key:
{
"pairing_id": "…",
"status": "approved",
"agent_name": "harness-relay",
"fingerprint": "SHA256:…",
"agent_id": "…",
"api_key": "ocv_…",
"vault_ids": ["…"],
"granted_access": {
"vault": "Harness",
"vault_id": "…",
"vault_created": true,
"path": "harness/**",
"permissions": ["read", "write"],
"granted": true
}
}
granted_access is absent when the agent asked for nothing or the human declined the request.
With the TypeScript SDK (@1claw/sdk 0.63.1 or later):
import { AgentsResource } from "@1claw/sdk";
const result = await AgentsResource.pair(
"https://api.1claw.co",
{
name: "harness-relay",
public_key: "ssh-ed25519 AAAAC3Nza…",
requested_access: { vault: "Harness", path: "harness/**", permissions: ["read", "write"] },
},
(fingerprint, approvalUrl) => console.log(fingerprint, approvalUrl),
);
console.log(result.api_key, result.granted_access);
2. Human grants access
Without a requested_access (or when the human declines it), approval applies the default starter grant in the vault named default, with a sample secret at examples/hello: read and write on examples/** when that vault already existed, or on ** when it was just created for this agent (it then holds only the sample).
For anything else, the human adds policies. The emailed flow sends the agent's ID and API key to the human. In the dashboard:
- Go to Vaults and select (or create) a vault.
- Navigate to Policies → Create Policy.
- Set principal type to Agent, select the agent, choose a path pattern (e.g.
api-keys/**), and grant read (and optionally write) permission.
The agent now has zero-access-by-default elevated to the specific paths the human chose.
3. Exchange API key for JWT
Once the human shares the API key with the agent's deployment:
- curl
- TypeScript SDK
- Python
TOKEN=$(curl -s -X POST https://api.1claw.co/v1/auth/agent-token \
-H "Content-Type: application/json" \
-d '{"agent_id":"<AGENT_ID>","api_key":"ocv_..."}' \
| jq -r .access_token)
import { createClient } from "@1claw/sdk";
const client = createClient({
baseUrl: "https://api.1claw.co",
agentId: process.env.ONECLAW_AGENT_ID,
apiKey: process.env.ONECLAW_AGENT_API_KEY,
});
// The SDK auto-exchanges and refreshes the JWT.
from oneclaw import create_client
client = create_client(api_key="ocv_your_agent_key")
print(client.resolved_agent_id)
4. Read and write secrets
- curl
- TypeScript SDK
- Python
# Read a secret
curl -s "https://api.1claw.co/v1/vaults/$VAULT_ID/secrets/api-keys/openai" \
-H "Authorization: Bearer $TOKEN"
# Store a secret
curl -s -X PUT "https://api.1claw.co/v1/vaults/$VAULT_ID/secrets/credentials/db-password" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"password","value":"s3cret!"}'
// Read
const { data: secret } = await client.secrets.get(VAULT_ID, "api-keys/openai");
// Write (requires write policy)
await client.secrets.set(VAULT_ID, "credentials/db-password", "s3cret!", {
type: "password",
});
from oneclaw import create_client
client = create_client(api_key="1ck_...")
resp = client.secrets.set(
vault_id,
"api-keys/openai",
"sk-proj-...",
type="api_key",
metadata={"tags": ["openai", "production"]},
)
print(resp.data["path"], f"v{resp.data['version']}")
5. Share secrets back to your human
Agents can share any secret they can read back to the human who created them using recipient_type: "creator". No email address or user ID is needed: the API resolves it from the agent's created_by. Agents can also create anyone_with_link, user and agent shares (not external_email); see Sharing Secrets.
- curl
- TypeScript SDK
- Python
- MCP
curl -s -X POST "https://api.1claw.co/v1/secrets/$SECRET_ID/share" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"recipient_type": "creator",
"expires_at": "2026-12-31T00:00:00Z",
"max_access_count": 10
}'
const { data: share } = await client.sharing.create(secretId, {
recipient_type: "creator",
expires_at: "2026-12-31T00:00:00Z",
max_access_count: 10,
});
from oneclaw import create_client
client = create_client(api_key="ocv_...")
resp = client._http.request(
"POST",
f"/v1/secrets/{secret_id}/share",
body={
"recipient_type": "creator",
"expires_at": "2026-12-31T00:00:00Z",
"max_access_count": 10,
},
)
share = resp.data
share_secret(secret_id: "...", recipient_type: "creator", expires_at: "2026-12-31T00:00:00Z")
The human sees the share in their Inbound tab on the Sharing page and accepts it.
Complete example
Here is a typical agent lifecycle in a single script:
import { createClient, AgentsResource } from "@1claw/sdk";
// Step 1: Self-enroll (first run only)
const enrollment = await AgentsResource.enroll("https://api.1claw.co", {
name: "deploy-bot",
human_email: "ops@mycompany.com",
});
console.log("Pending:", enrollment.message, enrollment.approval_url);
// Wait for human to approve, then email you the API key and create policies...
// Steps 3-5: Normal operation (after receiving credentials)
const client = createClient({
baseUrl: "https://api.1claw.co",
agentId: process.env.ONECLAW_AGENT_ID,
apiKey: process.env.ONECLAW_AGENT_API_KEY,
});
// Read a secret
const { data: secret } = await client.secrets.get(VAULT_ID, "api-keys/deploy-token");
// Store a newly generated credential
await client.secrets.set(VAULT_ID, "credentials/session-key", newSessionKey, {
type: "api_key",
});
// Share it back to the human
const { data: secretMeta } = await client.secrets.get(VAULT_ID, "credentials/session-key");
await client.sharing.create(secretMeta.id, {
recipient_type: "creator",
expires_at: "2026-06-01T00:00:00Z",
});
Security notes
- Least access by default: a freshly enrolled agent gets either the starter grant in the
defaultvault (examples/**, or**on a vault created just for it) or exactly therequested_accessthe human approved. Everything else needs a policy. - API key is never in the enroll response: it is emailed to the human after they approve, or, for a pairing, collected once by the agent from the status poll. The agent never sees its own key via
POST /v1/agents/enroll. - Rate limiting — Enrollment is rate-limited per email (10 min cooldown when email is used), with caps on pending rows and per IP.
- Uniform responses — Some branches use the same 201 shape to limit email enumeration;
approval_urlmay be omitted in those cases.
Next steps
- Managing Agent Fleets — Patterns for operating 100+ agents at scale.
- Give an agent access — The human side of the flow.
- Sharing Secrets — All share types and options.