Update Identity

This endpoint allows you to: * Set the specified identity as verified (but you cannot unverify a verified identity) * Update the `value` property of the specified identity You can't change an identity's `primary` attribute with this endpoint. You must use the [Make Identity Primary](#make-identity-primary) endpoint instead. #### Allowed For * Agents

Script zendesk Verified

by hugo697 ยท 11/7/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 377 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * Update Identity
8
 * This endpoint allows you to:
9

10
* Set the specified identity as verified (but you cannot unverify a verified identity)
11
* Update the `value` property of the specified identity
12

13
You can't change an identity's `primary` attribute with this endpoint. You must use the [Make Identity Primary](#make-identity-primary) endpoint instead.
14

15
#### Allowed For
16

17
* Agents
18

19
 */
20
export async function main(
21
  auth: Zendesk,
22
  user_id: string,
23
  user_identity_id: string
24
) {
25
  const url = new URL(
26
    `https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}/identities/${user_identity_id}`
27
  );
28

29
  const response = await fetch(url, {
30
    method: "PUT",
31
    headers: {
32
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
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