0

List audit logs

by
Published Oct 17, 2025

### Authorization A service token must have at least one of the following access in order to use this API endpoint: **Service Token Accesses** `read_audit_logs`

Script planetscale Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Planetscale = {
3
  serviceTokenId: string;
4
  serviceToken: string;
5
};
6
/**
7
 * List audit logs
8
 * 
9
### Authorization
10
A service token   must have at least one of the following access   in order to use this API endpoint:
11

12
**Service Token Accesses**
13
 `read_audit_logs`
14

15

16
 */
17
export async function main(auth: Planetscale, name: string) {
18
  const url = new URL(
19
    `https://api.planetscale.com/v1/organizations/${name}/audit-log`,
20
  );
21

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