## Set up SMS or email

`PUT https://whatsapp.paaltech.org/api/v1/businesses/{external_id}/channels/{channel}`

Turns SMS or email on for the business. Call again to change anything.

**SMS** goes through `provider` - `arkesel` (the default) or `hubtel` - under
`sender_id` (1-11 letters, digits or spaces; a business's own sender ID must first be
approved by that provider). PaalTech's account sends by default. With Arkesel a
business may send with its own Arkesel account instead: pass `arkesel.api_key`.
PaalChat checks the key with Arkesel, stores it encrypted and never returns it
(`own_key: true`); omit it to keep a saved key, send `null` to remove it. Switching
to Hubtel removes it.

**Email** goes through Resend from `from` - an address on a domain PaalChat sends for.

Ability: `connections.manage`

### Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `external_id` | string | yes | Your own ID for the business (Multi-SKUUL - the tenant ID). Max 191 characters. Pattern `^[A-Za-z0-9._:-]+$` |
| `channel` | string | yes | One of: `sms`, `email` |

### Body

| Name | Type | Required | Description |
|---|---|---|---|
| `sender_id` | string | null | no | SMS: 1-11 letters, digits or spaces. Max 11 characters |
| `provider` | string | null | no | SMS: the provider (default arkesel). One of: `arkesel`, `hubtel`, `` |
| `arkesel` | object | null | no | SMS through Arkesel: the business's own account. |
| `arkesel.api_key` | string | null | no | The business's own Arkesel API key; null removes a saved one. Never returned. |
| `from` | string | no | Email - required. Format email |
| `from_name` | string | null | no | Max 100 characters |
| `reply_to` | string | null | no | Format email |

### Request

```bash
curl --request PUT \
  --url 'https://whatsapp.paaltech.org/api/v1/businesses/presec/channels/channel' \
  --header "Authorization: Bearer $PAALCHAT_TOKEN" \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"sender_id": "PRESEC", "provider": "arkesel"}'
```

### Responses

- **200** - Set up (status connected, or pending until PaalTech has set the provider up).
- **401** - unauthenticated - missing, invalid, revoked or expired token

```json
{
  "error": {"code": "unauthenticated", "message": "A valid product token is required."}
}
```

- **403** - missing_ability, product_suspended or product_token_required

```json
{
  "error": {
    "code": "missing_ability",
    "message": "This token does not have the ability this request needs."
  }
}
```

- **404** - not_found - not yours, or does not exist

```json
{"error": {"code": "not_found", "message": "Business not found."}}
```

- **422** - validation_failed; channel_not_allowed (a sender ID, from address or provider PaalChat cannot use); invalid_provider_credentials (Arkesel does not accept the key).
- **429** - rate_limited - over 300 requests/minute for this product

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests. Slow down and retry after the Retry-After header."
  }
}
```

- **503** - provider_unavailable - Arkesel could not be reached to check the key; try again shortly.
