//native
type Attio = {
token: string;
};
/**
* Create a note
* Creates a new note for a given record.
At present, notes can only be created from plaintext without formatting.
Required scopes: `note:read-write`, `object_configuration:read`, `record_permission:read`.
*/
export async function main(
auth: Attio,
body: {
data: {
parent_object: string;
parent_record_id: string;
title: string;
format: "plaintext";
content: string;
created_at?: string;
};
},
) {
const url = new URL(`https://api.attio.com/v2/notes`);
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 235 days ago