0

Redact a Report

by
Published Apr 8, 2025

Permanently deletes personally identifiable information (PII) for a Report. This endpoint can be used to comply with privacy regulations such as GDPR / CCPA or to enforce data privacy. Note that this will only delete the report -- it does not delete associated accounts, inquiries, verifications, or other Persona resources.

Script persona Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Persona = {
3
  apiKey: string;
4
};
5
/**
6
 * Redact a Report
7
 * Permanently deletes personally identifiable information (PII) for a Report.
8

9
This endpoint can be used to comply with privacy regulations such as GDPR / CCPA or to enforce data privacy.
10

11
Note that this will only delete the report -- it does not delete associated accounts, inquiries, verifications, or other Persona resources.
12
 */
13
export async function main(
14
  auth: Persona,
15
  report_id: string,
16
  include: string | undefined,
17
  fields: string | undefined,
18
  Key_Inflection?: string,
19
  Idempotency_Key?: string,
20
  Persona_Version?: string,
21
) {
22
  const url = new URL(
23
    `https://api.withpersona.com/api/v1/reports/${report_id}`,
24
  );
25
  for (const [k, v] of [
26
    ["include", include],
27
    ["fields", fields],
28
  ]) {
29
    if (v !== undefined && v !== "" && k !== undefined) {
30
      url.searchParams.append(k, v);
31
    }
32
  }
33
  const headers: Record<string, string> = {
34
    Authorization: `Bearer ${auth.apiKey}`,
35
  };
36
  if (Key_Inflection) {
37
    headers["Key-Inflection"] = Key_Inflection;
38
  }
39
  if (Idempotency_Key) {
40
    headers["Idempotency-Key"] = Idempotency_Key;
41
  }
42
  if (Persona_Version) {
43
    headers["Persona-Version"] = Persona_Version;
44
  }
45
  const response = await fetch(url, {
46
    method: "DELETE",
47
    headers,
48
    body: undefined,
49
  });
50
  if (!response.ok) {
51
    const text = await response.text();
52
    throw new Error(`${response.status} ${text}`);
53
  }
54
  return await response.json();
55
}
56