Knock Subscriptions API
A subscription represents a connection between a recipient and an object, used to represent a list.
A subscription represents a connection between a recipient and an object, used to represent a list.
openapi: 3.0.0
info:
title: Knock Audiences Subscriptions API
version: '1.0'
description: An Audience is a segment of users.
servers:
- url: https://api.knock.app
variables: {}
security:
- BearerAuth: []
tags:
- description: A subscription represents a connection between a recipient and an object, used to represent a list.
name: Subscriptions
paths:
/v1/users/{user_id}/subscriptions:
get:
callbacks: {}
description: Retrieves a paginated list of subscriptions for a specific user, in descending order.
operationId: listSubscriptionsForUser
parameters:
- description: The user ID to list subscriptions for.
in: path
name: user_id
required: true
schema:
type: string
x-struct: null
x-validate: null
- description: Associated resources to include in the response.
in: query
name: include[]
required: false
schema:
items:
enum:
- preferences
type: string
x-struct: null
x-validate: null
type: array
x-struct: null
x-validate: null
- description: Only returns subscriptions for the specified object references.
in: query
name: objects[]
required: false
schema:
items:
$ref: '#/components/schemas/RecipientReference'
type: array
x-struct: null
x-validate: null
- description: The cursor to fetch entries after.
in: query
name: after
required: false
schema:
type: string
x-struct: null
x-validate: null
- description: The cursor to fetch entries before.
in: query
name: before
required: false
schema:
type: string
x-struct: null
x-validate: null
- description: The number of items per page (defaults to 50).
in: query
name: page_size
required: false
schema:
type: integer
x-struct: null
x-validate: null
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ListSubscriptionsResponse'
description: OK
summary: List user subscriptions
tags:
- Subscriptions
x-ratelimit-tier: 4
/v1/objects/{collection}/bulk/subscriptions/add:
post:
callbacks: {}
description: Add subscriptions for all objects in a single collection. If a subscription for an object in the collection already exists, it will be updated. This endpoint also handles [inline identifications](/managing-recipients/identifying-recipients#inline-identifying-recipients) for the `recipient` field.
operationId: bulkAddSubscriptions
parameters:
- description: The collection this object belongs to.
example: projects
in: path
name: collection
required: true
schema:
type: string
x-struct: null
x-validate: null
requestBody:
content:
application/json:
example:
subscriptions:
- id: project-1
properties: null
recipients:
- id: user_1
schema:
$ref: '#/components/schemas/BulkUpsertSubscriptionsRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk add subscriptions
tags:
- Subscriptions
x-ratelimit-tier: 1
/v1/objects/{collection}/bulk/subscriptions/delete:
post:
callbacks: {}
description: Delete subscriptions for many objects in a single collection type. If a subscription for an object in the collection doesn't exist, it will be skipped.
operationId: bulkDeleteSubscriptions
parameters:
- description: The collection this object belongs to.
example: projects
in: path
name: collection
required: true
schema:
type: string
x-struct: null
x-validate: null
requestBody:
content:
application/json:
example:
subscriptions:
- id: subscribed-to-object-1
recipients:
- collection: projects
id: subscriber-project-1
- subscriber-user-1
- id: subscribed-to-object-2
recipients:
- subscriber-user-2
schema:
$ref: '#/components/schemas/BulkDeleteSubscriptionsRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk delete subscriptions
tags:
- Subscriptions
x-ratelimit-tier: 1
/v1/objects/{collection}/{object_id}/subscriptions:
delete:
callbacks: {}
description: Delete subscriptions for the specified recipients from an object. Returns the list of deleted subscriptions.
operationId: deleteSubscriptionsForObject
parameters:
- description: Unique identifier for the object.
in: path
name: object_id
required: true
schema:
type: string
x-struct: null
x-validate: null
- description: The collection this object belongs to.
in: path
name: collection
required: true
schema:
type: string
x-struct: null
x-validate: null
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteSubscriptionsRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsResponse'
description: OK
summary: Delete subscriptions
tags:
- Subscriptions
x-ratelimit-tier: 3
get:
callbacks: {}
description: List subscriptions for an object. Either list the recipients that subscribe to the provided object, or list the objects that the provided object is subscribed to. Determined by the `mode` query parameter.
operationId: listSubscriptionsForObject
parameters:
- description: Mode of the request. `recipient` to list the objects that the provided object is subscribed to, `object` to list the recipients that subscribe to the provided object.
in: query
name: mode
required: false
schema:
default: object
enum:
- recipient
- object
type: string
x-struct: null
x-validate: null
- description: Additional fields to include in the response.
in: query
name: include[]
required: false
schema:
items:
enum:
- preferences
type: string
x-struct: null
x-validate: null
type: array
x-struct: null
x-validate: null
- description: Recipients to filter by (only used if mode is `object`).
in: query
name: recipients[]
required: false
schema:
items:
$ref: '#/components/schemas/RecipientReference'
type: array
x-struct: null
x-validate: null
- description: Objects to filter by (only used if mode is `recipient`).
in: query
name: objects[]
required: false
schema:
items:
$ref: '#/components/schemas/ObjectReference'
type: array
x-struct: null
x-validate: null
- description: Unique identifier for the object.
in: path
name: object_id
required: true
schema:
type: string
x-struct: null
x-validate: null
- description: The collection this object belongs to.
in: path
name: collection
required: true
schema:
type: string
x-struct: null
x-validate: null
- description: The cursor to fetch entries after.
in: query
name: after
required: false
schema:
type: string
x-struct: null
x-validate: null
- description: The cursor to fetch entries before.
in: query
name: before
required: false
schema:
type: string
x-struct: null
x-validate: null
- description: The number of items per page (defaults to 50).
in: query
name: page_size
required: false
schema:
type: integer
x-struct: null
x-validate: null
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/ListSubscriptionsResponse'
description: OK
summary: List subscriptions
tags:
- Subscriptions
x-ratelimit-tier: 4
post:
callbacks: {}
description: Add subscriptions for an object. If a subscription already exists, it will be updated. This endpoint also handles [inline identifications](/managing-recipients/identifying-recipients#inline-identifying-recipients) for the `recipient`.
operationId: addSubscriptionsForObject
parameters:
- description: Unique identifier for the object.
in: path
name: object_id
required: true
schema:
type: string
x-struct: null
x-validate: null
- description: The collection this object belongs to.
in: path
name: collection
required: true
schema:
type: string
x-struct: null
x-validate: null
requestBody:
content:
application/json:
example:
properties:
key: value
recipients:
- user_1
- user_2
schema:
$ref: '#/components/schemas/UpsertSubscriptionsRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/SubscriptionsResponse'
description: OK
summary: Add subscriptions
tags:
- Subscriptions
x-ratelimit-tier: 3
components:
schemas:
BulkDeleteSubscriptionsRequest:
description: A request to delete subscriptions for many groups of 1 subscribed-to object, N subscriber recipients.
example:
subscriptions:
- id: subscribed-to-object-1
recipients:
- collection: projects
id: subscriber-project-1
- subscriber-user-1
- id: subscribed-to-object-2
recipients:
- subscriber-user-2
properties:
subscriptions:
description: A nested list of subscriptions.
items:
description: A list of subscriptions. 1 subscribed-to id, and N subscriber recipients.
properties:
id:
description: Unique identifier for the object.
nullable: false
type: string
x-struct: null
x-validate: null
recipients:
description: The recipients of the subscription. You can subscribe up to 100 recipients to an object at a time.
items:
$ref: '#/components/schemas/RecipientReference'
nullable: false
type: array
x-struct: null
x-validate: null
required:
- id
- recipients
type: object
x-struct: null
x-validate: null
type: array
x-struct: null
x-validate: null
required:
- subscriptions
title: BulkDeleteSubscriptionsRequest
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.BulkDeleteSubscriptionsRequest
x-validate: null
DiscordIncomingWebhookConnection:
description: Discord incoming webhook connection.
example:
incoming_webhook:
url: https://example.com/webhook
properties:
incoming_webhook:
description: Discord incoming webhook object.
properties:
url:
description: Incoming webhook URL.
example: https://example.com/webhook
type: string
x-struct: null
x-validate: null
required:
- url
type: object
x-struct: null
x-validate: null
required:
- incoming_webhook
title: DiscordIncomingWebhookConnection
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.DiscordChannelData.IncomingWebhookConnection
x-validate: null
RecipientReference:
description: A reference to a recipient, either a user identifier (string) or an object reference (ID, collection).
example: user_123
oneOf:
- description: The ID of the user which is used as the reference for the recipient.
example: user_123
nullable: false
title: UserReference
type: string
x-struct: null
x-validate: null
- description: A reference to a recipient object.
example:
collection: projects
id: project_123
properties:
collection:
description: The collection the recipient object belongs to.
example: projects
nullable: false
type: string
x-struct: null
x-validate: null
id:
description: An identifier for the recipient object.
example: project_123
nullable: false
type: string
x-struct: null
x-validate: null
title: ObjectReference
type: object
x-struct: null
x-validate: null
title: RecipientReference
x-struct: Elixir.SwitchboardWeb.V1.Specs.RecipientReference
x-validate: null
InlinePreferenceSetRequest:
additionalProperties:
$ref: '#/components/schemas/PreferenceSetRequest'
description: Inline set preferences for a recipient, where the key is the preference set id. Preferences that are set inline will be merged into any existing preferences rather than replacing them.
example:
default:
categories:
transactional:
channel_types:
email: false
channel_types:
email: true
title: InlinePreferenceSetRequest
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.InlinePreferenceSetRequest
x-validate: null
ListSubscriptionsResponse:
description: A response containing a list of subscriptions.
example:
entries:
- __typename: Subscription
inserted_at: '2021-01-01T00:00:00Z'
object:
__typename: Object
collection: assets
created_at: null
id: specimen_25
properties:
classification: Theropod
config:
biz: baz
foo: bar
name: Velociraptor
status: contained
updated_at: '2024-05-22T12:00:00Z'
recipient:
__typename: User
avatar: null
created_at: null
email: jane@ingen.net
id: jane
name: Jane Doe
phone_number: null
timezone: null
updated_at: '2024-05-22T12:00:00Z'
updated_at: '2021-01-01T00:00:00Z'
page_info:
__typename: PageInfo
after: null
before: null
page_size: 25
properties:
entries:
description: A list of subscriptions.
items:
$ref: '#/components/schemas/Subscription'
type: array
x-struct: null
x-validate: null
page_info:
$ref: '#/components/schemas/PageInfo'
required:
- entries
- page_info
title: ListSubscriptionsResponse
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.ListSubscriptionsResponse
x-validate: null
MsTeamsTokenConnection:
description: Microsoft Teams token connection.
example:
ms_teams_channel_id: 123e4567-e89b-12d3-a456-426614174000
ms_teams_team_id: 123e4567-e89b-12d3-a456-426614174000
ms_teams_tenant_id: null
ms_teams_user_id: null
properties:
ms_teams_channel_id:
description: Microsoft Teams channel ID.
format: uuid
nullable: true
type: string
x-struct: null
x-validate: null
ms_teams_team_id:
description: Microsoft Teams team ID.
format: uuid
nullable: true
type: string
x-struct: null
x-validate: null
ms_teams_tenant_id:
description: Microsoft Teams tenant ID.
format: uuid
nullable: true
type: string
x-struct: null
x-validate: null
ms_teams_user_id:
description: Microsoft Teams user ID.
format: uuid
nullable: true
type: string
x-struct: null
x-validate: null
title: MsTeamsTokenConnection
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.MsTeamsChannelData.TokenConnection
x-validate: null
PageInfo:
description: Pagination information for a list of resources.
example:
__typename: PageInfo
after: null
before: null
page_size: 25
properties:
__typename:
description: The typename of the schema.
example: PageInfo
type: string
x-struct: null
x-validate: null
after:
description: The cursor to fetch entries after.
nullable: true
type: string
x-struct: null
x-validate: null
before:
description: The cursor to fetch entries before.
nullable: true
type: string
x-struct: null
x-validate: null
page_size:
description: The number of items per page (defaults to 50).
type: integer
x-struct: null
x-validate: null
required:
- __typename
- page_size
title: PageInfo
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.PageInfo
x-validate: null
Object:
description: A custom [Object](/concepts/objects) entity which belongs to a collection.
example:
__typename: Object
collection: assets
created_at: null
id: specimen_25
properties:
classification: Theropod
config:
biz: baz
foo: bar
name: Velociraptor
status: contained
updated_at: '2024-05-22T12:00:00Z'
properties:
__typename:
description: The typename of the schema.
example: Object
type: string
x-struct: null
x-validate: null
collection:
description: The collection this object belongs to.
type: string
x-struct: null
x-validate: null
created_at:
description: Timestamp when the resource was created.
format: date-time
nullable: true
type: string
x-struct: null
x-validate: null
id:
description: Unique identifier for the object.
type: string
x-struct: null
x-validate: null
properties:
additionalProperties: true
description: The custom properties associated with the object.
type: object
x-struct: null
x-validate: null
updated_at:
description: The timestamp when the resource was last updated.
format: date-time
type: string
x-struct: null
x-validate: null
required:
- __typename
- id
- collection
- updated_at
title: Object
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.Object
x-validate: null
InlineIdentifyObjectRequest:
additionalProperties: true
description: A custom [Object](/concepts/objects) entity which belongs to a collection.
example:
collection: projects
id: project_1
name: My project
properties:
channel_data:
description: An optional set of [channel data](/managing-recipients/setting-channel-data) for the object. This is a list of `ChannelData` objects.
oneOf:
- $ref: '#/components/schemas/InlineChannelDataRequest'
- nullable: true
x-struct: null
x-validate: null
x-struct: null
x-validate: null
collection:
description: The collection this object belongs to.
nullable: false
type: string
x-struct: null
x-validate: null
created_at:
description: Timestamp when the resource was created.
format: date-time
nullable: true
type: string
x-struct: null
x-validate: null
id:
description: Unique identifier for the object.
nullable: false
type: string
x-struct: null
x-validate: null
name:
description: An optional name for the object.
nullable: true
type: string
x-struct: null
x-validate: null
preferences:
description: An optional set of [preferences](/concepts/preferences) for the object.
oneOf:
- $ref: '#/components/schemas/InlinePreferenceSetRequest'
- nullable: true
x-struct: null
x-validate: null
x-struct: null
x-validate: null
required:
- id
- collection
title: InlineIdentifyObjectRequest
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.InlineIdentifyObjectRequest
x-validate: null
MsTeamsIncomingWebhookConnection:
description: Microsoft Teams incoming webhook connection.
example:
incoming_webhook:
url: https://example.com/webhook
properties:
incoming_webhook:
description: Microsoft Teams incoming webhook.
properties:
url:
description: Microsoft Teams incoming webhook URL.
example: https://example.com/webhook
type: string
x-struct: null
x-validate: null
required:
- url
type: object
x-struct: null
x-validate: null
required:
- incoming_webhook
title: MsTeamsIncomingWebhookConnection
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.MsTeamsChannelData.IncomingWebhookConnection
x-validate: null
OneSignalChannelDataPlayerIdsOnly:
description: OneSignal channel data.
example:
player_ids:
- 123e4567-e89b-12d3-a456-426614174000
properties:
player_ids:
description: A list of OneSignal player IDs.
example:
- 123e4567-e89b-12d3-a456-426614174000
items:
description: OneSignal player ID.
format: uuid
nullable: false
type: string
x-struct: null
x-validate: null
nullable: false
type: array
x-struct: null
x-validate: null
required:
- player_ids
title: OneSignalChannelDataPlayerIdsOnly
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.OneSignalChannelDataPlayerIdsOnly
x-validate: null
PreferenceSetWorkflowCategorySetting:
description: Workflow or category preferences within a preference set
example:
channel_types:
email: false
channels:
aef6e715-df82-4ab6-b61e-b743e249f7b6: true
oneOf:
- example: false
type: boolean
x-struct: null
x-validate: null
- description: The settings object for a workflow or category, where you can specify channel types or conditions.
example:
channel_types:
email: false
channels:
aef6e715-df82-4ab6-b61e-b743e249f7b6: true
conditions: null
properties:
channel_types:
anyOf:
- $ref: '#/components/schemas/PreferenceSetChannelTypes'
- nullable: true
x-struct: null
x-validate: null
description: An object where the key is the channel type and the values are the preference settings for that channel type.
x-struct: null
x-validate: null
channels:
anyOf:
- $ref: '#/components/schemas/PreferenceSetChannels'
- nullable: true
x-struct: null
x-validate: null
description: An object where the key is the channel ID and the values are the preference settings for that channel ID.
x-struct: null
x-validate: null
conditions:
description: A list of conditions to apply to a channel type.
items:
$ref: '#/components/schemas/Condition'
nullable: true
type: array
x-struct: null
x-validate: null
title: PreferenceSetWorkflowCategorySettingObject
type: object
x-struct: null
x-validate: null
title: PreferenceSetWorkflowCategorySetting
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.PreferenceSetWorkflowCategorySetting
x-validate: null
Recipient:
description: A recipient of a notification, which is either a user or an object.
example:
__typename: User
avatar: null
created_at: null
email: jane@ingen.net
id: jane
name: Jane Doe
phone_number: null
timezone: null
updated_at: '2024-05-22T12:00:00Z'
oneOf:
- $ref: '#/components/schemas/User'
- $ref: '#/components/schemas/Object'
title: Recipient
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.Recipient
x-validate: null
ObjectReference:
description: A reference to a recipient object.
example:
collection: projects
id: project_123
properties:
collection:
description: The collection the recipient object belongs to.
example: projects
nullable: false
type: string
x-struct: null
x-validate: null
id:
description: An identifier for the recipient object.
example: project_123
nullable: false
type: string
x-struct: null
x-validate: null
title: ObjectReference
type: object
x-struct: null
x-validate: null
PreferenceSetChannelTypes:
description: Channel type preferences.
example:
email: true
sms:
conditions:
- argument: US
operator: equal_to
variable: recipient.country_code
properties:
chat:
description: Whether the channel type is enabled for the preference set.
oneOf:
- type: boolean
x-struct: null
x-validate: null
- $ref: '#/components/schemas/PreferenceSetChannelTypeSetting'
x-struct: null
x-validate: null
email:
description: Whether the channel type is enabled for the preference set.
oneOf:
- type: boolean
x-struct: null
x-validate: null
- $ref: '#/components/schemas/PreferenceSetChannelTypeSetting'
x-struct: null
x-validate: null
http:
description: Whether the channel type is enabled for the preference set.
oneOf:
- type: boolean
x-struct: null
x-validate: null
- $ref: '#/components/schemas/PreferenceSetChannelTypeSetting'
x-struct: null
x-validate: null
in_app_feed:
description: Whether the channel type is enabled for the preference set.
oneOf:
- type: boolean
x-struct: null
x-validate: null
- $ref: '#/components/schemas/PreferenceSetChannelTypeSetting'
x-struct: null
x-validate: null
push:
description: Whether the channel type is enabled for the preference set.
oneOf:
- type: boolean
x-struct: null
x-validate: null
- $ref: '#/components/schemas/PreferenceSetChannelTypeSetting'
x-struct: null
x-validate: null
sms:
description: Whether the channel type is enabled for the preference set.
oneOf:
- type: boolean
x-struct: null
x-validate: null
- $ref: '#/components/schemas/PreferenceSetChannelTypeSetting'
x-struct: null
x-validate: null
title: PreferenceSetChannelTypes
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.PreferenceSetChannelTypes
x-validate: null
PreferenceSetChannelTypeSetting:
description: A set of settings for a channel type. Currently, this can only be a list of conditions to apply.
example:
conditions:
- argument: US
operator: equal_to
variable: recipient.country_code
properties:
conditions:
description: A list of conditions to apply to a channel type.
items:
$ref: '#/components/schemas/Condition'
type: array
x-struct: null
x-validate: null
required:
- conditions
title: PreferenceSetChannelTypeSetting
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.PreferenceSetChannelTypes.PreferenceSetChannelTypeSetting
x-validate: null
SubscriptionsResponse:
description: A response containing a list of subscriptions.
example:
- __typename: Subscription
inserted_at: '2021-01-01T00:00:00Z'
object:
__typename: Object
collection: assets
created_at: null
id: specimen_25
properties:
classification: Theropod
config:
biz: baz
foo: bar
name: Velociraptor
status: contained
updated_at: '2024-05-22T12:00:00Z'
recipient:
__typename: User
avatar: null
created_at: null
email: jane@ingen.net
id: jane
name: Jane Doe
phone_number: null
timezone: null
updated_at: '2024-05-22T12:00:00Z'
updated_at: '2021-01-01T00:00:00Z'
items:
$ref: '#/components/schemas/Subscription'
title: SubscriptionsResponse
type: array
x-struct: Elixir.SwitchboardWeb.V1.Specs.SubscriptionsResponse
x-validate: null
PreferenceSetRequest:
description: A request to set a preference set for a recipient.
example:
__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
# --- truncated at 32 KB (67 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/knock/refs/heads/main/openapi/knock-subscriptions-api-openapi.yml