0

Get audit logs

by
Published Oct 17, 2025

Retrieves a page of audit events from the last 90 days. If you want to retrieve data that is older than 90 days, you can use the CSV export feature.Required scope auditlogs:read Rate limiting Level 2

Script miro Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Miro = {
3
  token: string;
4
};
5
/**
6
 * Get audit logs
7
 * Retrieves a page of audit events from the last 90 days. If you want to retrieve data that is older than 90 days, you can use the CSV export feature.Required scope auditlogs:read Rate limiting Level 2
8
 */
9
export async function main(
10
  auth: Miro,
11
  createdAfter: string | undefined,
12
  createdBefore: string | undefined,
13
  cursor: string | undefined,
14
  limit: string | undefined,
15
  sorting: "ASC" | "DESC" | undefined,
16
) {
17
  const url = new URL(`https://api.miro.com//v2/audit/logs`);
18
  for (const [k, v] of [
19
    ["createdAfter", createdAfter],
20
    ["createdBefore", createdBefore],
21
    ["cursor", cursor],
22
    ["limit", limit],
23
    ["sorting", sorting],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42