//native
type Attio = {
token: string;
};
/**
* Create a comment
* Creates a new comment related to an existing thread, record or entry.
To create comments on records, you will need the `object_configuration:read` and `record_permission:read` scopes.
To create comments on list entries, you will need the `list_configuration:read` and `list_entry:read` scopes.
Required scopes: `comment:read-write`.
*/
export async function main(
auth: Attio,
body: {
data:
| {
format: "plaintext";
content: string;
author: { type: "workspace-member"; id: string };
created_at?: string;
thread_id: string;
}
| {
format: "plaintext";
content: string;
author: { type: "workspace-member"; id: string };
created_at?: string;
record: { object: string; record_id: string };
}
| {
format: "plaintext";
content: string;
author: { type: "workspace-member"; id: string };
created_at?: string;
entry: { list: string; entry_id: string };
};
},
) {
const url = new URL(`https://api.attio.com/v2/comments`);
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