//native
type Formstack = {
token: string;
};
/**
* Create new subaccount preview
*
*/
export async function main(
auth: Formstack,
organizationId: string,
body: { productHandles: string[]; periodicity?: "monthly" | "yearly" },
) {
const url = new URL(
`https://admin.formstack.com/api/v1/api/v1/organizations/${organizationId}/subaccounts/preview`,
);
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 235 days ago