All available operations for sending and manipulating preferences


List all preferences #

This endpoint returns information about all preferences set for a specific user.

HTTP Request #

HTTP:
GET https://api.cord.com/v1/users/<USER_ID>/preferences
cURL:
curl https://api.cord.com/v1/users/<USER_ID>/preferences \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord user ls-preferences <USER_ID>
GET https://api.cord.com/v1/users/<USER_ID>/preferences
Copy

Request Body #

This REST endpoint has no request body.

Response #

The response is a JSON array of objects with the following fields:


notification_channels
NotificationPreferences
notification_channels controls how users get notified about Cord activity.

This is an object with the following fields:

Show property details


Update preferences #

This endpoint updates preferences for a user.

HTTP Request #

HTTP:
PUT https://api.cord.com/v1/<USER_ID>/preferences
cURL:
curl https://api.cord.com/v1/users/<USER_ID>/preferences \
  -X PUT \
  -H 'Authorization: Bearer <ACCESS_TOKEN>'\
  -H 'Content-Type: application/json'
CLI:
# you can install @cord-sdk/cli for a simpler experience
cord user update-preferences <USER_ID>
PUT https://api.cord.com/v1/<USER_ID>/preferences
Copy

Request Body #


key
required
"notification_channels"
The preference key. notification_channels controls how users get notified about Cord activity.


value
required
Partial<NotificationPreferences>
The updated preference value. This will update only the keys that are passed along. For example, to disable Slack notification, but leave email untouched, you can use this value:
{
   "value": { "sendViaSlack": "false" },
}

This is an object with the following fields:

Show property details


Example Request #

In this example, suppose a user with the ID 123 exists. If you want to disable email notifications for this user, you can send this request:

cURL:
curl "https://api.cord.com/v1/123/preferences" \
  -X PUT \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "notification_channels",
    "value": {"sendViaSlack": false}
  }'
CLI:
# you can install @cord-sdk/cli for a simpler experience
              # you can install @cord-sdk/cli for a simpler experience
cord user update-preferences 123
--key=notification_channels
--value='{ "sendViaSlack": false }'
              
curl "https://api.cord.com/v1/123/preferences" \
  -X PUT \
  -H 'Authorization: Bearer <ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{
    "key": "notification_channels",
    "value": {"sendViaSlack": false}
  }'
Copy

If the request succeeds, the response will be:

JSON:
{
    "success": true,
    "message": "✅ You successfully updated user 123 preferences",
}
{
    "success": true,
    "message": "✅ You successfully updated user 123 preferences",
}
Copy

If the request does not succeed, the response will instead contain anerror and message explaining what went wrong:

JSON:
{
  "error": "<ERROR_CODE>",
  "message": "An explanation of the error code."
}
{
  "error": "<ERROR_CODE>",
  "message": "An explanation of the error code."
}
Copy

Not finding the answer you need? Ask our Developer Community

Ask Cordy