//native
type Brex = {
token: string;
};
/**
*
Create Spend Limit
*
Creates a Spend Limit
*/
export async function main(
auth: Brex,
Idempotency_Key: string,
body: {
name: string;
description?: string;
parent_budget_id?: string;
period_recurrence_type:
| ("PER_WEEK" & {})
| ("PER_MONTH" & {})
| ("PER_QUARTER" & {})
| ("PER_YEAR" & {})
| ("ONE_TIME" & {});
start_date?: string;
end_date?: string;
authorization_settings: {
base_limit: { amount: number; currency?: string } & {};
limit_buffer_percentage?: number;
authorization_type: ("HARD" & {}) | ("SOFT" & {});
rollover_refresh_rate:
| ("PER_MONTH" & {})
| ("PER_QUARTER" & {})
| ("PER_YEAR" & {})
| ("OFF" & {})
| ("NEVER" & {});
} & {};
expense_visibility: ("SHARED" & {}) | ("PRIVATE" & {});
authorization_visibility: ("PRIVATE" & {}) | ("PUBLIC" & {});
transaction_limit?: { amount: number; currency?: string } & {};
limit_increase_setting: ("ENABLED" & {}) | ("DISABLED" & {});
spend_type:
| ("BUDGET_PROVISIONED_CARDS_ONLY" & {})
| ("NON_BUDGET_PROVISIONED_CARDS_ALLOWED" & {});
auto_transfer_cards_setting: ("ENABLED" & {}) | ("DISABLED" & {});
auto_create_limit_cards_setting: ("DISABLED" & {}) | ("ALL_MEMBERS" & {});
owner_user_ids?: string[];
member_user_ids?: string[];
expense_policy_id: string;
limit_increase_request_policy_id?: string;
limit_approval_policy_id?: string;
legal_entity_id?: string;
department_id?: string;
},
) {
const url = new URL(`https://platform.brexapis.com/v2/spend_limits`);
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