---
docId: doc_f59504328a80482ba73bf4545727ab22
title: Connect a channel
description: "Start a connection that a person completes to create one or more channels."
api:
  group: canales
  auth: bearer
  operations:
    - operationId: connectChannel
      method: POST
      path: /v1/channels/connections
      postmanName: Connect a channel
---

<script>
  import { Ways, Note, Collapsible } from '$lib/components';
</script>

# Connect a channel

Start a pending connection. A person completes it to create one or more channels in the workspace. [Check the connection](/api-reference/channels/connections/get) until its state is `connected`.

`completion` tells you how to finish the connection for its `type`:

- **`authorize`** (`messenger`, `instagram`, `facebook-comments`, `instagram-comments`): someone authorizes with Meta and chooses which pages or accounts to connect. The response has `shareUrl`, a link you can send to whoever manages the Facebook page or the Instagram account, even if they have no Platica account or are not part of your workspace. It also has `authorizeIn`, the same step inside Platica for someone on your team with a session. See [sending the link to someone else](/api-reference/channels#sending-the-link-to-someone-else).
- **`wizard`** (`whatsapp`, `email`, `gmail`, `outlook`): `authorizeIn` opens that channel's wizard in Platica, with `?connection=chc_…`. Someone on your team with a session and write access to Integrations finishes it there. There is no `shareUrl`. The connection becomes `connected` when a channel of that type is created in the workspace.

It also works to reconnect a channel that stopped working: request another connection of the same `type`.

For your site's chat or a web page, use [create a web chat](/api-reference/web-chats/create).

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/channels/connections \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "type": "messenger", "agentId": "'"$AGENT_ID"'" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.channels.connect({ type: "messenger", agentId: "agent_123" });
```

</Ways.Way>
</Ways>

## Query parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `workspace` | string | Workspace ID. Required if your credential covers several workspaces; without it the answer is `400` | If the credential has several |

## Request body

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `type` | string | The channel. With a shareable link: `messenger`, `instagram`, `facebook-comments`, or `instagram-comments`. With a wizard in Platica: `whatsapp`, `email`, `gmail`, or `outlook`. The rest are explained in [other types](#other-types) | ✓ |
| `agentId` | string \| null | The agent that will answer the resulting channels. It must exist in the workspace. If you omit it, they are left without an agent and you choose it later with [update a channel](/api-reference/channels/update) | — |
| `expiresInMinutes` | integer | How long the connection and its link last, in minutes: `15` to `10080` (7 days). If you omit it, `1440` (24 hours) | — |

```json
{
  "type": "messenger",
  "agentId": "tVKljCHCNiebQdasHeit",
  "expiresInMinutes": 2880
}
```

## Response

`201 Created`. `data` is the connection, in `awaiting_user`.

Messenger, Instagram, or comments (`completion: "authorize"`):

```json
{
  "status": "success",
  "message": "Pending: a person must complete this connection — see nextStep",
  "data": {
    "id": "chc_7f3k9QmX2pLwR4tZ",
    "type": "messenger",
    "completion": "authorize",
    "status": "awaiting_user",
    "authorizeIn": "https://app.platica.mx/workspace/g6yCA16pkWl5eXo7KszB/connect/channel/chc_7f3k9QmX2pLwR4tZ",
    "shareUrl": "https://app.platica.mx/connect/chl_Q2x7vR9mK4pT1sW8yZ3bN6cF0hJ5gL2dA7eU9iO4qXk",
    "createdAt": "2026-11-12T18:40:00.000Z",
    "expiresAt": "2026-11-14T18:40:00.000Z",
    "agentId": "tVKljCHCNiebQdasHeit",
    "availableAssets": [],
    "channels": [],
    "error": null,
    "nextStep": "Send shareUrl to whoever manages the Facebook page: it works without a Platica account until expiresAt. They sign in with Facebook and choose the pages. A member of this workspace with access to Integrations can also open authorizeIn. Then check this connection again with GET /v1/channels/connections/chc_7f3k9QmX2pLwR4tZ. To send a new link (the current one stops working), use POST /v1/channels/connections/chc_7f3k9QmX2pLwR4tZ/link."
  }
}
```

WhatsApp, email, Gmail, or Outlook (`completion: "wizard"`):

```json
{
  "status": "success",
  "message": "Pending: a person must complete this connection — see nextStep",
  "data": {
    "id": "chc_Vn2sQ8rT5wYk1LmP",
    "type": "whatsapp",
    "completion": "wizard",
    "status": "awaiting_user",
    "authorizeIn": "https://app.platica.mx/workspace/g6yCA16pkWl5eXo7KszB/integrations/channels/whatsapp/new?connection=chc_Vn2sQ8rT5wYk1LmP",
    "shareUrl": null,
    "createdAt": "2026-11-12T18:40:00.000Z",
    "expiresAt": "2026-11-13T18:40:00.000Z",
    "agentId": null,
    "availableAssets": [],
    "channels": [],
    "error": null,
    "nextStep": "Ask a person with access to Integrations in this workspace to open authorizeIn and finish the WhatsApp wizard in Platica. This connection becomes connected when the channel is created; check it with GET /v1/channels/connections/chc_Vn2sQ8rT5wYk1LmP."
  }
}
```

The fields are in [get a connection](/api-reference/channels/connections/get#response-fields). Save the `id`: you check the connection with it.

### Other types

| `type` | Response |
|--------|----------|
| `webchat`, `webpage` | `409 USE_WEBCHATS`. Web chat and the web page do not use a connection: they are created with [`POST /v1/webchats`](/api-reference/web-chats/create) (the web page with `mode: "page"`). `details.nextStep` says how |
| `telegram`, `sms`, `voice` | `409 CHANNEL_TYPE_NOT_AVAILABLE`. They cannot be connected yet. `details.channelsUrl` opens the channels in Platica, where they show as coming soon |
| Any other | `400 INVALID_REQUEST` |

```json
{
  "code": 409,
  "error": "Conflict - The resource state conflicts with this request",
  "details": {
    "code": "CHANNEL_TYPE_NOT_AVAILABLE",
    "message": "A \"telegram\" channel cannot be connected yet.",
    "channelsUrl": "https://app.platica.mx/workspace/g6yCA16pkWl5eXo7KszB/integrations/channels",
    "nextStep": "It is not available yet. channelsUrl opens the channels in Platica, where it shows as coming soon."
  }
}
```

## Errors

<Collapsible summary="Show error codes and fixes">

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | `type` is missing or is not a type Platica knows, `agentId` is not valid, or `expiresInMinutes` is not an integer between 15 and 10080. `details.issues` says which field. Also when your credential covers several workspaces and `?workspace=` is missing (`details.available`) |
| `401` | `UNAUTHENTICATED` / `CREDENTIAL_REVOKED` | The credential is missing, invalid, or no longer covers this workspace |
| `403` | `FORBIDDEN` | The credential does not have write access to Integrations, or does not have access to the `agentId` agent |
| `403` | `INSUFFICIENT_SCOPE` | The OAuth token does not have `platica:write` |
| `403` | `READ_ONLY_CREDENTIAL` | An internal Platica agent can only read |
| `404` | `AGENT_NOT_FOUND` | The `agentId` agent does not exist in this workspace |
| `409` | `USE_WEBCHATS` | `type` is `webchat` or `webpage`. Create it with [create a web chat](/api-reference/web-chats/create) |
| `409` | `CHANNEL_TYPE_NOT_AVAILABLE` | `type` is `telegram`, `sms`, or `voice`. `details.channelsUrl` opens the channels in Platica |
| `503` | `CHANNEL_NOT_CONFIGURED` | That type is not available in this environment yet |
| `503` | `OPERATION_UNCONFIRMED` | Platica could not confirm whether it created the connection. [List the connections](/api-reference/channels/connections/list) before retrying |

```json
{
  "code": 400,
  "error": "Bad Request - The request has validation errors",
  "details": {
    "code": "INVALID_REQUEST",
    "message": "expiresInMinutes must be at most 10080 (7 days)",
    "issues": [
      { "path": ["expiresInMinutes"], "message": "expiresInMinutes must be at most 10080 (7 days)" }
    ]
  }
}
```

Messages that come from Platica (`AGENT_NOT_FOUND`, `CHANNEL_NOT_CONFIGURED`, and the permission ones) are in Spanish; code against `details.code`. The general format is in [Errors](/api-reference/errors).

<Note type="important">

The connection and its link expire at `expiresAt`: 24 hours after requesting it, or what you say in `expiresInMinutes`. If the link was sent to the wrong person or more time is needed, [renew it](/api-reference/channels/connections/renew-link) before it expires. If it already expired, request another connection.

</Note>

</Collapsible>

## Notes

- `authorizeIn` is completed by a workspace member with write access to Integrations, with their Platica session. It does not have to be whoever requested the connection. `shareUrl` does not ask for a session: whoever has access to the page or account in Meta opens it.
- On a `wizard` connection, any channel of that type created in the workspace after you request it completes it, even if it was not opened from `authorizeIn`. It is checked every time you [get](/api-reference/channels/connections/get) or [list](/api-reference/channels/connections/list) connections.
- One connection can create several channels. If the account has several pages or accounts, the connection waits in `awaiting_selection`: [choose what to connect](/api-reference/channels/connections/select-assets), or let the person choose on the page where they authorized.
- To stop it before it finishes, [cancel it](/api-reference/channels/connections/cancel).
- Needs a workspace API key, or an OAuth token with write access to Integrations and the `platica:write` scope.
