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