//native
type Attio = {
token: string;
};
/**
* Create an entry (add record to list)
* Adds a record to a list as a new list entry. This endpoint will throw on conflicts of unique attributes. Multiple list entries are allowed for the same parent record
Required scopes: `list_entry:read-write`, `list_configuration:read`.
*/
export async function main(
auth: Attio,
list: string,
body: {
data: { parent_record_id: string; parent_object: string; entry_values: {} };
},
) {
const url = new URL(`https://api.attio.com/v2/lists/${list}/entries`);
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