Skip to main content
PUT
/
:projectId
/
api
/
v7
/
push-notifications
/
preferences
Update Notification Preferences
curl --request PUT \
  --url https://api.sublay.io/api/v6/:projectId/api/v7/push-notifications/preferences \
  --header 'Content-Type: application/json' \
  --data '
{
  "disabledTypes": [
    "<string>"
  ],
  "userId": "<string>"
}
'
import requests

url = "https://api.sublay.io/api/v6/:projectId/api/v7/push-notifications/preferences"

payload = {
    "disabledTypes": ["<string>"],
    "userId": "<string>"
}
headers = {"Content-Type": "application/json"}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'PUT',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({disabledTypes: ['<string>'], userId: '<string>'})
};

fetch('https://api.sublay.io/api/v6/:projectId/api/v7/push-notifications/preferences', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.sublay.io/api/v6/:projectId/api/v7/push-notifications/preferences",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => json_encode([
    'disabledTypes' => [
        '<string>'
    ],
    'userId' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.sublay.io/api/v6/:projectId/api/v7/push-notifications/preferences"

	payload := strings.NewReader("{\n  \"disabledTypes\": [\n    \"<string>\"\n  ],\n  \"userId\": \"<string>\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.put("https://api.sublay.io/api/v6/:projectId/api/v7/push-notifications/preferences")
  .header("Content-Type", "application/json")
  .body("{\n  \"disabledTypes\": [\n    \"<string>\"\n  ],\n  \"userId\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.sublay.io/api/v6/:projectId/api/v7/push-notifications/preferences")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"disabledTypes\": [\n    \"<string>\"\n  ],\n  \"userId\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
Upserts the acting user’s push notification preferences. The request replaces the whole disabled-types set — send the complete set you want stored, not a delta. Duplicates are collapsed; only valid event type names are accepted. Requires authentication. Acting-user-scoped: an end-user token (Authorization: Bearer <accessToken>) writes its own preferences. A service/master key acts on behalf of a named user via the optional body userId — a service key without userId is rejected, and an end-user token may not name a different user. Requires the push bundle.

Body Parameters

disabledTypes
string[]
required
The complete set of event types to disable for push. Each value must be one of the server’s exact event type names (see the event palette) — unknown names are rejected. Pass [] to re-enable everything (all-on).
userId
string
The acting user whose preferences are written. Service/master keys only — a service key must pass it; an end-user token infers it from the auth token and may not name a different user.

Response

Returns 200 with the stored set (deduplicated).
{ "disabledTypes": ["comment-mention"] }

Error Responses

{ "error": "Unauthorized", "code": "notification-preferences/unauthorized" }
403 notification-preferences/unauthorized when an end-user token names a userId other than its own. A 401 is returned when no valid credential is present.
{ "error": "Missing user ID", "code": "notification-preferences/missing-user-id" }
Returned when a service/master key omits the required userId (it has no implicit session user).
{ "error": "...", "code": "notification-preferences/invalid-body" }
Returned when disabledTypes contains a value that is not a recognized event type name.
{ "error": "...", "code": "database/tables-not-available" }
Returned when the push bundle is not installed for this project.

See Also