Source: https://fyno.docs.pageloop.ai/api-reference/user-properties/post-wsid-version-profiles-properties-batch

# Batch Update User Properties

POST `https://api.fyno.io/v1/{WSID}/{version}/profiles/properties/batch`

This API enables you to modify user properties of your users listed in your [User Profiles](../user-profiles-overview) in bulk:

- [Update User Properties](./update-user-property) - `$set`
- [Set Unset Properties](./set-an-unset-property) - `$once`
- [Increment/Decrement Numeric Properties](./increment-decrement-numeric-property) - `$add`
- [Append Values to List](./append-values-to-list) - `$append`
- [Remove Values From List](./remove-value-from-list) - `$remove`
- [Unset User Properties](./unset-user-property) - `$unset`

**Please refer to function specific API documentation for [$set](./update-user-property), [$once](./set-an-unset-property), [$add](./increment-decrement-numeric-property), [$append](./append-values-to-list), [$remove](./remove-value-from-list), [$unset](./unset-user-property) before using this API.**

**Note:** The user properties in User Profiles can be used to filter your users for creating [user cohorts](../creating-cohorts) and [campaigns](../campaign_creation#creating-a-campaign-using-cohort).

## 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 update the user property.

## Body

#### batch (body, array of object, required)

Enter an array of objects with `distinct_id` and `action` to perform on the user properties

#### properties

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

Enter the distinct ID that you use to identify the recipient.

#### action (object, required)

## Response

#### 202

Request has been accepted and will be processed asynchronously.

#### request\_id (string, required)

#### batch (array of object, required)

#### properties

#### $set (string)

#### $once (string)

#### $add (string)

#### $append (string)

#### $remove (string)

#### $unset (string)

#### 400

$unset object is empty

#### \_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}/profiles/properties/batch' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"batch": [{"distinct_id": "XXXXX", "action": {"$set": {"property_1": "some text", "property_2": 123, "property_3": 45.67}, "$once": {"property_4": true, "property_5": ["iPhone 16 Pro", "iPad 32 GB"], "property_6": "2020-10-01T18:30:00.000Z"}, "$add": {"property_7": 10.23, "property_8": -11.9, "property_9": 223}, "$append": {"property_10": "#12345", "property_11": 2030, "property_12": "2022-11-11T10:30:00+02:00"}, "$remove": {"property_13": "2023-11-10", "property_14": "ABC1234", "property_15": 4010}, "$unset": ["property_0", "old_property1"]}}]}'
```

```javascript JavaScript
const res = await fetch('https://api.fyno.io/v1/{WSID}/{version}/profiles/properties/batch', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"batch": [{"distinct_id": "XXXXX", "action": {"$set": {"property_1": "some text", "property_2": 123, "property_3": 45.67}, "$once": {"property_4": true, "property_5": ["iPhone 16 Pro", "iPad 32 GB"], "property_6": "2020-10-01T18:30:00.000Z"}, "$add": {"property_7": 10.23, "property_8": -11.9, "property_9": 223}, "$append": {"property_10": "#12345", "property_11": 2030, "property_12": "2022-11-11T10:30:00+02:00"}, "$remove": {"property_13": "2023-11-10", "property_14": "ABC1234", "property_15": 4010}, "$unset": ["property_0", "old_property1"]}}]}),
});
const data = await res.json();
```

```python Python
import requests

res = requests.post(
    'https://api.fyno.io/v1/{WSID}/{version}/profiles/properties/batch',
    headers={'Authorization': 'Bearer <token>'},
    json={"batch": [{"distinct_id": "XXXXX", "action": {"$set": {"property_1": "some text", "property_2": 123, "property_3": 45.67}, "$once": {"property_4": true, "property_5": ["iPhone 16 Pro", "iPad 32 GB"], "property_6": "2020-10-01T18:30:00.000Z"}, "$add": {"property_7": 10.23, "property_8": -11.9, "property_9": 223}, "$append": {"property_10": "#12345", "property_11": 2030, "property_12": "2022-11-11T10:30:00+02:00"}, "$remove": {"property_13": "2023-11-10", "property_14": "ABC1234", "property_15": 4010}, "$unset": ["property_0", "old_property1"]}}]}
)
data = res.json()
```

#### Response

```json 202
{
  "request_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "batch": [
    {
      "$set": "ok",
      "$once": "ok",
      "$add": "ok",
      "$append": "ok",
      "$remove": "ok",
      "$unset": "ok"
    }
  ]
}
```

```json 400
{
  "_message": "$set has object/keys that is not allowed",
  "status": "error"
}
```

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