0

Delete a connection from a cluster's private endpoint service.

by
Published Oct 17, 2025

Remove a private endpoint from a service's trusted endpoints list. Caller should make sure to URL encode the endpoint_id before calling this method. Can be used by the following roles assigned at the organization, folder or cluster scope: - CLUSTER_ADMIN - CLUSTER_OPERATOR_WRITER

Script cockroachdb Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Cockroachdb = {
3
  token: string;
4
};
5
/**
6
 * Delete a connection from a cluster's private endpoint service.
7
 * Remove a private endpoint from a service's trusted endpoints list. Caller should make sure to URL encode the endpoint_id before calling this method.
8

9
Can be used by the following roles assigned at the organization, folder or cluster scope:
10
- CLUSTER_ADMIN
11
- CLUSTER_OPERATOR_WRITER
12

13
 */
14
export async function main(
15
  auth: Cockroachdb,
16
  cluster_id: string,
17
  endpoint_id: string,
18
) {
19
  const url = new URL(
20
    `https://cockroachlabs.cloud/api/v1/clusters/${cluster_id}/networking/private-endpoint-connections/${endpoint_id}`,
21
  );
22

23
  const response = await fetch(url, {
24
    method: "DELETE",
25
    headers: {
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36