Updates an app

Updates 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 an app
7
 * Updates the application with the specified application ID.
8
 */
9
export async function main(
10
  auth: Ably,
11
  id: string,
12
  body: {
13
    name?: string;
14
    status?: string;
15
    tlsOnly?: false | true;
16
    fcmKey?: string;
17
    fcmServiceAccount?: string;
18
    fcmProjectId?: string;
19
    apnsCertificate?: string;
20
    apnsPrivateKey?: string;
21
    apnsUseSandboxEndpoint?: false | true;
22
  },
23
) {
24
  const url = new URL(`https://control.ably.net/v1/apps/${id}`);
25

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