Documentation

Quickstart

Create an account, connect TextTree to an AI agent, send your first SMS, and confirm the agent can receive replies.

Copy-paste API examples
curl JavaScript Python Elixir
curl
curl https://api.texttree.ai/api/v1/messages \
  -H "Authorization: Bearer $TEXTREE_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"phone_number":"+15551234567","body":"Hello"}'

Copy this into Claude, Codex, or Cursor

Set up TextTree.ai SMS for my AI agent.

Use https://texttree.ai/docs/mcp/ and https://texttree.ai/docs/openai-mcp/. Assume I want a dedicated SMS number unless I say otherwise.

Create my TextTree account through the headless bootstrap flow, capture the one-time backup codes, and help me store them securely.

Store the returned txt_... TextTree bearer access token as TEXTREE_ACCESS_TOKEN. Do not use a txk_... legacy API key for /api/v1/messages or MCP.

Walk me through funding the dedicated number with $100 in credits, then initialize the number by sending a test SMS only after checking balance, spend limits, suppression state, and recipient approval.

After setup, retrieve and store:

- Assigned SMS number
- API base URL
- TEXTREE_ACCESS_TOKEN location
- MCP server URL: https://api.texttree.ai/mcp

Finally, create working tests that exercise the API shape and MCP tool discovery. Ask before sending any live SMS.

Agent-first setup

Start with the Prompt tab if you are working in Claude, Codex, Cursor, or another AI coding agent. It gives the agent a complete setup brief for creating a TextTree account, securing backup codes, preparing a dedicated SMS number, connecting MCP, and testing outbound and inbound SMS.

Use the direct code tabs when you already have a TextTree access token and want to send a message from your own shell or application.

Required values

Before running the API examples, set these placeholders:

  • TEXTREE_ACCESS_TOKEN: your TextTree bearer token from the app or agent bootstrap flow.
  • +15551234567: the destination phone number for your test SMS.

The API examples use the current TextTree V1 contract:

  • Base URL: https://api.texttree.ai/api/v1
  • Messages endpoint: https://api.texttree.ai/api/v1/messages
  • Auth header: Authorization: Bearer $TEXTREE_ACCESS_TOKEN
  • Message field: phone_number

Create an account

Start in the TextTree app, or let an AI client create a headless account with username/password over the API or MCP surface. Email, Google OAuth, wallet auth, and headless agent accounts all normalize into the same TextTree identity model.

https://app.texttree.ai/signup

Headless API bootstrap:

curl https://api.texttree.ai/api/v1/accounts \
  -H "Content-Type: application/json" \
  -d '{
    "username": "agent-demo",
    "password": "correct horse battery staple"
  }'

The bootstrap response returns one-time backup codes and a txt_... bearer token. Account creation is limited to one successful account per IP address every five minutes.

Send and verify

After sending your first SMS, open Messages in the console to inspect status, cost, failure reason, and the message timeline. Configure a webhook before going live so inbound replies and delivery events reach your application or agent workflow.

Go live

Add billing, complete compliance, register or connect a sender, and switch the environment to Live.