Updates a namespace

Updates the namespace with the specified ID, for the application with the specified application ID.

Script ably Verified

by hugo697 ยท 10/17/2025

The script

Submitted by hugo697 Bun
Verified 220 days ago
1
//native
2
type Ably = {
3
  accessToken: string;
4
};
5
/**
6
 * Updates a namespace
7
 * Updates the namespace with the specified ID, for the application with the specified application ID.
8
 */
9
export async function main(
10
  auth: Ably,
11
  app_id: string,
12
  namespace_id: string,
13
  body: {
14
    authenticated?: false | true;
15
    persisted?: false | true;
16
    persistLast?: false | true;
17
    pushEnabled?: false | true;
18
    batchingEnabled?: false | true;
19
    batchingPolicy?: string;
20
    batchingInterval?: number;
21
    tlsOnly?: false | true;
22
    exposeTimeserial?: false | true;
23
  },
24
) {
25
  const url = new URL(
26
    `https://control.ably.net/v1/apps/${app_id}/namespaces/${namespace_id}`,
27
  );
28

29
  const response = await fetch(url, {
30
    method: "PATCH",
31
    headers: {
32
      "Content-Type": "application/json",
33
      Authorization: "Bearer " + auth.accessToken,
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43