Knock Bulk operations API
A bulk operation is a set of changes applied across zero or more records triggered via a call to the Knock API and performed asynchronously.
A bulk operation is a set of changes applied across zero or more records triggered via a call to the Knock API and performed asynchronously.
openapi: 3.0.0
info:
title: Knock Audiences Bulk operations API
version: '1.0'
description: An Audience is a segment of users.
servers:
- url: https://api.knock.app
variables: {}
security:
- BearerAuth: []
tags:
- description: A bulk operation is a set of changes applied across zero or more records triggered via a call to the Knock API and performed asynchronously.
name: Bulk operations
paths:
/v1/bulk_operations/{id}:
get:
callbacks: {}
description: Retrieves a bulk operation (if it exists) and displays the current state of it.
operationId: getBulkOperation
parameters:
- description: The ID of the bulk operation to retrieve.
in: path
name: id
required: true
schema:
format: uuid
type: string
x-struct: null
x-validate: null
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Get bulk operation
tags:
- Bulk operations
x-ratelimit-tier: 4
/v1/objects/{collection}/bulk/delete:
post:
callbacks: {}
description: Bulk deletes objects from the specified collection.
operationId: bulkDeleteObjects
parameters:
- 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:
object_ids:
- obj_123
- obj_456
- obj_789
schema:
$ref: '#/components/schemas/BulkDeleteObjectsRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk delete objects
tags:
- Bulk operations
x-ratelimit-tier: 1
/v1/users/bulk/preferences:
post:
callbacks: {}
description: Bulk sets the preferences for up to 1,000 users at a time. The preference set `:id` can be either `default` or a `tenant.id`. Learn more about [per-tenant preferences](/preferences/tenant-preferences). Note that this is a destructive operation and will replace any existing users' preferences with the preferences sent.
operationId: bulkSetUserPreferences
parameters: []
requestBody:
content:
application/json:
example:
preferences:
__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
user_ids:
- user_1
- user_2
schema:
$ref: '#/components/schemas/BulkSetUserPreferencesRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk set preferences
tags:
- Bulk operations
x-ratelimit-tier: 1
/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:
- Bulk operations
x-ratelimit-tier: 1
/v1/users/bulk/identify:
post:
callbacks: {}
description: Identifies multiple users in a single operation. Allows creating or updating up to 1,000 users in a single batch with various properties, preferences, and channel data.
operationId: bulkIdentifyUsers
parameters: []
requestBody:
content:
application/json:
example:
users:
- email: jane@ingen.net
id: user_1
name: Jane Doe
timezone: America/New_York
schema:
$ref: '#/components/schemas/BulkIdentifyUsersRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk identify users
tags:
- Bulk operations
x-ratelimit-tier: 1
/v1/tenants/bulk/delete:
post:
callbacks: {}
description: Delete up to 1,000 tenants at a time in a single operation. This operation cannot be undone.
operationId: bulkDeleteTenants
parameters:
- description: The IDs of the tenants to delete.
in: query
name: tenant_ids[]
required: true
schema:
items:
type: string
x-struct: null
x-validate: null
type: array
x-struct: null
x-validate: null
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk delete tenants
tags:
- Bulk operations
x-ratelimit-tier: 1
/v1/channels/{channel_id}/messages/bulk/{action}:
post:
callbacks: {}
description: Bulk update the status of messages for a specific channel. The channel is specified by the `channel_id` parameter. The action to perform is specified by the `action` parameter, where the action is a status change action (e.g. `archive`, `unarchive`).
operationId: bulkUpdateMessagesForChannel
parameters:
- description: The ID of the channel to update messages for.
in: path
name: channel_id
required: true
schema:
format: uuid
type: string
x-struct: null
x-validate: null
- description: The target status to be applied to the messages.
in: path
name: action
required: true
schema:
enum:
- seen
- unseen
- read
- unread
- archived
- unarchived
- interacted
- archive
- unarchive
- delete
type: string
x-struct: null
x-validate: null
requestBody:
content:
application/json:
example:
archived: include
delivery_status: delivered
engagement_status: seen
has_tenant: true
newer_than: '2024-01-01T00:00:00Z'
older_than: '2024-01-01T00:00:00Z'
recipient_ids:
- recipient1
- recipient2
tenants:
- tenant1
- tenant2
trigger_data: '{"key":"value"}'
workflows:
- workflow1
- workflow2
schema:
$ref: '#/components/schemas/BulkUpdateMessagesForChannelRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk update message statuses for channel
tags:
- Bulk operations
x-ratelimit-tier: 2
x-retention-policy: true
/v1/users/bulk/delete:
post:
callbacks: {}
description: Permanently deletes up to 1,000 users at a time.
operationId: bulkDeleteUsers
parameters: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/BulkDeleteUsersRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk delete users
tags:
- Bulk operations
x-ratelimit-tier: 1
/v1/schedules/bulk/create:
post:
callbacks: {}
description: Bulk creates up to 1,000 schedules at a time. This endpoint also handles [inline identifications](/managing-recipients/identifying-recipients#inline-identifying-recipients) for the `actor`, `recipient`, and `tenant` fields.
operationId: bulkCreateSchedules
parameters: []
requestBody:
content:
application/json:
example:
schedules:
- data:
key: value
ending_at: null
recipient: dnedry
repeats:
- __typename: ScheduleRepeat
day_of_month: null
days:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
frequency: daily
hours: null
interval: 1
minutes: null
scheduled_at: null
tenant: acme_corp
workflow: comment-created
- data:
key: value
ending_at: null
recipient: esattler
repeats:
- __typename: ScheduleRepeat
day_of_month: null
days:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
frequency: daily
hours: null
interval: 1
minutes: null
scheduled_at: null
tenant: acme_corp
workflow: comment-created
schema:
$ref: '#/components/schemas/BulkCreateSchedulesRequest'
description: Schedule bulk creation request
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Create schedules in bulk
tags:
- Bulk operations
x-ratelimit-tier: 1
/v1/tenants/bulk/set:
post:
callbacks: {}
description: Set or update up to 1,000 tenants in a single operation.
operationId: bulkSetTenants
parameters: []
requestBody:
content:
application/json:
example:
tenants:
- id: tenant_1
name: Acme Corp, Inc.
schema:
$ref: '#/components/schemas/BulkSetTenantsRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk set tenants
tags:
- Bulk operations
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:
- Bulk operations
x-ratelimit-tier: 1
/v1/objects/{collection}/bulk/set:
post:
callbacks: {}
description: Bulk sets up to 1,000 objects at a time in the specified collection.
operationId: bulkSetObjects
parameters:
- 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:
objects:
- id: project_1
name: My project
schema:
$ref: '#/components/schemas/BulkSetObjectsRequest'
description: Params
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/BulkOperation'
description: OK
summary: Bulk set objects
tags:
- Bulk operations
x-ratelimit-tier: 1
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
BulkDeleteUsersRequest:
description: A request to delete users in bulk.
example:
user_ids:
- user_1
- user_2
properties:
user_ids:
description: A list of user IDs.
items:
description: The unique identifier of the user.
type: string
x-struct: null
x-validate: null
type: array
x-struct: null
x-validate: null
required:
- user_ids
title: BulkDeleteUsersRequest
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.BulkDeleteUsersRequest
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
TenantRequest:
additionalProperties: true
description: A tenant to be set in the system. You can supply any additional properties on the tenant object.
example:
id: tenant_123
name: ACME Corp, Inc.
settings:
branding:
icon_url: https://example.com/icon.png
logo_url: https://example.com/logo.png
primary_color: '#000000'
primary_color_contrast: '#FFFFFF'
properties:
channel_data:
description: The channel data for the tenant.
oneOf:
- nullable: true
x-struct: null
x-validate: null
- $ref: '#/components/schemas/InlineChannelDataRequest'
x-struct: null
x-validate: null
id:
description: The unique identifier for the tenant.
type: string
x-struct: null
x-validate: null
name:
description: An optional name for the tenant.
nullable: true
type: string
x-struct: null
x-validate: null
preferences:
description: The preferences for the tenant.
oneOf:
- nullable: true
x-struct: null
x-validate: null
- $ref: '#/components/schemas/InlinePreferenceSetRequest'
x-struct: null
x-validate: null
settings:
description: The settings for the tenant. Includes branding and preference set.
properties:
branding:
description: The branding for the tenant.
properties:
icon_url:
description: The icon URL for the tenant. Must point to a valid image with an image MIME type.
nullable: true
type: string
x-struct: null
x-validate: null
logo_url:
description: The logo URL for the tenant. Must point to a valid image with an image MIME type.
nullable: true
type: string
x-struct: null
x-validate: null
primary_color:
description: The primary color for the tenant, provided as a hex value.
nullable: true
type: string
x-struct: null
x-validate: null
primary_color_contrast:
description: The primary color contrast for the tenant, provided as a hex value.
nullable: true
type: string
x-struct: null
x-validate: null
type: object
x-struct: null
x-validate: null
preference_set:
description: The preference set for the tenant. Used to override the default preference set.
oneOf:
- nullable: true
x-struct: null
x-validate: null
- $ref: '#/components/schemas/PreferenceSetRequest'
x-struct: null
x-validate: null
type: object
x-struct: null
x-validate: null
required:
- id
title: TenantRequest
type: object
x-struct: Elixir.SwitchboardWeb.V1.Specs.TenantRequest
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
InlineTenantRequest:
description: An request to set a tenant inline.
example:
id: tenant_1
name: Acme Corp, Inc.
oneOf:
- description: The unique identifier for the tenant.
type: string
x-struct: null
x-validate: null
- $ref: '#/components/schemas/TenantRequest'
title: InlineTenantRequest
x-struct: Elixir.SwitchboardWeb.V1.Specs.InlineTenantRequest
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
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
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
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
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/PreferenceSetChannelType
# --- truncated at 32 KB (78 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/knock/refs/heads/main/openapi/knock-bulk-operations-api-openapi.yml