> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apollodeploy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send emails with Next.js

> Send a transactional email from a Next.js route handler with the official Apollo Signal SDK

Call Apollo Signal from a Route Handler, Server Action, or other server-only module. Do not import
the SDK into a Client Component. The client uses `https://api.signal.apollodeploy.com` by default.

Before you start, [create an API key](/signal/create-an-api-key) with **Emails: Send** permission
and [verify the From domain](/signal/add-a-domain).

<Steps>
  <Step title="Install the SDK">
    ```bash theme={"dark"}
    npm install @apollo-deploy/signal-sdk
    ```
  </Step>

  <Step title="Configure the server secret">
    Add `SIGNAL_API_KEY` to your deployment environment. Do not prefix it with `NEXT_PUBLIC_`.
  </Step>

  <Step title="Create a route handler">
    ```typescript app/api/send-welcome/route.ts theme={"dark"}
    import { ApolloSignalApi } from "@apollo-deploy/signal-sdk";

    const signal = new ApolloSignalApi();

    export async function POST(request: Request) {
      const { email } = (await request.json()) as { email: string };

      const message = await signal.emails.sendEmail(
        {
          from: "welcome@mail.company.com",
          to: [email],
          subject: "Welcome",
          text: "Your account is ready.",
        },
        {
          headers: {
            Authorization: `Bearer ${process.env.SIGNAL_API_KEY}`,
          },
        },
      );

      return Response.json({ id: message.id }, { status: 201 });
    }
    ```
  </Step>
</Steps>

Validate and authorize the incoming request before accepting arbitrary recipients. Add rate limits
when the route is reachable outside your trusted application flow.

<CardGroup cols={2}>
  <Card title="All SDKs" icon="code" href="/signal/send-with/sdk-overview">
    Compare every supported language and framework.
  </Card>

  <Card title="API key safety" icon="key" href="/signal/knowledge-base/how-to-handle-api-keys">
    Keep credentials out of client bundles and logs.
  </Card>
</CardGroup>
