//native
type Clerk = {
apiKey: string;
};
/**
* Create a new organization domain.
* Creates a new organization domain. By default the domain is verified, but can be optionally set to unverified.
*/
export async function main(
auth: Clerk,
organization_id: string,
body: { name?: string; enrollment_mode?: string; verified?: false | true },
) {
const url = new URL(
`https://api.clerk.com/v1/organizations/${organization_id}/domains`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
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 428 days ago