Source: https://fyno.docs.pageloop.ai/api-reference/manage-user-profiles/patch-wsid-version-profiles-distinct-id-channel

# Add/Update channel data

PATCH `https://api.fyno.io/v1/{WSID}/{version}/profiles/{distinct_id}/channel`

This API enables you to update existing data for `sms`, `whatsapp`, `email`, `slack`, `discord`, and `teams` channels, and add new tokens for `push` and `inapp` channels. It works like an update for channels that can hold a single destination only and like an insert for channels that can hold multiple destinations/tokens.

## Authorization

#### Authorization (header, string, required)

Enter your API Key. If you don't have it already, you can create one from the API Keys page within your Fyno account

## Path Parameters

#### WSID (path, string, required)

Enter your workspace ID. You can obtain this value from the API Keys page within your Fyno account.

#### version (path, enum (string), required) — allowed: live, test

Specify the version for which you would like to manage the user profile.

#### distinct\_id (path, string, required)

Enter the distinct ID that you currently use to identify the user.

## Body

#### channel (body, object, required)

#### properties

#### discord (string)

Enter the new discord ID of the user. If you do not wish to change this value, remove this key from the payload.

#### email (string)

Enter the new email address of the user. If you do not wish to change this value, remove this key from the payload.

#### inapp (array of object)

#### push (array of object)

#### slack (string)

Enter the new channel ID, user ID, or email address of the user. If you do not wish to change this value, remove this key from the payload.

#### sms (string)

Enter the new mobile number of the user. The number must start with the country code (preferably in E.164 format). For example: +919879XXXXXX. If you do not wish to change this value, remove this key from the payload.

#### teams (string)

Enter the new channel name. For teams, we currently support sending to one channel only. If you wish to send to multiple channels, do get in touch and we can share a workaround. If you do not wish to change this value, remove this key from the payload.

#### voice (string)

Enter the new mobile number of the user. The number must start with the country code (preferably in E.164 format). For example: +919879XXXXXX. If you do not wish to change this value, remove this key from the payload.

#### whatsapp (string)

Enter the new WhatsApp mobile number of the user. The number must start with the country code (preferably in E.164 format). For example: +919879XXXXXX. If you do not wish to change this value, remove this key from the payload.

## Response

#### 200

Profile updated successfully

#### \_message (string, required)

#### status (string, required)

#### 400

Distinct ID does not exist

#### \_message (string, required)

#### status (string, required)

#### 401

API Key or Workspace ID is invalid. User is unauthorised.

#### \_message (string, required)

#### status (string, required)

#### Request

```bash cURL
curl -X PATCH 'https://api.fyno.io/v1/{WSID}/{version}/profiles/{distinct_id}/channel' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"channel": {"discord": "101XXXXXXXXXX7XXXXX", "email": "abcde@fghi.com", "inapp": [{"integration_id": "\u2026", "status": "\u2026", "token": "\u2026"}], "push": [{"integration_id": "\u2026", "status": "\u2026", "token": "\u2026"}], "slack": "CXXXXXXXXXX", "sms": "+919879XXXXXX", "teams": "General", "voice": "+919879XXXXXX", "whatsapp": "+919879XXXXXX"}}'
```

```javascript JavaScript
const res = await fetch('https://api.fyno.io/v1/{WSID}/{version}/profiles/{distinct_id}/channel', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"channel": {"discord": "101XXXXXXXXXX7XXXXX", "email": "abcde@fghi.com", "inapp": [{"integration_id": "\u2026", "status": "\u2026", "token": "\u2026"}], "push": [{"integration_id": "\u2026", "status": "\u2026", "token": "\u2026"}], "slack": "CXXXXXXXXXX", "sms": "+919879XXXXXX", "teams": "General", "voice": "+919879XXXXXX", "whatsapp": "+919879XXXXXX"}}),
});
const data = await res.json();
```

```python Python
import requests

res = requests.patch(
    'https://api.fyno.io/v1/{WSID}/{version}/profiles/{distinct_id}/channel',
    headers={'Authorization': 'Bearer <token>'},
    json={"channel": {"discord": "101XXXXXXXXXX7XXXXX", "email": "abcde@fghi.com", "inapp": [{"integration_id": "\u2026", "status": "\u2026", "token": "\u2026"}], "push": [{"integration_id": "\u2026", "status": "\u2026", "token": "\u2026"}], "slack": "CXXXXXXXXXX", "sms": "+919879XXXXXX", "teams": "General", "voice": "+919879XXXXXX", "whatsapp": "+919879XXXXXX"}}
)
data = res.json()
```

#### Response

```json 200
{
  "_message": "Channel has been modified successfully",
  "status": "ok"
}
```

```json 400
{
  "_message": "incorrect/non existing distinct_id provided",
  "status": "error"
}
```

```json 401
{
  "_message": "Invalid API details",
  "status": "error"
}
```
