//native
type Attio = {
token: string;
};
/**
* Create a record
* 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`.
*/
export async function main(
auth: Attio,
object: string,
body: { data: { values: {} } },
) {
const url = new URL(`https://api.attio.com/v2/objects/${object}/records`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 51 days ago