Reference only — not for production use. Review and adapt for your own security requirements.
Four TypeScript scripts that walk through the core 1Claw workflows: vault CRUD, secrets management, billing, user signup with sharing, the Intents API, and Execution Intents bindings.
cd examples/basic
npm install
cp .env.example .env
# Edit .env: set ONECLAW_API_KEY (from https://1claw.xyz/settings/api-keys)
npm startFrom the repo root: cd examples && npm run bootstrap copies .env.example → .env when missing.
- Authenticate with the 1Claw SDK (API key or agent token)
- Create a vault, store a secret, retrieve it, and list vault contents
- Check your billing usage
- Sign up a new user and share a secret by email
- Register an agent with the Intents API, submit a signed transaction, and verify guardrails
- Create Execution Intents bindings with inline and vault-ref credentials
- Node.js 20+
- A 1Claw account with an API key (get one at Settings → API Keys)
- Uses
@1claw/sdk@^0.34.0(npm install will fetch it)
cd examples/basic
npm install
cp .env.example .envOpen .env and fill in your API key:
ONECLAW_BASE_URL=https://api.1claw.xyz
ONECLAW_API_KEY=1ck_your_key_herenpm startThis runs src/index.ts, which:
- Authenticates with your API key
- Creates a vault called
demo-vault - Stores a secret
OPENAI_KEYwith valuesk-demo-12345 - Retrieves and prints the secret (value truncated)
- Lists all secrets in the vault
- Checks your billing usage (tier, limits, current month)
- Deletes the secret and vault
Expected output:
Creating client...
--- Creating vault ---
Vault created: demo-vault (a1b2c3d4-...)
--- Storing secret ---
Secret stored: OPENAI_KEY (v1)
--- Retrieving secret ---
Secret: OPENAI_KEY
Type: api_key
Value: sk-demo-...
Version: 1
--- Listing secrets ---
OPENAI_KEY (api_key, v1)
--- Billing usage ---
Tier: free
Free limit: 1000/month
Used this month: 5
--- Cleaning up ---
Vault and secret deleted.
Done!
npm run signupThis runs src/signup-and-share.ts, which:
- Creates a new user account via
POST /v1/auth/signup - Creates a vault and stores a
DATABASE_URLsecret - Shares the secret by email with a link that expires and has a max access count
Note: On production, signup sends a verification email instead of returning a JWT immediately. The script falls back to API key auth if available.
npm run intents-apiThis runs src/intents-api.ts, which:
- Creates a vault and stores a signing key at
keys/base-signer - Registers an agent with
intents_api_enabled: true - Grants the agent a read policy on
keys/** - Submits a transaction (signed server-side — the agent never sees the private key)
- Verifies the agent's configuration
- Disables the Intents API and cleans up
npm run execution-intentsThis runs src/execution-intents.ts, which:
- Creates a vault and stores a Stripe API key
- Registers an agent with
execution_intents_enabled: true - Creates a binding with an inline credential (HSM-encrypted copy)
- Creates a binding with a vault-ref credential (
credential_source: { type: "vault_ref", vault_id, path }) - Lists bindings showing both credential source types
- Rotates the vault secret — vault-ref bindings automatically resolve the new value
- Cleans up
| Command | Script | Description |
|---|---|---|
npm start |
src/index.ts |
Vault CRUD, secrets, billing |
npm run signup |
src/signup-and-share.ts |
User signup, create vault, share by email |
npm run intents-api |
src/intents-api.ts |
Agent with Intents API, transaction signing |
npm run execution-intents |
src/execution-intents.ts |
Execution Intents: bindings with inline & vault-ref credentials |
| Variable | Required | Description |
|---|---|---|
ONECLAW_API_KEY |
Yes* | Your API key (ocv_...). Get one at 1claw.xyz → Settings → API Keys. Not needed for signup script. |
ONECLAW_BASE_URL |
No | API URL (default: https://api.1claw.xyz) |
ONECLAW_AGENT_ID |
No | Agent UUID. When set, npm start authenticates as an agent. |
Create a client and authenticate:
import { createClient } from "@1claw/sdk";
const client = createClient({ baseUrl: "https://api.1claw.xyz" });
await client.auth.apiKeyToken({ api_key: "ocv_..." });Store and retrieve a secret:
await client.secrets.set(vaultId, "OPENAI_KEY", "sk-live-xxx", {
type: "api_key",
metadata: { provider: "openai" },
});
const { data } = await client.secrets.get(vaultId, "OPENAI_KEY");
console.log(data.value); // sk-live-xxx- LangChain Agent — Use an LLM to decide when to fetch secrets
- FastMCP Tool Server — Build a custom MCP server with 1Claw
- Transaction Simulation — AI agent with guardrails and Tenderly simulation
- 1Claw Docs