Back to home
Developer API (Preview)

TXT CLAW API

Create a dedicated OpenClaw agent and talk to it over HTTPS. SMS provisioning is a separate lane and may be async.

Quickstart (1 line)

pnpm dlx txtclaw@latest init

Agent-friendly docs: /agents.md · /openapi.yaml

HTTP (curl)

Create an agent:

curl -sS "$TXTCLAW_API_BASE_URL/v1/agents" \
  -H "Authorization: Bearer $TXTCLAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "system_prompt": "You are a helpful assistant. Keep replies concise.",
    "sms": { "mode": "none" }
  }'

Send a message:

curl -sS "$TXTCLAW_API_BASE_URL/v1/agents/$AGENT_ID/messages" \
  -H "Authorization: Bearer $TXTCLAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Draft a polite text asking my landlord to fix a leak." }'

JS Example

const baseUrl =
  process.env.TXTCLAW_API_BASE_URL ?? "https://txtclaw-sms-e2e.lopez731.workers.dev"
const apiKey = process.env.TXTCLAW_API_KEY

const create = await fetch(`${baseUrl}/v1/agents`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    system_prompt: "You are a helpful assistant. Keep replies concise.",
    sms: { mode: "none" },
  }),
})
const { agent_id } = await create.json()

const msg = await fetch(`${baseUrl}/v1/agents/${agent_id}/messages`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${apiKey}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ text: "Summarize this: ..." }),
})
console.log(await msg.json())

Notes

  • Runtime API works immediately (no Twilio required).
  • SMS provisioning is preview/async; response may be needs_compliance.
  • Every response includes trace_id (and header x-txtclaw-trace-id).
  • If you get 429, respect Retry-After.
  • Stable agent ingest docs: /agents.md

Generate an API key in /dashboard/api-keys.