export type AuditLogsExportRequest = {workspaceId?: (string | null) | undefined, organizationId?: (string | null) | undefined, startDate?: (number | null) | undefined, endDate?: (number | null) | undefined, actions?: (Array | null) | undefined, actorIds?: (Array | null) | undefined, targetId?: (string | null) | undefined}; export type CreateApiV2AuditLogsExportArgs = {body: AuditLogsExportRequest}; export type CreateApiV2AuditLogsExportOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export audit log events as CSV * * POST /v2/auditLogs/export */ export const createApiV2AuditLogsExport = async (args: CreateApiV2AuditLogsExportArgs, options?: CreateApiV2AuditLogsExportOptions) => { const {baseUrl = "https://api.synthesia.io", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/csv") if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/auditLogs/export${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };