# Add an IP address to a pool

## API Overview

IP pools allow you to group your dedicated SendGrid IP addresses. For example, you could create separate one pool for your transactional email and another for your marketing email. When sending marketing emails, specify that you want to use the marketing IP pool. This allows you to maintain separate reputations for your different email traffic.

A single IP address or a range of IP addresses may be dedicated to an account in order to send email for multiple domains. *The reputation of this IP is determined by the aggregate performance of all email traffic sent from it*.

IP pools can only be used with IP addresses for which you've set up a reverse DNS record.

If an IP pool is *not* specified for an email, it will use any IP available, including pooled addresses.

**Each user can create up to 100 different IP pools.**

## Operation overview

```json
{"path":"https://api.sendgrid.com/v3/ips/pools/{pool_name}/ips","method":"post","servers":[{"url":"https://api.sendgrid.com","description":"for global users and subusers"},{"url":"https://api.eu.sendgrid.com","description":"for EU regional subusers"}]}
```

**This endpoint allows you to add an IP address to an IP pool.**

You can add the same IP address to multiple pools. It may take up to 60 seconds for your IP address to be added to a pool after your request is made.

Before you can add an IP to a pool, you need to activate it in your SendGrid account:

1. Log into your SendGrid account.
2. Navigate to **Settings** and then select **IP Addresses**.
3. Find the IP address you want to activate and then click **Edit**.
4. Check **Allow my account to send mail using this IP address**.
5. Click **Save**.

You can retrieve all of your available IP addresses from the "Retrieve all IP addresses" endpoint.

## Operation details

### Authentication

API Key

### Headers

```json
[{"in":"header","name":"Authorization","required":true,"default":"Bearer <<YOUR_API_KEY_HERE>>","schema":{"type":"string"}}]
```

### Path parameters

```json
[{"name":"pool_name","in":"path","description":"The name of the IP pool you want to add the address to. If the name contains spaces, they must be URL encoded (e.g., \"Test Pool\" becomes \"Test%20Pool\").","required":true,"schema":{"type":"string"}}]
```

### Request body

```json
{"schema":{"type":"object","example":{"ip":"0.0.0.0"},"properties":{"ip":{"type":"string","description":"The IP address that you want to add to the named pool."}}},"encodingType":"application/json"}
```

### Responses

```json
[{"responseCode":"201","schema":{"description":"","content":{"application/json":{"schema":{"type":"object","required":["ip","pools","start_date","warmup"],"properties":{"ip":{"type":"string","description":"The IP address."},"pools":{"type":"array","description":"The IP pools that this IP address has been added to.","items":{"type":"string"}},"start_date":{"type":"integer","description":"A Unix timestamp indicating when the warmup process began for the added IP address."},"warmup":{"type":"boolean","description":"Indicates if the IP address is in warmup."}}},"examples":{"response":{"value":{"ip":"000.00.00.0","pools":["test1"],"start_date":1409616000,"warmup":true}}}}}}},{"responseCode":"404","schema":{"description":"","content":{"application/json":{"schema":{"type":"object","properties":{"errors":{"type":"array","description":"The error returned.","items":{"type":"object","properties":{"field":{"type":"string","nullable":true},"message":{"type":"string","description":"A message explaining why the IP address could not be added to the IP Pool."}}}}}},"examples":{"response":{"value":{"errors":[{"field":null,"message":"resource not found"}]}}}}}}}]
```

Add an IP address to a pool

```js
const client = require("@sendgrid/client");
client.setApiKey(process.env.SENDGRID_API_KEY);

const pool_name = "pool_name";
const data = {
  ip: "0.0.0.0",
};

const request = {
  url: `/v3/ips/pools/${pool_name}/ips`,
  method: "POST",
  body: data,
};

client
  .request(request)
  .then(([response, body]) => {
    console.log(response.statusCode);
    console.log(response.body);
  })
  .catch((error) => {
    console.error(error);
  });
```

```python
import os
from sendgrid import SendGridAPIClient


sg = SendGridAPIClient(os.environ.get("SENDGRID_API_KEY"))

pool_name = "pool_name"
data = {"ip": "0.0.0.0"}

response = sg.client.ips.pools._(pool_name).ips.post(request_body=data)

print(response.status_code)
print(response.body)
print(response.headers)
```

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using SendGrid;

public class Program {
    public static async Task Main() {
        string apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
        var client = new SendGridClient(apiKey);

        var poolName = "pool_name";
        var data =
            @"{
            ""ip"": ""0.0.0.0""
        }";

        var response = await client.RequestAsync(
            method: SendGridClient.Method.POST,
            urlPath: $"ips/pools/{poolName}/ips",
            requestBody: data);

        Console.WriteLine(response.StatusCode);
        Console.WriteLine(response.Body.ReadAsStringAsync().Result);
        Console.WriteLine(response.Headers.ToString());
    }
}
```

```java
import com.sendgrid.*;
import java.io.IOException;
import org.json.JSONObject;
import java.util.HashMap;

public class Example {
    public static void main(String[] args) throws IOException {
        try {
            SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
            Request request = new Request();
            request.setMethod(Method.POST);
            request.setEndpoint("/ips/pools/pool_name/ips");
            request.setBody(new JSONObject(new HashMap<String, Object>() {
                {
                    put("ip", "0.0.0.0");
                }
            }).toString());
            Response response = sg.api(request);
            System.out.println(response.getStatusCode());
            System.out.println(response.getBody());
            System.out.println(response.getHeaders());
        } catch (IOException ex) {
            throw ex;
        }
    }
}
```

```go
package main

import (
	"fmt"
	"github.com/sendgrid/sendgrid-go"
	"os"
)

func main() {
	apiKey := os.Getenv("SENDGRID_API_KEY")
	host := "https://api.sendgrid.com"
	request := sendgrid.GetRequest(apiKey, "/v3/ips/pools/pool_name/ips", host)
	request.Method = "POST"
	request.Body = []byte(`{
  "ip": "0.0.0.0"
}`)
	response, err := sendgrid.API(request)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		fmt.Println(response.StatusCode)
		fmt.Println(response.Body)
		fmt.Println(response.Headers)
	}
}
```

```php
<?php
// Uncomment the next line if you're using a dependency loader (such as Composer) (recommended)
// require 'vendor/autoload.php';

// Uncomment next line if you're not using a dependency loader (such as Composer)
// require_once '<PATH TO>/sendgrid-php.php';

$apiKey = getenv("SENDGRID_API_KEY");
$sg = new \SendGrid($apiKey);
$request_body = json_decode('{
    "ip": "0.0.0.0"
}');
$pool_name = "pool_name";

try {
    $response = $sg->client
        ->ips()
        ->pools()
        ->_($pool_name)
        ->ips()
        ->post($request_body);
    print $response->statusCode() . "\n";
    print_r($response->headers());
    print $response->body() . "\n";
} catch (Exception $ex) {
    echo "Caught exception: " . $ex->getMessage();
}
```

```ruby
require 'sendgrid-ruby'
include SendGrid

sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
data = JSON.parse('{
  "ip": "0.0.0.0"
}')
pool_name = "pool_name"

response = sg.client.ips.pools._(pool_name).ips.post(request_body: data)
puts response.status_code
puts response.headers
puts response.body
```

```bash
curl -X POST "https://api.sendgrid.com/v3/ips/pools/pool_name/ips" \
--header "Authorization: Bearer $SENDGRID_API_KEY" \
--header "Content-Type: application/json" \
--data '{"ip": "0.0.0.0"}'
```
