//native
type Brex = {
token: string;
};
/**
*
Create Budget Program
*
Creates a Budget Program
*/
export async function main(
auth: Brex,
Idempotency_Key: string,
body: {
existing_budget_ids?: string[];
budget_blueprints: {
name: string;
description: string;
parent_budget_id: string;
owner_user_ids?: string[];
period_type: "WEEKLY" | "MONTHLY" | "QUARTERLY" | "YEARLY" | "ONE_TIME";
start_date?: string;
end_date?: string;
limit: { amount: number; currency?: string };
limit_type: "HARD" | "SOFT";
spend_type:
| "BUDGET_PROVISIONED_CARDS_ONLY"
| "NON_BUDGET_PROVISIONED_CARDS_ALLOWED";
limit_visibility: "SHARED" | "PRIVATE";
}[];
employee_filter?: {
employment_status?:
| "EMPLOYMENT_STATUS_ACTIVE"
| "EMPLOYMENT_STATUS_INACTIVE"
| "EMPLOYMENT_STATUS_PENDING";
employment_type?:
| "EMPLOYMENT_TYPE_FULL_TIME"
| "EMPLOYMENT_TYPE_PART_TIME"
| "EMPLOYMENT_TYPE_CONTRACTOR"
| "EMPLOYMENT_TYPE_INTERN"
| "EMPLOYMENT_TYPE_FREELANCE";
};
name: string;
description?: string;
},
) {
const url = new URL(`https://platform.brexapis.com/v1/budget_programs`);
const response = await fetch(url, {
method: "POST",
headers: {
"Idempotency-Key": Idempotency_Key,
"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 170 days ago