# SendGrid

Generate and API Key on SendGrid and copy it down.

Set it into the **.env** file

```
SENDGRID_API_KEY="<your_api_key>"
```

Open `src/config/auth.ts` and add the provider

```typescript
providers: [
  EmailProvider({
    async sendVerificationRequest({identifier: email, url}) {
      // Call the cloud Email provider API for sending emails
      // See https://docs.sendgrid.com/api-reference/mail-send/mail-send
      const response = await fetch("https://api.sendgrid.com/v3/mail/send", {
        // The body format will vary depending on provider, please see their documentation
        // for further details.
        body: JSON.stringify({
          personalizations: [{ to: [{ email }] }],
          from: { email: "noreply@company.com" },
          subject: "Sign in to Your page",
          content: [
            {
              type: "text/plain",
              value: `Please click here to authenticate - ${url}`,
            },
          ],
        }),
        headers: {
          // Authentication will also vary from provider to provider, please see their docs.
          Authorization: `Bearer ${process.env.SENDGRID_API_KEY}`,
          "Content-Type": "application/json",
        },
        method: "POST",
      })

      if (!response.ok) {
        const { errors } = await response.json()
        throw new Error(JSON.stringify(errors))
      }
    },
  })
],
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.shipped.club/features/authentication/sendgrid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
