//native
type Clickup = {
token: string;
};
/**
* Create Doc
* Create a new Doc.
*/
export async function main(
auth: Clickup,
workspaceId: string,
body: {
name?: string;
parent?: { id: string; type: number };
visibility?: string;
create_page?: false | true;
},
) {
const url = new URL(
`https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: 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 168 days ago