Edits history of script submission #14577 for ' Create secure email to send card number (brex)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Brex = {
      token: string;
    };
    /**
     * 
    Create secure email to send card number 
    
     * 
    Creates a secure email to send card number, CVV, and expiration date of a card by ID to the specified email.
    
    This endpoint is currently gated. If you would like to request access, please reach out to
    developer-support@brex.com
    
     */
    export async function main(
      auth: Brex,
      id: string,
      Idempotency_Key: string,
      body: {
        recipient_email?: string;
        sender_name?: string;
        message?: string;
        expiry_days?: number;
      },
    ) {
      const url = new URL(
        `https://platform.brexapis.com/v2/cards/${id}/secure_email`,
      );
    
      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.text();
    }
    

    Submitted by hugo697 217 days ago