Subscriptions
Delete topic subscriptions
Delete subscriptions for subscriberIds for a topic.
DELETE
/
v2
/
topics
/
{topicKey}
/
subscriptions
TypeScript
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.topics.subscriptions.delete({
subscriptions: [
{
identifier: "subscriber-123-subscription-a",
subscriberId: "subscriber-123",
},
{
subscriberId: "subscriber-456",
},
{
identifier: "subscriber-789-subscription-b",
},
],
}, "<value>");
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Topics.Subscriptions.DeleteAsync(
topicKey: "<value>",
deleteTopicSubscriptionsRequestDto: new DeleteTopicSubscriptionsRequestDto() {
Subscriptions = new List<DeleteTopicSubscriptionsRequestDtoSubscriptions>() {
DeleteTopicSubscriptionsRequestDtoSubscriptions.CreateDeleteTopicSubscriberIdentifierDto(
new DeleteTopicSubscriberIdentifierDto() {
Identifier = "subscriber-123-subscription-a",
SubscriberId = "subscriber-123",
}
),
DeleteTopicSubscriptionsRequestDtoSubscriptions.CreateDeleteTopicSubscriberIdentifierDto(
new DeleteTopicSubscriberIdentifierDto() {
SubscriberId = "subscriber-456",
}
),
DeleteTopicSubscriptionsRequestDtoSubscriptions.CreateDeleteTopicSubscriberIdentifierDto(
new DeleteTopicSubscriberIdentifierDto() {
Identifier = "subscriber-789-subscription-b",
}
),
},
}
);
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$deleteTopicSubscriptionsRequestDto = new Components\DeleteTopicSubscriptionsRequestDto(
subscriptions: [
new Components\DeleteTopicSubscriberIdentifierDto(
identifier: 'subscriber-123-subscription-a',
subscriberId: 'subscriber-123',
),
new Components\DeleteTopicSubscriberIdentifierDto(
subscriberId: 'subscriber-456',
),
new Components\DeleteTopicSubscriberIdentifierDto(
identifier: 'subscriber-789-subscription-b',
),
],
);
$response = $sdk->topics->subscriptions->delete(
topicKey: '<value>',
deleteTopicSubscriptionsRequestDto: $deleteTopicSubscriptionsRequestDto
);
if ($response->deleteTopicSubscriptionsResponseDto !== null) {
// handle response
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.topics.subscriptions.delete(topic_key="<value>", delete_topic_subscriptions_request_dto={
"subscriptions": [
{
"identifier": "subscriber-123-subscription-a",
"subscriber_id": "subscriber-123",
},
{
"subscriber_id": "subscriber-456",
},
{
"identifier": "subscriber-789-subscription-b",
},
],
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Topics.Subscriptions.Delete(ctx, "<value>", components.DeleteTopicSubscriptionsRequestDto{
Subscriptions: []components.DeleteTopicSubscriptionsRequestDtoSubscriptions{
components.CreateDeleteTopicSubscriptionsRequestDtoSubscriptionsDeleteTopicSubscriberIdentifierDto(
components.DeleteTopicSubscriberIdentifierDto{
Identifier: v3.Pointer("subscriber-123-subscription-a"),
SubscriberID: v3.Pointer("subscriber-123"),
},
),
components.CreateDeleteTopicSubscriptionsRequestDtoSubscriptionsDeleteTopicSubscriberIdentifierDto(
components.DeleteTopicSubscriberIdentifierDto{
SubscriberID: v3.Pointer("subscriber-456"),
},
),
components.CreateDeleteTopicSubscriptionsRequestDtoSubscriptionsDeleteTopicSubscriberIdentifierDto(
components.DeleteTopicSubscriberIdentifierDto{
Identifier: v3.Pointer("subscriber-789-subscription-b"),
},
),
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.DeleteTopicSubscriptionsResponseDto != nil {
// handle response
}
}curl --request DELETE \
--url https://api.novu.co/v2/topics/{topicKey}/subscriptions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"subscriberIds": [
"subscriberId1",
"subscriberId2"
],
"subscriptions": [
{
"identifier": "subscriber-123-subscription-a",
"subscriberId": "subscriber-123"
},
{
"subscriberId": "subscriber-456"
},
{
"identifier": "subscriber-789-subscription-b"
}
]
}
'const options = {
method: 'DELETE',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscriberIds: ['subscriberId1', 'subscriberId2'],
subscriptions: [
{identifier: 'subscriber-123-subscription-a', subscriberId: 'subscriber-123'},
{subscriberId: 'subscriber-456'},
{identifier: 'subscriber-789-subscription-b'}
]
})
};
fetch('https://api.novu.co/v2/topics/{topicKey}/subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.delete("https://api.novu.co/v2/topics/{topicKey}/subscriptions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscriberIds\": [\n \"subscriberId1\",\n \"subscriberId2\"\n ],\n \"subscriptions\": [\n {\n \"identifier\": \"subscriber-123-subscription-a\",\n \"subscriberId\": \"subscriber-123\"\n },\n {\n \"subscriberId\": \"subscriber-456\"\n },\n {\n \"identifier\": \"subscriber-789-subscription-b\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/topics/{topicKey}/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscriberIds\": [\n \"subscriberId1\",\n \"subscriberId2\"\n ],\n \"subscriptions\": [\n {\n \"identifier\": \"subscriber-123-subscription-a\",\n \"subscriberId\": \"subscriber-123\"\n },\n {\n \"subscriberId\": \"subscriber-456\"\n },\n {\n \"identifier\": \"subscriber-789-subscription-b\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"_id": "64f5e95d3d7946d80d0cb679",
"topic": {
"_id": "64f5e95d3d7946d80d0cb677",
"key": "product-updates",
"name": "Product Updates"
},
"subscriber": {
"_id": "64da692e9a94fb2e6449ad07",
"subscriberId": "user-123",
"avatar": "https://example.com/avatar.png",
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]"
},
"createdAt": "2025-04-24T05:40:21Z",
"updatedAt": "2025-04-24T05:40:21Z",
"identifier": "tk=product-updates:si=subscriber-123",
"contextKeys": [
"tenant:org-a",
"project:proj-123"
]
}
],
"meta": {
"totalCount": 3,
"successful": 2,
"failed": 1
},
"errors": [
{
"subscriberId": "invalid-subscriber-id",
"code": "SUBSCRIBER_NOT_FOUND",
"message": "Subscriber with ID invalid-subscriber-id could not be found"
}
]
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"errors": {
"fieldName1": {
"messages": [
"Field is required",
"Must be a valid email address"
],
"value": "invalidEmail"
},
"fieldName2": {
"messages": [
"Must be at least 18 years old"
],
"value": 17
},
"fieldName3": {
"messages": [
"Must be a boolean value"
],
"value": true
},
"fieldName4": {
"messages": [
"Must be a valid object"
],
"value": {
"key": "value"
}
},
"fieldName5": {
"messages": [
"Field is missing"
],
"value": null
},
"fieldName6": {
"messages": [
"Undefined value"
]
}
},
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"API rate limit exceeded"{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"Please wait some time, then try again."Authorizations
API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".
Headers
A header for idempotency purposes
Path Parameters
The key identifier of the topic
Body
application/json
List of subscriber identifiers to unsubscribe from the topic (max: 100). @deprecated Use the "subscriptions" property instead.
Example:
["subscriberId1", "subscriberId2"]
List of subscriptions to unsubscribe from the topic (max: 100). Can be either a string array of subscriber IDs or an array of objects with identifier and/or subscriberId. If only subscriberId is provided, all subscriptions for that subscriber within the topic will be deleted.
Example:
[
{
"identifier": "subscriber-123-subscription-a",
"subscriberId": "subscriber-123"
},
{ "subscriberId": "subscriber-456" },
{
"identifier": "subscriber-789-subscription-b"
}
]
Was this page helpful?
⌘I
TypeScript
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.topics.subscriptions.delete({
subscriptions: [
{
identifier: "subscriber-123-subscription-a",
subscriberId: "subscriber-123",
},
{
subscriberId: "subscriber-456",
},
{
identifier: "subscriber-789-subscription-b",
},
],
}, "<value>");
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Topics.Subscriptions.DeleteAsync(
topicKey: "<value>",
deleteTopicSubscriptionsRequestDto: new DeleteTopicSubscriptionsRequestDto() {
Subscriptions = new List<DeleteTopicSubscriptionsRequestDtoSubscriptions>() {
DeleteTopicSubscriptionsRequestDtoSubscriptions.CreateDeleteTopicSubscriberIdentifierDto(
new DeleteTopicSubscriberIdentifierDto() {
Identifier = "subscriber-123-subscription-a",
SubscriberId = "subscriber-123",
}
),
DeleteTopicSubscriptionsRequestDtoSubscriptions.CreateDeleteTopicSubscriberIdentifierDto(
new DeleteTopicSubscriberIdentifierDto() {
SubscriberId = "subscriber-456",
}
),
DeleteTopicSubscriptionsRequestDtoSubscriptions.CreateDeleteTopicSubscriberIdentifierDto(
new DeleteTopicSubscriberIdentifierDto() {
Identifier = "subscriber-789-subscription-b",
}
),
},
}
);
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$deleteTopicSubscriptionsRequestDto = new Components\DeleteTopicSubscriptionsRequestDto(
subscriptions: [
new Components\DeleteTopicSubscriberIdentifierDto(
identifier: 'subscriber-123-subscription-a',
subscriberId: 'subscriber-123',
),
new Components\DeleteTopicSubscriberIdentifierDto(
subscriberId: 'subscriber-456',
),
new Components\DeleteTopicSubscriberIdentifierDto(
identifier: 'subscriber-789-subscription-b',
),
],
);
$response = $sdk->topics->subscriptions->delete(
topicKey: '<value>',
deleteTopicSubscriptionsRequestDto: $deleteTopicSubscriptionsRequestDto
);
if ($response->deleteTopicSubscriptionsResponseDto !== null) {
// handle response
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.topics.subscriptions.delete(topic_key="<value>", delete_topic_subscriptions_request_dto={
"subscriptions": [
{
"identifier": "subscriber-123-subscription-a",
"subscriber_id": "subscriber-123",
},
{
"subscriber_id": "subscriber-456",
},
{
"identifier": "subscriber-789-subscription-b",
},
],
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Topics.Subscriptions.Delete(ctx, "<value>", components.DeleteTopicSubscriptionsRequestDto{
Subscriptions: []components.DeleteTopicSubscriptionsRequestDtoSubscriptions{
components.CreateDeleteTopicSubscriptionsRequestDtoSubscriptionsDeleteTopicSubscriberIdentifierDto(
components.DeleteTopicSubscriberIdentifierDto{
Identifier: v3.Pointer("subscriber-123-subscription-a"),
SubscriberID: v3.Pointer("subscriber-123"),
},
),
components.CreateDeleteTopicSubscriptionsRequestDtoSubscriptionsDeleteTopicSubscriberIdentifierDto(
components.DeleteTopicSubscriberIdentifierDto{
SubscriberID: v3.Pointer("subscriber-456"),
},
),
components.CreateDeleteTopicSubscriptionsRequestDtoSubscriptionsDeleteTopicSubscriberIdentifierDto(
components.DeleteTopicSubscriberIdentifierDto{
Identifier: v3.Pointer("subscriber-789-subscription-b"),
},
),
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.DeleteTopicSubscriptionsResponseDto != nil {
// handle response
}
}curl --request DELETE \
--url https://api.novu.co/v2/topics/{topicKey}/subscriptions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"subscriberIds": [
"subscriberId1",
"subscriberId2"
],
"subscriptions": [
{
"identifier": "subscriber-123-subscription-a",
"subscriberId": "subscriber-123"
},
{
"subscriberId": "subscriber-456"
},
{
"identifier": "subscriber-789-subscription-b"
}
]
}
'const options = {
method: 'DELETE',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
subscriberIds: ['subscriberId1', 'subscriberId2'],
subscriptions: [
{identifier: 'subscriber-123-subscription-a', subscriberId: 'subscriber-123'},
{subscriberId: 'subscriber-456'},
{identifier: 'subscriber-789-subscription-b'}
]
})
};
fetch('https://api.novu.co/v2/topics/{topicKey}/subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.delete("https://api.novu.co/v2/topics/{topicKey}/subscriptions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"subscriberIds\": [\n \"subscriberId1\",\n \"subscriberId2\"\n ],\n \"subscriptions\": [\n {\n \"identifier\": \"subscriber-123-subscription-a\",\n \"subscriberId\": \"subscriber-123\"\n },\n {\n \"subscriberId\": \"subscriber-456\"\n },\n {\n \"identifier\": \"subscriber-789-subscription-b\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/topics/{topicKey}/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"subscriberIds\": [\n \"subscriberId1\",\n \"subscriberId2\"\n ],\n \"subscriptions\": [\n {\n \"identifier\": \"subscriber-123-subscription-a\",\n \"subscriberId\": \"subscriber-123\"\n },\n {\n \"subscriberId\": \"subscriber-456\"\n },\n {\n \"identifier\": \"subscriber-789-subscription-b\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"_id": "64f5e95d3d7946d80d0cb679",
"topic": {
"_id": "64f5e95d3d7946d80d0cb677",
"key": "product-updates",
"name": "Product Updates"
},
"subscriber": {
"_id": "64da692e9a94fb2e6449ad07",
"subscriberId": "user-123",
"avatar": "https://example.com/avatar.png",
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]"
},
"createdAt": "2025-04-24T05:40:21Z",
"updatedAt": "2025-04-24T05:40:21Z",
"identifier": "tk=product-updates:si=subscriber-123",
"contextKeys": [
"tenant:org-a",
"project:proj-123"
]
}
],
"meta": {
"totalCount": 3,
"successful": 2,
"failed": 1
},
"errors": [
{
"subscriberId": "invalid-subscriber-id",
"code": "SUBSCRIBER_NOT_FOUND",
"message": "Subscriber with ID invalid-subscriber-id could not be found"
}
]
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"errors": {
"fieldName1": {
"messages": [
"Field is required",
"Must be a valid email address"
],
"value": "invalidEmail"
},
"fieldName2": {
"messages": [
"Must be at least 18 years old"
],
"value": 17
},
"fieldName3": {
"messages": [
"Must be a boolean value"
],
"value": true
},
"fieldName4": {
"messages": [
"Must be a valid object"
],
"value": {
"key": "value"
}
},
"fieldName5": {
"messages": [
"Field is missing"
],
"value": null
},
"fieldName6": {
"messages": [
"Undefined value"
]
}
},
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"API rate limit exceeded"{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"Please wait some time, then try again."