# Mandaí CLI

The official CLI is included in the public npm package [@mandai/sdk](https://www.npmjs.com/package/@mandai/sdk). It requires Node.js 20 or later.

```sh
npm install -g @mandai/sdk
mandai --help
# Set MANDAI_API_KEY securely in your environment before authenticated requests.
mandai preview --to +5511000000001 --body 'Pedido confirmado'
mandai send --to +5511000000001 --body 'Pedido confirmado' --idempotency-key order-123-confirmation
mandai status --message-id msg_example
```

Sandbox is the default. Use `--environment production` only after obtaining authorization to send to real recipients with a Production credential and active capacity. API keys are read only from `MANDAI_API_KEY`, never command arguments. Required scopes: `messages:send` for preview/send and `messages:read` for status.

Use `--body-file path.txt` or `--body-file -` (stdin) instead of `--body` to keep SMS text out of shell history. Success responses are JSON on stdout; errors are JSON on stderr and exit with code 1. Requests time out after 20 seconds, reject redirects and are never retried automatically. Preserve both the idempotency key and body when retrying the same intent after an uncertain result. HTTP 202 means accepted, not delivered.

- [Developer portal](https://mandaionline.com/developers/)
- [OpenAPI contract](https://mandaionline.com/openapi.json)
- [Errors and idempotency](https://mandaionline.com/docs-markdown/errors-and-idempotency.md)
- [Sandbox](https://mandaionline.com/docs-markdown/sandbox.md)
