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

> ## Agent Instructions
> Bridge exposes three integration surfaces: the REST Integrations API for pushing data into Bridge, webhooks for receiving events from Bridge, and the public Custom Connections endpoint that a tenant's landing page posts to.
> The Integrations API host is https://api-connect-us.bridge.new and every request to it must be authenticated with the x-api-key header. Bridge does not use bearer tokens or OAuth.
> The Custom Connections endpoint is different and the Integrations API rules do not apply to it: it has its own host, it takes no x-api-key and no authentication header of any kind, and it is called from a visitor's browser. It is identified by a workspace id and a capture key together with a reCAPTCHA token. Never tell a reader to authenticate it with an API key, and never tell them to keep its capture key out of frontend code - it is designed to live in the page.
> REST error catalog keys use BRIDGE_<DOMAIN>_<NNNN>, for example BRIDGE_CONVERSATION_0001. Some reviewed legacy handlers return a recognized code plus a symbolic suffix separated by |; preserve the complete received value and use the compatible catalog lookup on /error-codes. Custom Connections uses separate BRIDGE.CAMPAIGN_LEADS.<NAME> identifiers on its own error reference. Never invent an error code or confuse the two integration surfaces.
> This documentation covers the Integrations API, webhooks and Custom Connections only. It does not describe the Bridge web application or its internal APIs.
> Before generating an API request, read the relevant OpenAPI specification or the individual endpoint Markdown page. llms-full.txt collects guides and endpoint descriptions; it does not embed every request and response schema. The REST and Custom Connections contracts are separate.
> Preserve the published host, method, path, operationId, authentication, headers, parameter and field names, types, formats, required and nullable fields, enums, defaults, limits, and response codes. Do not invent identifiers, fields, retry rules, or delivery guarantees. When published sources conflict, identify the conflicting passages and ask Bridge support to confirm the current behavior before relying on it.
> Custom Connections is the current name of the landing-page feature previously documented as Lead Capture. The existing /lead-capture documentation URLs, captureKey field, campaign-leads endpoint, and BRIDGE.CAMPAIGN_LEADS error identifiers are unchanged. This is a naming change, not a change to authentication or the API contract.
> For a complete workflow, start with the task guides: /guides/first-conversation, /guides/send-attachments, /guides/send-template, /guides/agent-outbound, /guides/pagination, /guides/identifiers and /guides/responses. Read the endpoint contract as well as the recipe. Outbound requires an existing Contact, but does not require creating a separate Conversation first.
> forceSend=true permits reuse of an existing active conversation; it does not create a fresh one by ignoring it and it is not idempotency. Recovery of a released recoverable conversation can occur even with false. The LeadScout and Agents outbound routes have different line-selection and controller checks; use /guides/agent-outbound.
> For webhook HMAC, follow /webhooks/verifying-signatures exactly: the Python JSON serialization with sorted keys is signed; X-Bridge-Timestamp is not included in that signature. Do not claim a signed timestamp, raw-body signing, exactly-once delivery or a global event order. Use /webhooks/receive-events for durable acceptance and duplicates.
> A 201 message response, 202 handoff or 202 Custom Connections response is not a provider delivery receipt. Do not invent a polling endpoint from messageId, trackingId or requestId. REST validation parsing must tolerate the compatibility difference explained in /error-codes.
> The documentation is available in English (existing root URLs), Spanish (/es/) and Brazilian Portuguese (/pt-br/). Prefer the reader's language when a localized page exists, but preserve the API's exact field names, enums, routes, authentication and examples. Translations describe the same API; they do not introduce regional API hosts or behaviors.
> For coding-assistant setup, use /connect-your-agent, /es/connect-your-agent or /pt-br/connect-your-agent. The Bridge documentation MCP server reads published documentation and has a separate optional feedback tool. Connecting it does not connect the coding assistant to a customer workspace or authorize live business requests.
> For direct HTTP access without MCP, start at https://docs.bridge.new/llms.txt. It lists every published page in English, Spanish and Brazilian Portuguese. Choose /llms-en.json, /llms-es.json or /llms-pt-br.json for a language-specific index, and /llms-full-en.json, /llms-full-es.json or /llms-full-pt-br.json for collected content. /llms-full.txt contains the combined collection. Fetch the original OpenAPI specification for exact schemas.
> For HTTP page reads, follow the .md URLs from the index or request Accept: text/markdown at the canonical page URL. The MCP virtual filesystem uses .mdx page paths instead; .mdx is not the public HTTP export extension. With Search MCP, set language to en, es or pt-BR explicitly; its default is en.
> For integration capabilities and source-selection rules, read https://docs.bridge.new/skill.md. Documentation access does not authorize business API actions; use the actual user request, workspace, credentials and target identifiers for any live integration.

# Parâmetros de templates de WhatsApp

> Abra uma conversa com seus próprios templates de WhatsApp, preencha as variáveis e trate os erros que a requisição pode retornar.

## Visão geral

Ao criar uma conversa, `onboardingTemplates` permite escolher, em ordem, os templates de WhatsApp usados na abertura. Um template pode conter variáveis, como número de pedido, data de entrega ou nome do Contato. O Bridge preenche algumas delas para cada Contato; outras só você pode fornecer, enviando-as em `parameters` da entrada correspondente.

O fluxo tem três etapas:

1. Consulte as variáveis do template.
2. Decida quais valores enviar.
3. Envie-os com `POST .../conversations`.

> [!NOTE]
>
> Todas as verificações descritas nesta página ocorrem antes de qualquer criação. Se a requisição for rejeitada, **nenhuma conversa é criada e nenhuma mensagem é enviada**. Você pode corrigi-la e enviá-la novamente.

***

## 1. Encontre as variáveis do template

```http theme={null}
GET /bridge/api/v1/workspaces/{workspaceId}/templates/{templateId}
x-api-key: YOUR_API_KEY
```

`templateId` aceita o `id` ou o `name` do template. A resposta lista suas variáveis:

```json theme={null}
{
  "id": "f0000040-0000-4000-8000-000000000040",
  "name": "order_shipped_promo",
  "language": "es",
  "driftWarning": { "hasDrift": false, "stale": [], "missingLabels": [] },
  "variables": [
    { "key": "first_name", "label": "Contact first name", "callerMustSupply": false, "isCustom": false, "default": null },
    { "key": "order_number", "label": "Order number", "callerMustSupply": true, "isCustom": false, "default": null },
    { "key": "delivery_date", "label": "Delivery date", "callerMustSupply": true, "isCustom": false, "default": null },
    { "key": "tracking_code", "label": "Tracking code", "callerMustSupply": false, "isCustom": true, "default": "pending" }
  ]
}
```

`driftWarning` é apenas diagnóstico: informa diferenças entre as variáveis declaradas e o snapshot do template na Meta e nunca bloqueia um envio. A tabela abaixo descreve cada item de `variables`.

| Campo | Significado |
| - | - |
| `key` | O nome a usar em `parameters` |
| `label` | Uma descrição da variável legível por pessoas |
| `callerMustSupply` | `true` quando você precisa fornecer um valor não vazio porque o Bridge não tem uma fonte para ele; `false` nos demais casos |
| `isCustom` | Indica se a variável é personalizada: um valor que só você conhece, com um texto padrão |
| `default` | Para uma variável personalizada, o texto enviado quando você não fornece um valor; `null` nos demais casos |

Um template que não pertence ao workspace retorna `404` com `BRIDGE_TEMPLATE_0001`.

***

## 2. Decida quais valores enviar

| Variável | O que significa | O que fazer |
| - | - | - |
| `callerMustSupply: true` | O Bridge não tem uma fonte para esse valor | **Obrigatório.** Envie um valor não vazio para sua `key` |
| `callerMustSupply: false`, `isCustom: false` | O Bridge preenche o valor para cada Contato, como o primeiro nome | **Opcional.** Omita-o para manter o valor do Bridge |
| `isCustom: true` | Um valor que só você conhece, com um `default` | **Opcional.** Envie seu valor, omita-o ou envie-o vazio para usar o `default` |

Um valor enviado para uma variável `callerMustSupply: false` substitui o valor do Bridge e é usado **para todos os Contatos** da conversa.

> [!WARNING]
>
> Para uma variável não personalizada, mantenha o valor do Bridge **omitindo a chave**. Um valor vazio não significa "usar o padrão": ele é enviado como você o escreveu. Uma variável obrigatória vazia ou composta apenas de espaços é rejeitada como ausente. Somente variáveis personalizadas (`isCustom: true`) tratam um valor vazio como não enviado e usam seu `default`.

***

## 3. Envie os parâmetros

Cada entrada de `onboardingTemplates` recebe o `id` do template retornado na etapa 1 e seus `parameters`, indexados pela `key` da variável. A posição na lista define a ordem de envio.

```http theme={null}
POST /bridge/api/v1/workspaces/{workspaceId}/conversations
x-api-key: YOUR_API_KEY
Content-Type: application/json
```

```json theme={null}
{
  "participants": {
    "externals": [
      {
        "identifier": "+13802098869",
        "identifierType": "PHONE",
        "messageProviderType": "WHATSAPP",
        "brandId": "YOUR_BRAND_ID"
      }
    ]
  },
  "onboardingTemplates": [
    {
      "templateId": "f0000040-0000-4000-8000-000000000040",
      "parameters": {
        "order_number": "A-10492",
        "delivery_date": "3 de octubre"
      }
    }
  ]
}
```

Neste exemplo, `first_name` e `tracking_code` são omitidos. Assim, cada Contato recebe seu próprio primeiro nome, e `tracking_code` é enviado com seu valor padrão, `pending`.

Limites por template: no máximo **50** parâmetros, chaves de até **128** caracteres e valores de até **1.024** caracteres. Requisições que ultrapassam esses limites são rejeitadas como malformadas; veja [erros](#errors).

Conforme a configuração do workspace, seus templates substituem toda a sequência inicial ou apenas o primeiro template. No segundo caso, o restante da sequência configurada ainda é enviado depois dos seus.

***

## Regras de valores do WhatsApp

O WhatsApp rejeita determinados valores no envio da mensagem. O Bridge os verifica antes para que a requisição falhe enquanto você ainda pode corrigi-los:

| Regra | Limite |
| - | - |
| Quebras de linha e tabulações | Não permitidas: sem `\n`, `\r` ou `\t` |
| Espaços consecutivos | No máximo quatro seguidos |
| Cabeçalho | O texto do cabeçalho com o valor inserido deve caber em **60** caracteres |
| Botão de URL | O link do botão com o valor inserido deve caber em **2.000** caracteres |
| Corpo | O texto do corpo mais todos os valores deve caber em **1.024** caracteres |

> [!WARNING]
>
> O limite do corpo inclui os valores que o Bridge preenche para cada Contato, como o primeiro nome. O Bridge só consegue verificar os valores disponíveis no momento da requisição; reserve espaço para os demais.

O Bridge nunca remove espaços das extremidades nem reescreve seus valores: o que você envia é o que o Contato recebe.

***

## Erros

Todos os erros usam o formato `application/problem+json` descrito em [códigos de erro](https://docs.bridge.new/pt-br/error-codes.md). Escolha o tratamento por `code`, nunca por `title`.

| Código | Status | Quando ocorre | `extra` |
| - | - | - | - |
| `BRIDGE_CONVERSATION_0601` | 404 | O template não existe | `templateId`, `workspaceId` |
| `BRIDGE_CONVERSATION_0602` | 400 | O template pertence a outro workspace | `templateId`, `workspaceId` |
| `BRIDGE_CONVERSATION_0603` | 400 | O template não foi aprovado para a linha pela qual um participante será contatado | `templateId`, `workspaceId`, `userIds` (os Contatos cuja linha não tem aprovação, quando conhecidos) |
| `BRIDGE_CONVERSATION_0604` | 422 | Uma variável obrigatória está ausente ou vazia | `templateId`, `missingVariables: [{key, label}]` |
| `BRIDGE_CONVERSATION_0605` | 422 | Uma chave de `parameters` não está entre as variáveis do template | `templateId`, `unknownKeys: [key]` |
| `BRIDGE_CONVERSATION_0606` | 422 | `parameters` foi enviado para um template que não é de WhatsApp | `templateId` |
| `BRIDGE_CONVERSATION_0607` | 422 | Um valor viola uma [regra do WhatsApp](#whatsapp-value-rules) | `templateId`, `invalidVariables: [{key, label, reason}]` |
| `BRIDGE_CONVERSATION_0608` | 422 | Um template enviado pelo workspace depois do seu exige valores que só o integrador pode fornecer | `templateId`, `origin: "WORKSPACE_CONFIGURATION"` |

### Valores ausentes — `0604`

```json theme={null}
{
  "title": "A template named in the onboarding override is missing values only the caller can provide",
  "status": 422,
  "detail": "A template named in the onboarding override is missing values only the caller can provide",
  "code": "BRIDGE_CONVERSATION_0604",
  "extra": {
    "templateId": "f0000040-0000-4000-8000-000000000040",
    "missingVariables": [
      { "key": "delivery_date", "label": "Delivery date" }
    ]
  }
}
```

### Valores inválidos — `0607`

```json theme={null}
{
  "title": "Parameter values for an onboarding template break a WhatsApp rule and would be rejected when sent",
  "status": 422,
  "detail": "Parameter values for an onboarding template break a WhatsApp rule and would be rejected when sent",
  "code": "BRIDGE_CONVERSATION_0607",
  "extra": {
    "templateId": "f0000040-0000-4000-8000-000000000040",
    "invalidVariables": [
      { "key": "order_number", "label": "Order number", "reason": "NEWLINE" }
    ]
  }
}
```

`reason` informa a primeira regra violada pelo valor:

| `reason` | Significado |
| - | - |
| `NEWLINE` | O valor contém `\n` ou `\r` |
| `TAB` | O valor contém `\t` |
| `CONSECUTIVE_SPACES` | O valor contém mais de quatro espaços seguidos |
| `TOO_LONG` | O cabeçalho ou botão de URL ultrapassa o limite com o valor inserido |
| `BODY_TOO_LONG` | O corpo ultrapassa 1.024 caracteres; todos os valores de corpo enviados são listados |

### O erro `0608` não se resolve alterando a requisição

`BRIDGE_CONVERSATION_0608` ocorre somente em workspaces em que seus templates substituem apenas o primeiro template da sequência inicial. Isso significa que um template enviado pelo workspace depois do seu precisa de valores que só o integrador pode fornecer e que a API não consegue suprir. Peça a um administrador para alterar a sequência inicial.

### Requisições malformadas

Uma requisição incompatível com o esquema — mais de 50 parâmetros, chave com mais de 128 caracteres, valor com mais de 1.024 caracteres ou campo desconhecido — é rejeitada com `422` **sem `code`**. Nesse caso, uma lista `errors` aponta cada problema:

```json theme={null}
{
  "title": "Unprocessable content",
  "status": 422,
  "errors": [
    {
      "loc": ["body", "onboardingTemplates", 0, "parameters", "order_number"],
      "msg": "String should have at most 1024 characters",
      "type": "string_too_long"
    }
  ]
}
```

### Ordem de avaliação

As verificações seguem esta ordem, e **o primeiro erro prevalece**:

1. Limite de requisições — `429`
2. Formato da requisição — `422` sem `code`
3. Participantes, marca e linha — `400` / `409`, por exemplo, `BRIDGE_BRAND_0101` ou `BRIDGE_PROVIDER_CHANNEL_0001`
4. Cada template, na ordem da lista: `0601` / `0602` → `0603` → `0606` → `0605` → `0604` → `0607`
5. `0608`, somente em workspaces onde seus templates substituem apenas o primeiro template

Por isso, corrigir um erro pode revelar o próximo. Os valores de um template posterior só são verificados depois que todos os anteriores passam.

***

## Tópicos relacionados

* [Criar uma conversa](https://docs.bridge.new/pt-br/api-reference/conversations-api/criar-conversa-com-identifica%C3%A7%C3%A3o-flex%C3%ADvel-de-usu%C3%A1rios) — Referência completa da requisição e resposta
* [Códigos de erro](https://docs.bridge.new/pt-br/error-codes.md) — Todos os códigos, incluindo erros de marca e linha
* [Limites de requisições](https://docs.bridge.new/pt-br/rate-limits.md) — Tratamento de `429`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.