> ## Documentation Index
> Fetch the complete documentation index at: https://docs.1to1ai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Primeiros passos

> Autentique sua primeira requisição e envie uma mensagem de WhatsApp em minutos.

Este guia te leva do zero à sua primeira mensagem de WhatsApp enviada pela API.

<Steps>
  <Step title="Obtenha sua API key">
    A API key é emitida pelo dashboard, em **Configurações → API**. Ela tem o
    prefixo `sk_1to1_`.

    <Warning>
      A API key dá acesso completo às conversas do seu negócio. Trate-a como um
      segredo — nunca a coloque em código cliente nem a suba a um
      repositório.
    </Warning>
  </Step>

  <Step title="Identifique seu negócio">
    Todos os endpoints partem de uma base URL que inclui o `{slug}` do seu
    negócio:

    ```
    https://app.1to1.ai/api/v1/public/{slug}
    ```

    O `{slug}` também está nas configurações da API. A key e o `slug`
    devem corresponder ao **mesmo negócio**.
  </Step>

  <Step title="Envie sua primeira mensagem">
    Um `POST` ao endpoint de texto, com a conversa identificada por
    telefone:

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "https://app.1to1.ai/api/v1/public/{slug}/conversation/messages/text" \
        -H "Authorization: Bearer sk_1to1_sua_api_key" \
        -H "Content-Type: application/json" \
        -d '{
          "conversation": { "phone": "+5215512345678" },
          "body": "Olá 👋, como posso ajudar?"
        }'
      ```

      ```js JavaScript theme={null}
      const res = await fetch(
        "https://app.1to1.ai/api/v1/public/{slug}/conversation/messages/text",
        {
          method: "POST",
          headers: {
            Authorization: "Bearer sk_1to1_sua_api_key",
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            conversation: { phone: "+5215512345678" },
            body: "Olá 👋, como posso ajudar?",
          }),
        },
      );
      ```

      ```python Python theme={null}
      import requests

      requests.post(
          "https://app.1to1.ai/api/v1/public/{slug}/conversation/messages/text",
          headers={"Authorization": "Bearer sk_1to1_sua_api_key"},
          json={
              "conversation": {"phone": "+5215512345678"},
              "body": "Olá 👋, como posso ajudar?",
          },
      )
      ```
    </CodeGroup>
  </Step>

  <Step title="Trate a resposta">
    Uma resposta `201` confirma o envio:

    ```json theme={null}
    { "message_uuid": "...", "wamid": "..." }
    ```

    Os erros retornam `{ code, message }` com um status `4xx` ou `5xx`. Ambos
    os campos são garantidos. Faça `switch` sobre `code` (estável), nunca sobre
    `message` (texto humano, pode ser refinado entre versões):

    ```json theme={null}
    { "code": "WINDOW_CLOSED", "message": "..." }
    ```
  </Step>
</Steps>

<Note>
  **Rate limit:** dois buckets independentes de 60 requisições/min por API key —
  um geral (leituras, tags, mailbox, notes, files) e outro para mensagens (text,
  quick-reply, template). Ao exceder você recebe um `429` com o header
  `Retry-After`. Ver [Rate limits](/pt/rate-limits).
</Note>

## Próximos passos

<CardGroup cols={2}>
  <Card title="Conversas" icon="comments" href="/pt/conversations">
    Como identificar uma conversa e a janela de 24h.
  </Card>

  <Card title="Mensagens" icon="paper-plane" href="/pt/messages">
    As quatro formas de enviar uma mensagem.
  </Card>
</CardGroup>
