0

Update Account

by
Published today

Updates attributes of an existing account.

Script outreach Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 5 hours ago
1
//native
2

3
/**
4
 * Update Account
5
 * Updates attributes of an existing account (e.g. { "industry": "Manufacturing" }).
6
 */
7
export async function main(
8
  auth: RT.Outreach,
9
  account_id: number,
10
  attributes: { [key: string]: any }
11
) {
12
  const response = await fetch(
13
    `https://api.outreach.io/api/v2/accounts/${account_id}`,
14
    {
15
      method: "PATCH",
16
      headers: {
17
        Authorization: `Bearer ${auth.token}`,
18
        "Content-Type": "application/vnd.api+json",
19
        Accept: "application/vnd.api+json",
20
      },
21
      body: JSON.stringify({
22
        data: { type: "account", id: account_id, attributes },
23
      }),
24
    }
25
  )
26

27
  if (!response.ok) {
28
    throw new Error(`${response.status} ${await response.text()}`)
29
  }
30

31
  return await response.json()
32
}
33