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

# Enviar contacto

> Envía uno o varios contactos como vCard

**Auth:** `TokenAccount` o `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotente:** no

## Descripción

Envía uno o más contactos como vCard. El destinatario recibe una tarjeta clicable que puede agregar el contacto directamente a su libreta de direcciones. El campo `vcard` acepta un **array** de objetos `VCard` (envío múltiple) **o** un único objeto (compatibilidad hacia atrás, el servidor acepta ambos formatos). Soporta `replyTo`, `replyPrivate`, `delay` (en segundos) y `source`. **No** soporta menciones.

## Ejemplos

### Contacto único

Envía un vCard con lo mínimo (`fullName` y `phone`). El destinatario recibe una única tarjeta clicable con el contacto "João Silva" listo para ser agregado a su libreta de direcciones.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/message/contact/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number": "5511999999999",
      "vcard": [
        {
          "fullName": "João Silva",
          "phone":    "5511888888888"
        }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/message/contact/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number: "5511999999999",
      vcard: [
        {
          fullName: "João Silva",
          phone:    "5511888888888"
        }
      ]
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/message/contact/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number": "5511999999999",
          "vcard": [
              {
                  "fullName": "João Silva",
                  "phone":    "5511888888888"
              }
          ]
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "number": "5511999999999",
          "vcard": [
              {
                  "fullName": "João Silva",
                  "phone":    "5511888888888"
              }
          ]
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/message/contact/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

### Múltiples contactos

Pasa tres contactos en el array `vcard`. El servidor envía todo como un único `ContactsArrayMessage`; el destinatario ve una tarjeta agrupada y elige qué nombres agregar a su libreta de direcciones.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/message/contact/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number": "5511999999999",
      "vcard": [
        {
          "fullName": "João Silva",
          "phone":    "5511888888888"
        },
        {
          "fullName": "Maria Souza",
          "phone":    "5511777777777"
        },
        {
          "fullName": "Carlos Lima",
          "phone":    "5511666666666"
        }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/message/contact/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number: "5511999999999",
      vcard: [
        { fullName: "João Silva",   phone: "5511888888888" },
        { fullName: "Maria Souza",  phone: "5511777777777" },
        { fullName: "Carlos Lima",  phone: "5511666666666" }
      ]
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/message/contact/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number": "5511999999999",
          "vcard": [
              {"fullName": "João Silva",  "phone": "5511888888888"},
              {"fullName": "Maria Souza", "phone": "5511777777777"},
              {"fullName": "Carlos Lima", "phone": "5511666666666"}
          ]
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "number": "5511999999999",
          "vcard": [
              { "fullName": "João Silva",  "phone": "5511888888888" },
              { "fullName": "Maria Souza", "phone": "5511777777777" },
              { "fullName": "Carlos Lima", "phone": "5511666666666" }
          ]
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/message/contact/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

### Contacto con organización, email y sitio web

Incluye los campos opcionales `organization`, `email` y `url` en el vCard. La tarjeta resultante muestra la empresa, el email de contacto y el sitio web debajo del nombre, ideal para presentar contactos comerciales completos.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/message/contact/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number": "5511999999999",
      "vcard": [
        {
          "fullName":     "João Silva",
          "phone":        "5511888888888",
          "organization": "Example S.A.",
          "email":        "joao@example.com",
          "url":          "https://example.com"
        }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/message/contact/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number: "5511999999999",
      vcard: [
        {
          fullName:     "João Silva",
          phone:        "5511888888888",
          organization: "Example S.A.",
          email:        "joao@example.com",
          url:          "https://example.com"
        }
      ]
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/message/contact/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number": "5511999999999",
          "vcard": [
              {
                  "fullName":     "João Silva",
                  "phone":        "5511888888888",
                  "organization": "Example S.A.",
                  "email":        "joao@example.com",
                  "url":          "https://example.com"
              }
          ]
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "number": "5511999999999",
          "vcard": [
              {
                  "fullName":     "João Silva",
                  "phone":        "5511888888888",
                  "organization": "Example S.A.",
                  "email":        "joao@example.com",
                  "url":          "https://example.com"
              }
          ]
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/message/contact/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Respuesta exitosa

El array `vcard` en la respuesta refleja exactamente lo que enviaste (con todos los contactos). Cuando hay más de un contacto, `message` se vuelve `"X contacts sent successfully in one message"`.

```json 200 OK theme={null}
{
  "success": true,
  "message": "Contact sent successfully",
  "status":  "sent",
  "data": {
    "messageId":   "3EB08FCF27E532F1B0F5",
    "direction":   "sent",
    "messageType": "contact",
    "vcard": [
      {
        "fullName":     "João Silva",
        "phone":        "5511888888888",
        "organization": "Example S.A.",
        "email":        "joao@example.com",
        "url":          "https://example.com"
      }
    ],
    "source":    "api",
    "timestamp": "2026-04-30T14:30:00Z",
    "chat": {
      "jid":     "5511999999999@s.whatsapp.net",
      "isGroup": false
    },
    "sender": {
      "jid":      "5511777777777@s.whatsapp.net",
      "instance": "minha-instancia"
    }
  }
}
```

<Note>
  Cuando `vcard` contiene un solo elemento, el servidor lo envía como `ContactMessage`. Para múltiples elementos, se envía como `ContactsArrayMessage` (un único mensaje agrupando varias tarjetas).
</Note>

## Parámetros de ruta

<ParamField path="instance" type="string" required>
  Nombre de la instancia (p. ej., `$Instance_Name`).
</ParamField>

## Cabeceras

<ParamField header="token" type="string" required>
  `TokenAccount` o `TokenInstance`.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Cuerpo de la solicitud

<ParamField body="number" type="string" required>
  Destino: teléfono (`5511999999999`) o JID (`@s.whatsapp.net`, `@lid`, `@g.us`, `@newsletter`).
</ParamField>

<ParamField body="vcard" type="VCard[]" required>
  Array de contactos a enviar. Cada elemento sigue la estructura abajo. El handler también acepta un **único** objeto `VCard` (sin array) por compatibilidad hacia atrás, convirtiéndolo internamente a un array de un solo elemento. Se requiere al menos un contacto.
</ParamField>

<ParamField body="vcard[].fullName" type="string" required>
  Nombre completo del contacto. Aparece como la etiqueta principal de la tarjeta.
</ParamField>

<ParamField body="vcard[].phone" type="string" required>
  Número de teléfono del contacto (con código de país, p. ej., `5511888888888`).
</ParamField>

<ParamField body="vcard[].organization" type="string">
  Organización/empresa del contacto (opcional).
</ParamField>

<ParamField body="vcard[].email" type="string">
  Email del contacto (opcional).
</ParamField>

<ParamField body="vcard[].url" type="string">
  URL/sitio web del contacto (opcional).
</ParamField>

<ParamField body="delay" type="int" default="0">
  Tiempo en **segundos** a esperar antes de enviar. Durante el intervalo, el servidor envía el indicador "escribiendo..." al destinatario y dispara "pausado" antes del envío real.
</ParamField>

<ParamField body="replyTo" type="string">
  ID del mensaje a citar (respuesta). El mensaje original debe pertenecer a la misma instancia y haber sido guardado en la base de datos.
</ParamField>

<ParamField body="replyPrivate" type="boolean" default="false">
  Cuando es `true` **y** `replyTo` apunta a un mensaje originado en un grupo, la respuesta se redirige al chat **privado** del autor original (manteniendo la cita). Ignorado si el mensaje original no es de un grupo. **Aviso:** este campo está definido en la struct pero el handler de contactos hace parsing manual del JSON y no está extrayendo `replyPrivate` del payload, por lo que actualmente se trata como `false`.
</ParamField>

<ParamField body="source" type="string" default="api">
  Identificador de origen para trazabilidad (p. ej., `crm`, `bot-suporte`, `n8n`). Guardado en el registro del mensaje en la base de datos y propagado a los webhooks. Cuando se omite, el default es `"api"`.
</ParamField>

## Notas

<Note>
  * **`delay` es en segundos**, no milisegundos.
  * El campo `vcard` acepta **tanto un array como un objeto único**. Recomendamos usar siempre un array (`[ {...} ]`) para evitar ambigüedad.
  * Cada contacto requiere **`fullName`** y **`phone`**. `organization`, `email` y `url` son opcionales.
  * Para envíos múltiples, WhatsApp agrupa los contactos en una única tarjeta en el chat, el destinatario puede elegir cuáles agregar.
  * Los mensajes de contacto **no soportan** `mention` ni `mentionAll`.
  * Para números BR (que comienzan con `55`), el servicio prueba automáticamente variaciones con y sin el 9° dígito.
  * Cada contacto en el array pasa por validación individual; si el elemento `N` falla, la respuesta es `400 Contact full name is required for contact N` o `400 Contact phone number is required for contact N`.
</Note>

## Errores

| HTTP | Status interno   | Mensaje                                          |
| ---- | ---------------- | ------------------------------------------------ |
| 400  | ,                | `Instance name is required`                      |
| 400  | ,                | `Invalid JSON format: <detail>`                  |
| 400  | ,                | `Failed to read request body: <detail>`          |
| 400  | ,                | `Number is required`                             |
| 400  | ,                | `At least one contact (vcard) is required`       |
| 400  | ,                | `Contact full name is required for contact N`    |
| 400  | ,                | `Contact phone number is required for contact N` |
| 400  | `invalid_number` | `Invalid phone number format: <detail>`          |
| 500  | `send_failed`    | `Failed to send message: <reason>`               |
| 404  | ,                | `Instance not found`                             |
| 503  | `disconnected`   | `Instance is not connected to WhatsApp`          |

Envoltorio de error:

```json theme={null}
{
  "success": false,
  "error": { "message": "At least one contact (vcard) is required" }
}
```
