0

Create Account

by
Published today

Creates a company account in Outreach.

Script outreach Verified

The script

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

3
/**
4
 * Create Account
5
 * Creates a company account in Outreach.
6
 */
7
export async function main(
8
  auth: RT.Outreach,
9
  name: string,
10
  domain: string | undefined,
11
  additional_attributes: { [key: string]: any } | undefined
12
) {
13
  const attributes: { [key: string]: any } = { ...additional_attributes, name }
14
  if (domain !== undefined && domain !== "") {
15
    attributes.domain = domain
16
  }
17

18
  const response = await fetch("https://api.outreach.io/api/v2/accounts", {
19
    method: "POST",
20
    headers: {
21
      Authorization: `Bearer ${auth.token}`,
22
      "Content-Type": "application/vnd.api+json",
23
      Accept: "application/vnd.api+json",
24
    },
25
    body: JSON.stringify({ data: { type: "account", attributes } }),
26
  })
27

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

32
  return await response.json()
33
}
34