0

Redact an Inquiry

by
Published Apr 8, 2025

Permanently deletes personally identifiable information (PII) for an Inquiry and all associated Verifications, Reports, 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 an Inquiry
7
 * Permanently deletes personally identifiable information (PII) for an Inquiry and all associated Verifications, Reports, or other Persona resources.
8
 */
9
export async function main(
10
  auth: Persona,
11
  inquiry_id: string,
12
  include: string | undefined,
13
  fields: string | undefined,
14
  Key_Inflection?: string,
15
  Idempotency_Key?: string,
16
  Persona_Version?: string,
17
) {
18
  const url = new URL(
19
    `https://api.withpersona.com/api/v1/inquiries/${inquiry_id}`,
20
  );
21
  for (const [k, v] of [
22
    ["include", include],
23
    ["fields", fields],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const headers: Record<string, string> = {
30
    Authorization: `Bearer ${auth.apiKey}`,
31
  };
32
  if (Key_Inflection) {
33
    headers["Key-Inflection"] = Key_Inflection;
34
  }
35
  if (Idempotency_Key) {
36
    headers["Idempotency-Key"] = Idempotency_Key;
37
  }
38
  if (Persona_Version) {
39
    headers["Persona-Version"] = Persona_Version;
40
  }
41
  const response = await fetch(url, {
42
    method: "DELETE",
43
    headers,
44
    body: undefined,
45
  });
46
  if (!response.ok) {
47
    const text = await response.text();
48
    throw new Error(`${response.status} ${text}`);
49
  }
50
  return await response.json();
51
}
52