//native
type Formstack = {
token: string;
};
/**
* /subaccount/:subaccount_id/form/:form_id/copy
* Create a copy of the form from the parent account to the subaccount.
*/
export async function main(
auth: Formstack,
subaccount_id: string,
form_id: string,
) {
const url = new URL(
`https://www.formstack.com/api/v2/smartlist/${subaccount_id}/form/${form_id}/copy`,
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago