Prerequisites

To get the most out of this guide, you’ll need to:

1. Create a Deno Deploy project

Go to dash.deno.com/projects and create a new playground project.

Deno Deploy - New Project

2. Edit the handler function

Paste the following code into the browser editor:

index.ts
import { serve } from "https://deno.land/std@0.190.0/http/server.ts";

const RESEND_API_KEY = 're_123456789';

const handler = async (_request: Request): Promise<Response> => {
    const res = await fetch('https://api.resend.com/emails', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${RESEND_API_KEY}`
        },
        body: JSON.stringify({
            from: 'Acme <onboarding@resend.dev>',
            to: ['delivered@resend.dev'],
            subject: 'hello world',
            html: '<strong>it works!</strong>',
        })
    });

    if (res.ok) {
        const data = await res.json();

        return new Response(data, {
            status: 200,
            headers: {
                'Content-Type': 'application/json',
            },
        });
    }
};

serve(handler);

3. Deploy and send email

Click on Save & Deploy at the top of the screen.

Deno Deploy - Playground

4. Try it yourself

Deno Deploy Example

See the full source code.