//native
type Attio = {
token: string;
};
/**
* Create a status
* Add a new status to a status attribute on either an object or a list.
Required scopes: `object_configuration:read-write`.
*/
export async function main(
auth: Attio,
target: "lists" | "objects",
identifier: string,
attribute: string,
body: {
data: {
title: string;
celebration_enabled?: false | true;
target_time_in_status?: string;
};
},
) {
const url = new URL(
`https://api.attio.com/v2/${target}/${identifier}/attributes/${attribute}/statuses`,
);
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