# SDKs

Canonical URL: https://texttree.ai/en/docs/sdks/
Markdown URL: https://texttree.ai/en/docs/sdks.md
Page type: docs
Translation status: approved
Legal status: not_required

## Summary

Use TextTree from curl, JavaScript, Python, and Elixir.

## Source content

Reference client libraries live in the
[`sdks/`](https://github.com/alphagrowth/texttree-sms/tree/main/sdks) directory
(JavaScript and Python, both dependency-free), and a machine-readable
[OpenAPI spec](https://github.com/alphagrowth/texttree-sms/blob/main/docs/openapi.yaml)
describes the messaging surface for code generation and API tooling.

The snippets below show the raw HTTP calls the SDKs wrap.

## JavaScript

```js
const response = await fetch("https://api.texttree.ai/api/v1/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TEXTREE_ACCESS_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    phone_number: "+15551234567",
    body: "Hello from TextTree",
  }),
});

const result = await response.json();
```

## Python

```py
import os
import requests

response = requests.post(
    "https://api.texttree.ai/api/v1/messages",
    headers={"Authorization": f"Bearer {os.environ['TEXTREE_ACCESS_TOKEN']}"},
    json={"phone_number": "+15551234567", "body": "Hello from TextTree"},
    timeout=10,
)

result = response.json()
```

## Elixir

```elixir
Mix.install([:req])

result =
  Req.post!(
    "https://api.texttree.ai/api/v1/messages",
    auth: {:bearer, System.fetch_env!("TEXTREE_ACCESS_TOKEN")},
    json: %{
      phone_number: "+15551234567",
      body: "Hello from TextTree"
    }
  ).body
```

## curl

```bash
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 from TextTree"
  }'
```

## Notes

- Use TextTree access tokens with the scopes required by the endpoint.
- Use Live mode only after billing, compliance, and sender setup are complete.
- Use idempotency keys for workflow retries so duplicate jobs do not create duplicate sends.
