Edits history of script submission #1266 for ' Create a new API key (resend)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Resend = {
      token: string;
    };
    /**
     * Create a new API key
     *
     */
    export async function main(
      auth: Resend,
      body: {
        name: string;
        permission?: "full_access" | "sending_access";
        domain_id?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.resend.com/api-keys`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "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 398 days ago

  • nativets
    type Resend = {
      token: string;
    };
    /**
     * Create a new API key
     *
     */
    export async function main(
      auth: Resend,
      body: {
        name: string;
        permission?: "full_access" | "sending_access";
        domain_id?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.resend.com/api-keys`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "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 960 days ago

  • nativets
    export type Resend = {
      token: string;
    };
    /**
     * Create a new API key
     *
     */
    export async function main(
      auth: Resend,
      body: {
        /**   * The API key name.   */ name: string;
        /**   * The API key can have full access to Resend’s API or be only restricted to send emails. * full_access - Can create, delete, get, and update any resource. * sending_access - Can only send emails.   */ permission?:
          | "full_access"
          | "sending_access";
        /**   * Restrict an API key to send emails only from a specific domain. Only used when the permission is sending_acces.   */ domain_id?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.resend.com/api-keys`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      return await response.json();
    }
    

    Submitted by rubenfiszel 961 days ago