Update a subscriber
Update a subscriber by its unique key identifier subscriberId. subscriberId is a required field, rest other fields are optional
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.subscribers.patch({
firstName: "John",
lastName: "Doe",
email: "[email protected]",
phone: "+1234567890",
avatar: "https://example.com/avatar.jpg",
locale: "en-US",
timezone: "America/New_York",
}, "<id>");
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Subscribers.PatchAsync(
subscriberId: "<id>",
patchSubscriberRequestDto: new PatchSubscriberRequestDto() {
FirstName = "John",
LastName = "Doe",
Email = "[email protected]",
Phone = "+1234567890",
Avatar = "https://example.com/avatar.jpg",
Locale = "en-US",
Timezone = "America/New_York",
}
);
// 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();
$patchSubscriberRequestDto = new Components\PatchSubscriberRequestDto(
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phone: '+1234567890',
avatar: 'https://example.com/avatar.jpg',
locale: 'en-US',
timezone: 'America/New_York',
);
$response = $sdk->subscribers->patch(
subscriberId: '<id>',
patchSubscriberRequestDto: $patchSubscriberRequestDto
);
if ($response->subscriberResponseDto !== null) {
// handle response
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.subscribers.patch(subscriber_id="<id>", patch_subscriber_request_dto={
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"phone": "+1234567890",
"avatar": "https://example.com/avatar.jpg",
"locale": "en-US",
"timezone": "America/New_York",
})
# 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.Subscribers.Patch(ctx, "<id>", components.PatchSubscriberRequestDto{
FirstName: v3.Pointer("John"),
LastName: v3.Pointer("Doe"),
Email: v3.Pointer("[email protected]"),
Phone: v3.Pointer("+1234567890"),
Avatar: v3.Pointer("https://example.com/avatar.jpg"),
Locale: v3.Pointer("en-US"),
Timezone: v3.Pointer("America/New_York"),
}, nil)
if err != nil {
log.Fatal(err)
}
if res.SubscriberResponseDto != nil {
// handle response
}
}curl --request PATCH \
--url https://api.novu.co/v2/subscribers/{subscriberId} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"phone": "+1234567890",
"avatar": "https://example.com/avatar.jpg",
"locale": "en-US",
"timezone": "America/New_York",
"data": {}
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phone: '+1234567890',
avatar: 'https://example.com/avatar.jpg',
locale: 'en-US',
timezone: 'America/New_York',
data: {}
})
};
fetch('https://api.novu.co/v2/subscribers/{subscriberId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.novu.co/v2/subscribers/{subscriberId}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"email\": \"[email protected]\",\n \"phone\": \"+1234567890\",\n \"avatar\": \"https://example.com/avatar.jpg\",\n \"locale\": \"en-US\",\n \"timezone\": \"America/New_York\",\n \"data\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/subscribers/{subscriberId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"email\": \"[email protected]\",\n \"phone\": \"+1234567890\",\n \"avatar\": \"https://example.com/avatar.jpg\",\n \"locale\": \"en-US\",\n \"timezone\": \"America/New_York\",\n \"data\": {}\n}"
response = http.request(request)
puts response.read_body{
"subscriberId": "<string>",
"_organizationId": "<string>",
"_environmentId": "<string>",
"deleted": true,
"createdAt": "<string>",
"updatedAt": "<string>",
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>",
"phone": "<string>",
"avatar": "<string>",
"locale": "<string>",
"channels": [
{
"credentials": {
"webhookUrl": "https://example.com/webhook",
"channel": "general",
"deviceTokens": [
"token1",
"token2",
"token3"
],
"alertUid": "12345-abcde",
"title": "Critical Alert",
"imageUrl": "https://example.com/image.png",
"state": "resolved",
"externalUrl": "https://example.com/details"
},
"_integrationId": "<string>",
"integrationIdentifier": "<string>"
}
],
"topics": [
"<string>"
],
"isOnline": true,
"lastOnlineAt": "<string>",
"__v": 123,
"data": {},
"timezone": "<string>"
}{
"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 identifier of the subscriber
Body
First name of the subscriber
"John"
Last name of the subscriber
"Doe"
Email address of the subscriber
Phone number of the subscriber
"+1234567890"
Avatar URL or identifier
"https://example.com/avatar.jpg"
Locale of the subscriber
"en-US"
Timezone of the subscriber
"America/New_York"
Additional custom data associated with the subscriber
Response
OK
The identifier used to create this subscriber, which typically corresponds to the user ID in your system.
The unique identifier of the organization to which the subscriber belongs.
The unique identifier of the environment associated with this subscriber.
Indicates whether the subscriber has been deleted.
The timestamp indicating when the subscriber was created, in ISO 8601 format.
The timestamp indicating when the subscriber was last updated, in ISO 8601 format.
The internal ID generated by Novu for your subscriber. This ID does not match the subscriberId used in your queries. Refer to subscriberId for that identifier.
The first name of the subscriber.
The last name of the subscriber.
The email address of the subscriber.
The phone number of the subscriber.
The URL of the subscriber's avatar image.
The locale setting of the subscriber, indicating their preferred language or region.
An array of channel settings associated with the subscriber.
Show child attributes
Show child attributes
An array of topics that the subscriber is subscribed to.
Indicates whether the subscriber is currently online.
The timestamp indicating when the subscriber was last online, in ISO 8601 format.
The version of the subscriber document.
Additional custom data for the subscriber
Timezone of the subscriber
Was this page helpful?
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.subscribers.patch({
firstName: "John",
lastName: "Doe",
email: "[email protected]",
phone: "+1234567890",
avatar: "https://example.com/avatar.jpg",
locale: "en-US",
timezone: "America/New_York",
}, "<id>");
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.Subscribers.PatchAsync(
subscriberId: "<id>",
patchSubscriberRequestDto: new PatchSubscriberRequestDto() {
FirstName = "John",
LastName = "Doe",
Email = "[email protected]",
Phone = "+1234567890",
Avatar = "https://example.com/avatar.jpg",
Locale = "en-US",
Timezone = "America/New_York",
}
);
// 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();
$patchSubscriberRequestDto = new Components\PatchSubscriberRequestDto(
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phone: '+1234567890',
avatar: 'https://example.com/avatar.jpg',
locale: 'en-US',
timezone: 'America/New_York',
);
$response = $sdk->subscribers->patch(
subscriberId: '<id>',
patchSubscriberRequestDto: $patchSubscriberRequestDto
);
if ($response->subscriberResponseDto !== null) {
// handle response
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.subscribers.patch(subscriber_id="<id>", patch_subscriber_request_dto={
"first_name": "John",
"last_name": "Doe",
"email": "[email protected]",
"phone": "+1234567890",
"avatar": "https://example.com/avatar.jpg",
"locale": "en-US",
"timezone": "America/New_York",
})
# 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.Subscribers.Patch(ctx, "<id>", components.PatchSubscriberRequestDto{
FirstName: v3.Pointer("John"),
LastName: v3.Pointer("Doe"),
Email: v3.Pointer("[email protected]"),
Phone: v3.Pointer("+1234567890"),
Avatar: v3.Pointer("https://example.com/avatar.jpg"),
Locale: v3.Pointer("en-US"),
Timezone: v3.Pointer("America/New_York"),
}, nil)
if err != nil {
log.Fatal(err)
}
if res.SubscriberResponseDto != nil {
// handle response
}
}curl --request PATCH \
--url https://api.novu.co/v2/subscribers/{subscriberId} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"phone": "+1234567890",
"avatar": "https://example.com/avatar.jpg",
"locale": "en-US",
"timezone": "America/New_York",
"data": {}
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
phone: '+1234567890',
avatar: 'https://example.com/avatar.jpg',
locale: 'en-US',
timezone: 'America/New_York',
data: {}
})
};
fetch('https://api.novu.co/v2/subscribers/{subscriberId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.novu.co/v2/subscribers/{subscriberId}")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"email\": \"[email protected]\",\n \"phone\": \"+1234567890\",\n \"avatar\": \"https://example.com/avatar.jpg\",\n \"locale\": \"en-US\",\n \"timezone\": \"America/New_York\",\n \"data\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/subscribers/{subscriberId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"email\": \"[email protected]\",\n \"phone\": \"+1234567890\",\n \"avatar\": \"https://example.com/avatar.jpg\",\n \"locale\": \"en-US\",\n \"timezone\": \"America/New_York\",\n \"data\": {}\n}"
response = http.request(request)
puts response.read_body{
"subscriberId": "<string>",
"_organizationId": "<string>",
"_environmentId": "<string>",
"deleted": true,
"createdAt": "<string>",
"updatedAt": "<string>",
"_id": "<string>",
"firstName": "<string>",
"lastName": "<string>",
"email": "<string>",
"phone": "<string>",
"avatar": "<string>",
"locale": "<string>",
"channels": [
{
"credentials": {
"webhookUrl": "https://example.com/webhook",
"channel": "general",
"deviceTokens": [
"token1",
"token2",
"token3"
],
"alertUid": "12345-abcde",
"title": "Critical Alert",
"imageUrl": "https://example.com/image.png",
"state": "resolved",
"externalUrl": "https://example.com/details"
},
"_integrationId": "<string>",
"integrationIdentifier": "<string>"
}
],
"topics": [
"<string>"
],
"isOnline": true,
"lastOnlineAt": "<string>",
"__v": 123,
"data": {},
"timezone": "<string>"
}{
"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."