v30

latestOpenAPI 3.0.0raw.githubusercontent.com2026-04-22116135580.0 KB
Objects
Preferences

Update a preference set

Sets preferences within the given preference set. By default, this is a destructive operation and will replace any existing preferences with the preferences given. Use '__persistence_strategy': 'merge' to merge with existing preferences instead. If no object exists in the current environment for the given :collection and :object_id, Knock will create the object as part of this request. The preference set :id can be either default or a tenant.id. Learn more about per-tenant preferences.

put/v1/objects/{collection}/{object_id}/preferences/{id}

Path parameters

object_idstring required

Unique identifier for the object.

collectionstring required

The collection this object belongs to.

idstring required
Example:default

Unique identifier for the preference set.

Request body

__persistence_strategy__'merge' | 'replace'

Controls how the preference set is persisted. 'replace' will completely replace the preference set, 'merge' will merge with existing preferences.

commercial_subscribedboolean nullable

Whether the recipient is subscribed to commercial communications. When false, the recipient will not receive commercial workflow notifications.

Example request

{
  "__persistence_strategy__": "merge",
  "categories": {
    "marketing": false,
    "transactional": {
      "channel_types": {
        "email": false
      }
    }
  },
  "channel_types": {
    "email": true
  },
  "channels": {
    "2f641633-95d3-4555-9222-9f1eb7888a80": {
      "conditions": [
        {
          "argument": "US",
          "operator": "equal_to",
          "variable": "recipient.country_code"
        }
      ]
    },
    "aef6e715-df82-4ab6-b61e-b743e249f7b6": true
  },
  "commercial_subscribed": true,
  "workflows": {
    "dinosaurs-loose": {
      "channel_types": {
        "email": false
      }
    }
  }
}

Response

OK

commercial_subscribedboolean nullable

Whether the recipient is subscribed to commercial communications. When false, the recipient will not receive commercial workflow notifications.

idstring required

Unique identifier for the preference set.

Example response

{
  "categories": {
    "marketing": false,
    "transactional": {
      "channel_types": {
        "email": false
      }
    }
  },
  "channel_types": {
    "email": true,
    "push": false,
    "sms": {
      "conditions": [
        {
          "argument": "US",
          "operator": "equal_to",
          "variable": "recipient.country_code"
        }
      ]
    }
  },
  "commercial_subscribed": true,
  "id": "default",
  "workflows": null
}