Skip to main content
DELETE
/
v2
/
topics
/
{topicKey}
/
subscriptions
PHP
declare(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
}
{
  "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": "john@example.com"
      },
      "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"
    }
  ]
}

Authorizations

Authorization
string
header
required

API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".

Headers

idempotency-key
string

A header for idempotency purposes

Path Parameters

topicKey
string
required

The key identifier of the topic

Body

application/json
subscriberIds
string[]
deprecated

List of subscriber identifiers to unsubscribe from the topic (max: 100). @deprecated Use the "subscriptions" property instead.

Example:
["subscriberId1", "subscriberId2"]
subscriptions
(string | object)[]

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"
}
]

Response

Subscriptions deleted successfully

data
object[]
required

The list of successfully deleted subscriptions

meta
object
required

Metadata about the operation

errors
object[]

The list of errors for failed deletion attempts