//native
/**
* Create Zone
* Add a domain to the Cloudflare account. The zone stays pending until its nameservers point to Cloudflare.
*/
export async function main(
auth: RT.Cloudflare,
name: string,
type: "full" | "partial" | "secondary" | undefined,
jump_start: boolean | undefined
) {
const response = await fetch("https://api.cloudflare.com/client/v4/zones", {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
name,
account: { id: auth.account_id },
type: type || "full",
jump_start: jump_start ?? undefined,
}),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 4 hours ago