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

# Crear canal

> Crea un nuevo canal (newsletter) vinculado a la cuenta conectada

**Auth:** `TokenAccount` o `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotente:** no (cada llamada crea un nuevo canal)

## Descripción

Crea un nuevo canal. La cuenta creadora se convierte automáticamente en administrador / propietario. El servicio acepta automáticamente los términos de uso (TOS) cuando WhatsApp los requiere, realizando un retry transparente luego de `AcceptTOSNotice`.

## Ejemplos

### Mínimo

Crea un canal solo con el `name` requerido. El canal nace sin descripción ni imagen, pero ya obtiene un `jid` permanente y un `inviteLink` en la respuesta.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/newsletter/create/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Important News"
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/newsletter/create/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      name: "Important News"
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/newsletter/create/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "name": "Important News"
      }
  )
  ```

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

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

  func main() {
      body := strings.NewReader(`{
          "name": "Important News"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/newsletter/create/"+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>

### Completo

Crea el canal con `description` y `picture` (URL pública). El servidor descarga la imagen, la convierte a JPEG 640x640 y la fija como imagen inicial del canal.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/newsletter/create/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Important News",
      "description": "Daily updates",
      "picture": "https://example.com/logo.png"
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/newsletter/create/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      name:        "Important News",
      description: "Daily updates",
      picture:     "https://example.com/logo.png"
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/newsletter/create/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "name":        "Important News",
          "description": "Daily updates",
          "picture":     "https://example.com/logo.png"
      }
  )
  ```

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

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

  func main() {
      body := strings.NewReader(`{
          "name":        "Important News",
          "description": "Daily updates",
          "picture":     "https://example.com/logo.png"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/newsletter/create/"+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>

### Con imagen base64

Mismo flujo, pero la imagen va inline como una URL `data:` con base64 en lugar de una URL externa. Útil cuando la imagen se genera localmente o está detrás de autenticación.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/newsletter/create/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Test Channel",
      "picture": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/newsletter/create/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      name:    "Test Channel",
      picture: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/newsletter/create/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "name":    "Test Channel",
          "picture": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
      }
  )
  ```

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

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

  func main() {
      body := strings.NewReader(`{
          "name":    "Test Channel",
          "picture": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/newsletter/create/"+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

La respuesta incluye el `channel.jid` permanente del canal recién creado (úsalo como `identifier` en llamadas posteriores), el `inviteLink` listo para compartir y el `state` actual. `subscriberCount` comienza en `0`, y `pictureUrl` viene como `null` cuando la imagen aún no fue procesada o no fue proporcionada.

```json 200 OK theme={null}
{
  "success": true,
  "message": "Newsletter created successfully",
  "channel": {
    "jid": "120363422585881117@newsletter",
    "state": "active",
    "name": "Important News",
    "description": "Daily updates",
    "inviteLink": "https://whatsapp.com/channel/120363422585881117",
    "subscriberCount": 0,
    "pictureUrl": null
  }
}
```

## Parámetros de ruta

<ParamField path="instance" type="string" required>
  Nombre de la instancia.
</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="name" type="string" required>
  Nombre del canal. No puede estar vacío.
</ParamField>

<ParamField body="description" type="string">
  Descripción / bio del canal.
</ParamField>

<ParamField body="picture" type="string">
  URL o base64. Convertida a JPEG (máx. 640x640). Un fallo solo registra una advertencia, el canal se crea sin imagen.
</ParamField>

## Notas

<Note>
  * En algunos países, crear un canal requiere una **cuenta WhatsApp Business verificada**. Si el servidor rechaza, el error de WhatsMeow se propaga.
  * Guarda el `channel.jid` devuelto, los enlaces de invitación pueden revocarse, pero el JID es permanente.
  * La creación **no es idempotente**: un retry automático ante un timeout de red puede duplicar el canal.
  * La imagen se redimensiona a 640x640 manteniendo proporción (formatos aceptados: JPEG, PNG, WebP, GIF).
</Note>

## Errores

| HTTP | Mensaje                                                                                 |
| ---- | --------------------------------------------------------------------------------------- |
| 400  | `The 'name' field is required`                                                          |
| 400  | `Instance is not connected to WhatsApp`                                                 |
| 500  | `failed to create newsletter: <reason>`                                                 |
| 501  | `WhatsApp client does not support newsletter creation (CreateNewsletter not available)` |
| 501  | `failed to create newsletter (terms may need acceptance)`                               |

Envoltorio:

```json theme={null}
{
  "success": false,
  "error": { "message": "The 'name' field is required" }
}
```

## Siguiente

<CardGroup cols={2}>
  <Card title="Información del canal" icon="circle-info" href="/es/api/newsletter/info">
    Confirma los datos después de la creación.
  </Card>

  <Card title="Listar canales" icon="list" href="/es/api/newsletter/list">
    Mira los canales suscritos.
  </Card>
</CardGroup>
