> ## 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.

# Primeros pasos

> Autentica tu primer request y envía un mensaje de WhatsApp en minutos.

Esta guía te lleva del cero a tu primer mensaje de WhatsApp enviado por la API.

<Steps>
  <Step title="Obtén tu API key">
    La API key se emite desde el dashboard, en **Configuración → API**. Tiene el
    prefijo `sk_1to1_`.

    <Warning>
      La API key da acceso completo a las conversaciones de tu negocio. Trátala
      como un secreto — nunca la pongas en código cliente ni la subas a un
      repositorio.
    </Warning>
  </Step>

  <Step title="Identifica tu negocio">
    Todos los endpoints cuelgan de una base URL que incluye el `{slug}` de tu
    negocio:

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

    El `{slug}` también está en la configuración de la API. La key y el `slug`
    deben corresponder al **mismo negocio**.
  </Step>

  <Step title="Envía tu primer mensaje">
    Un `POST` al endpoint de texto, con la conversación identificada por
    teléfono:

    <CodeGroup>
      ```bash cURL theme={null}
      curl -X POST "https://app.1to1.ai/api/v1/public/{slug}/conversation/messages/text" \
        -H "Authorization: Bearer sk_1to1_tu_api_key" \
        -H "Content-Type: application/json" \
        -d '{
          "conversation": { "phone": "+5215512345678" },
          "body": "Hola 👋, ¿en qué te puedo ayudar?"
        }'
      ```

      ```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_tu_api_key",
            "Content-Type": "application/json",
          },
          body: JSON.stringify({
            conversation: { phone: "+5215512345678" },
            body: "Hola 👋, ¿en qué te puedo ayudar?",
          }),
        },
      );
      ```

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

      requests.post(
          "https://app.1to1.ai/api/v1/public/{slug}/conversation/messages/text",
          headers={"Authorization": "Bearer sk_1to1_tu_api_key"},
          json={
              "conversation": {"phone": "+5215512345678"},
              "body": "Hola 👋, ¿en qué te puedo ayudar?",
          },
      )
      ```
    </CodeGroup>
  </Step>

  <Step title="Maneja la respuesta">
    Una respuesta `201` confirma el envío:

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

    Los errores devuelven `{ code, message }` con un status `4xx` o `5xx`. Ambos
    campos están garantizados. Haz `switch` sobre `code` (estable), nunca sobre
    `message` (texto humano, puede afinarse entre versiones):

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

<Note>
  **Rate limit:** dos buckets independientes de 60 requests/min por API key —
  uno general (lecturas, tags, mailbox, notes, files) y otro para mensajes
  (text, quick-reply, template). Al excederlo recibes un `429` con el header
  `Retry-After`. Ver [Rate limits](/es/rate-limits).
</Note>

## Próximos pasos

<CardGroup cols={2}>
  <Card title="Conversaciones" icon="comments" href="/es/conversations">
    Cómo identificar una conversación y la ventana de 24h.
  </Card>

  <Card title="Mensajes" icon="paper-plane" href="/es/messages">
    Las cuatro formas de enviar un mensaje.
  </Card>
</CardGroup>
