UNPKG

@letanure/resend-cli

Version:

A command-line interface for Resend email API

38 lines 1.18 kB
import { Resend } from 'resend'; import { formatResendError } from '../../../utils/resendErrors.js'; /** * Creates an audience using the Resend API * * @param data - Audience data for creation * @param apiKey - API key for Resend API * @returns Promise<ApiResult<CreateAudienceResponseSuccess>> - Standard result format */ export async function createAudience(data, apiKey) { try { const resend = new Resend(apiKey); const { data: responseData, error } = await resend.audiences.create(data); if (error) { return { success: false, error: formatResendError(error, 'create audience', data), }; } if (!responseData) { return { success: false, error: formatResendError('No data returned from API', 'create audience', data), }; } return { success: true, data: responseData, }; } catch (error) { return { success: false, error: formatResendError(error, 'create audience', data), }; } } //# sourceMappingURL=action.js.map