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

# Sending Emails via SendGrid

> Send emails through SendGrid using the SendPost API with IP Pool routing.

Once your SendGrid provider and IP Pool are configured, you can send emails through SendGrid using the standard SendPost API.

<Note>
  **Important**: You must include the `ippool` parameter in your API request to route emails through SendGrid.
</Note>

***

## Basic Email Example

```bash theme={null}
curl -X POST "https://api.sendpost.io/api/v1/subaccount/email/" \
  -H "X-SubAccount-ApiKey: YOUR_SENDPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {
      "email": "sender@yourdomain.com",
      "name": "Your Name"
    },
    "to": [{
      "email": "recipient@example.com",
      "name": "Recipient Name"
    }],
    "subject": "Hello from SendPost via SendGrid",
    "htmlBody": "<h1>Hello!</h1><p>This email is sent through SendGrid.</p>",
    "textBody": "Hello! This email is sent through SendGrid.",
    "ippool": "sendgrid-pool",
    "trackOpens": true,
    "trackClicks": true
  }'
```

***

## Email with Personalization

```bash theme={null}
curl -X POST "https://api.sendpost.io/api/v1/subaccount/email/" \
  -H "X-SubAccount-ApiKey: YOUR_SENDPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {
      "email": "sender@yourdomain.com",
      "name": "Your Company"
    },
    "to": [{
      "email": "john@example.com",
      "name": "John Doe",
      "customFields": {
        "firstName": "John",
        "accountType": "Premium"
      }
    }],
    "subject": "Welcome {{firstName}}!",
    "htmlBody": "<h1>Welcome {{firstName}}!</h1><p>Your {{accountType}} account is ready.</p>",
    "ippool": "sendgrid-pool",
    "trackOpens": true,
    "trackClicks": true
  }'
```

***

## Using SendGrid IP Pools

If you have multiple IP Pools configured in your SendGrid account and want to specify which SendGrid IP Pool to use for sending, you can pass the `tpspIppool` parameter in your API request.

<Info>
  The `tpspIppool` field is optional. Use it when you want to route emails through a specific IP Pool on the SendGrid side, separate from the SendPost IP Pool routing.
</Info>

**Parameters**:

* `ippool`: The SendPost IP Pool that routes traffic to SendGrid (required)
* `tpspIppool`: The IP Pool name configured in your SendGrid account (optional)

```bash theme={null}
curl -X POST "https://api.sendpost.io/api/v1/subaccount/email/" \
  -H "X-SubAccount-ApiKey: YOUR_SENDPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "from": {
      "email": "sender@yourdomain.com",
      "name": "Your Company"
    },
    "to": [{
      "email": "recipient@example.com",
      "name": "Recipient Name"
    }],
    "subject": "Hello from SendPost via SendGrid",
    "htmlBody": "<h1>Hello!</h1><p>This email is sent through a specific SendGrid IP Pool.</p>",
    "ippool": "sendgrid-pool",
    "tpspIppool": "transactional",
    "trackOpens": true,
    "trackClicks": true
  }'
```

In this example:

* `ippool: "sendgrid-pool"` - Routes the email through SendPost's IP Pool configured for SendGrid
* `tpspIppool: "transactional"` - Sends the email via the "transactional" IP Pool in your SendGrid account

***

## Response

**Success Response** (HTTP 200):

```json theme={null}
[
  {
    "messageId": "abc123-def456-ghi789",
    "errorCode": 0,
    "to": "recipient@example.com"
  }
]
```

***

## Next Steps

* [Migrate from SendGrid](/guides/sendgrid/compatible-api) using the SendGrid-Compatible API
* [Understand event types](/guides/sendgrid/event-types) for tracking email status
* [View analytics](/guides/sendgrid/analytics) for your SendGrid emails
