Edits history of script submission #14568 for ' Archive a Spend Limit (brex)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Brex = {
      token: string;
    };
    /**
     * 
    Archive a Spend Limit
    
     * 
    Archives a Spend Limit, making it unusable for future expenses and removing it from the UI
    
     */
    export async function main(auth: Brex, id: string) {
      const url = new URL(
        `https://platform.brexapis.com/v2/spend_limits/${id}/archive`,
      );
    
      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.text();
    }
    

    Submitted by hugo697 217 days ago