//native
type Attio = {
token: string;
};
/**
* Create an object
* Creates a new custom object in your workspace.
Required scopes: `object_configuration:read-write`.
*/
export async function main(
auth: Attio,
body: {
data: { api_slug: string; singular_noun: string; plural_noun: string };
},
) {
const url = new URL(`https://api.attio.com/v2/objects`);
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