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 50 days ago
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 611 days ago
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 613 days ago