0

Create a record

by
Published Oct 17, 2025

Creates a new person, company or other record. This endpoint will throw on conflicts of unique attributes. If you would prefer to update records on conflicts, please use the Assert record endpoint instead. Required scopes: `record_permission:read-write`, `object_configuration:read`.

Script attio Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Attio = {
3
  token: string;
4
};
5
/**
6
 * Create a record
7
 * Creates a new person, company or other record. This endpoint will throw on conflicts of unique attributes. If you would prefer to update records on conflicts, please use the Assert record endpoint instead.
8

9
Required scopes: `record_permission:read-write`, `object_configuration:read`.
10
 */
11
export async function main(
12
  auth: Attio,
13
  object: string,
14
  body: { data: { values: {} } },
15
) {
16
  const url = new URL(`https://api.attio.com/v2/objects/${object}/records`);
17

18
  const response = await fetch(url, {
19
    method: "POST",
20
    headers: {
21
      "Content-Type": "application/json",
22
      Authorization: "Bearer " + auth.token,
23
    },
24
    body: JSON.stringify(body),
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.json();
31
}
32