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