Source: https://fyno.docs.pageloop.ai/api-reference/manage-user-subscriptions-preferences/post-wsid-version-subscriptions-list-subscription-id-user

# Update user preference (single)

POST `https://api.fyno.io/v1/{WSID}/{version}/subscriptions/list/{subscription_id}/user`

This API enables you to update the channel preference of a user for a particular subscription topic.

**Note:** If the channel configuration for a subscription topic is set to 'required', then the user preference for the channel cannot be updated.

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

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

Enter the subscription ID to update the channel preference for the subscription topic. To update the user preference for all subscription topics at once (global preference), use 'all' instead of the subscription id.

## Body

#### channel (body, enum (string), required) — allowed: sms, whatsapp, email, discord, slack, teams, push, voice, inapp, webpush

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

#### status (body, enum (string), required) — allowed: opted-in, opted-out

## Response

#### 200

Subscription updated successfully

#### SXXXXXXXXX (object, required)

#### properties

#### discord (enum (string)) — allowed: opted-out, opted-in

#### email (enum (string)) — allowed: opted-out, opted-in

#### inapp (enum (string)) — allowed: opted-out, opted-in

#### push (enum (string)) — allowed: opted-out, opted-in

#### slack (enum (string)) — allowed: opted-out, opted-in

#### sms (enum (string)) — allowed: opted-out, opted-in

#### teams (enum (string)) — allowed: opted-out, opted-in

#### voice (enum (string)) — allowed: opted-out, opted-in

#### webpush (enum (string)) — allowed: opted-out, opted-in

#### whatsapp (enum (string)) — allowed: opted-out, opted-in

#### 400

Distinct ID, channel, or status is not provided

#### \_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 POST 'https://api.fyno.io/v1/{WSID}/{version}/subscriptions/list/{subscription_id}/user' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"channel": "sms", "distinct_id": "string", "status": "opted-in"}'
```

```javascript JavaScript
const res = await fetch('https://api.fyno.io/v1/{WSID}/{version}/subscriptions/list/{subscription_id}/user', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"channel": "sms", "distinct_id": "string", "status": "opted-in"}),
});
const data = await res.json();
```

```python Python
import requests

res = requests.post(
    'https://api.fyno.io/v1/{WSID}/{version}/subscriptions/list/{subscription_id}/user',
    headers={'Authorization': 'Bearer <token>'},
    json={"channel": "sms", "distinct_id": "string", "status": "opted-in"}
)
data = res.json()
```

#### Response

```json 200
{
  "SXXXXXXXXX": {
    "discord": "opted-out",
    "email": "opted-out",
    "inapp": "opted-out",
    "push": "opted-out",
    "slack": "opted-out",
    "sms": "opted-out",
    "teams": "opted-out",
    "voice": "opted-out",
    "webpush": "opted-out",
    "whatsapp": "opted-out"
  }
}
```

```json 400
{
  "_message": "distinct_id is required!",
  "status": "error"
}
```

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