# Add a Twilio SendGrid IP Address

## API Overview

The IP Address Management API combines functionality that was previously split between the Twilio SendGrid [IP Address API](/docs/sendgrid/api-reference/ip-address) and [IP Pools API](/docs/sendgrid/api-reference/ip-pools). This functionality includes adding IP addresses to your account, assigning IP addresses to IP Pools and Subusers, among other tasks. More details about each operation can be found in the descriptions and schemas for each endpoint.

> \[!NOTE]
>
> Regional Email sending in the European Union (EU) is available for [Twilio SendGrid Pro plan or above](https://sendgrid.com/en-us/pricing). EU Regional Email sending requires use of an EU IP address and EU subuser. Learn more about [sending emails with Twilio SendGrid on EU servers](https://www.twilio.com/en-us/blog/send-emails-in-eu).

> \[!WARNING]
>
> The IP Address Management API is in public beta at this time. This means the API and documentation are still in development and subject to change without advanced notice.

## Operation overview

```json
{"path":"https://api.sendgrid.com/v3/send_ips/ips","method":"post","servers":[{"url":"https://api.sendgrid.com","description":"for global users"}]}
```

This operation adds a Twilio SendGrid IP address to your account. You can also assign up to 100 Subusers to the IP address at creation.

## Operation details

### Authentication

API Key

### Headers

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

### Request body

```json
{"schema":{"type":"object","required":["is_auto_warmup","is_parent_assigned"],"properties":{"is_auto_warmup":{"type":"boolean","description":"Indicates if the IP address is set to automatically [warmup](/docs/sendgrid/ui/sending-email/warming-up-an-ip-address)."},"is_parent_assigned":{"type":"boolean","description":"Indicates if a parent on the account is able to send email from the IP address."},"subusers":{"type":"array","maxItems":100,"description":"An array of Subuser IDs the IP address will be assigned to.","items":{"type":"string"}},"region":{"type":"string","default":"us","description":"The region to which the IP address is assigned. This property will only be returned if the `include_region` query parameter is included and set to `true` as part of the API request.","enum":["eu","us"],"refName":"Region3","modelName":"Region3"},"include_region":{"type":"boolean","default":false,"description":"Boolean indicating whether or not to return the IP address's region information in the response."}}},"examples":{"example-1":{"value":{"is_auto_warmup":true,"is_parent_assigned":true,"subusers":["12345"]}}},"encodingType":"application/json"}
```

### Responses

```json
[{"responseCode":"201","schema":{"description":"Created","content":{"application/json":{"schema":{"type":"object","properties":{"ip":{"type":"string","description":"The IP address that was added to your account."},"is_auto_warmup":{"type":"boolean","description":"Indicates if the IP address is set to automatically [warmup](/docs/sendgrid/ui/sending-email/warming-up-an-ip-address).  This parameter is returned only if the IP address is set to automatically warm up."},"is_parent_assigned":{"type":"boolean","description":"Indicates if a parent on the account is able to send email from the IP address."},"subusers":{"type":"array","description":"An array of Subuser IDs the IP address was assigned to.","items":{"type":"string"}},"region":{"type":"string","description":"The region to which the IP address is assigned. This property will only be returned if the `include_region` query parameter is included and set to `true` as part of the API request.","enum":["eu","us"],"refName":"Region2","modelName":"Region2"}}},"examples":{"201":{"value":{"ip":"127.0.0.1","is_auto_warmup":true,"is_parent_assigned":true,"subusers":["12345"]}}}}}}},{"responseCode":"400","schema":{"description":"Bad Request","content":{"application/json":{"schema":{"type":"object","example-1":{"errors":[{"field":"after_key","message":"must be a numeric value"}]},"description":"IP Address Management Error Response Schema","refName":"IpAddressManagementErrorResponse","modelName":"IpAddressManagementErrorResponse","properties":{"errors":{"type":"array","description":"An array of error objects.","items":{"type":"object","properties":{"field":{"type":"string","description":"Indicates which field caused the error. This may be an empty string if no specific field is responsible for the error."},"message":{"type":"string","description":"An error-specific message that provides more information about the error's cause."}}}}}},"examples":{"JSON parse error":{"value":{"errors":[{"field":"","message":"failed to parse the request body as a JSON payload"}]},"refName":"#/components/examples/IpAddressManagement400JsonParseError","modelName":"__components_examples_IpAddressManagement400JsonParseError"},"no ips remaining":{"value":{"errors":[{"field":"","message":"No IPs remaining"}]},"refName":"#/components/examples/IpAddressManagement400IpNoRemainingError","modelName":"__components_examples_IpAddressManagement400IpNoRemainingError"},"is_auto_warmup not found":{"value":{"errors":[{"field":"is_auto_warmup","message":"not found in the request body"}]},"refName":"#/components/examples/IpAddressManagement400IsAutoWarmupMissingError","modelName":"__components_examples_IpAddressManagement400IsAutoWarmupMissingError"},"is_parent_assigned not found":{"value":{"errors":[{"field":"is_parent_assigned","message":"not found in the request body"}]},"refName":"#/components/examples/IpAddressManagement400IsParentAssignedMissingError","modelName":"__components_examples_IpAddressManagement400IsParentAssignedMissingError"},"subusers unverified":{"value":{"errors":[{"field":"subusers","message":"unverified subusers: 123, 456, 789"}]},"refName":"#/components/examples/IpAddressManagement400SubusersUnverifiedError","modelName":"__components_examples_IpAddressManagement400SubusersUnverifiedError"},"subusers limit exceeded":{"value":{"errors":[{"field":"subusers","message":"cannot assign more than 1000 subusers per call"}]},"refName":"#/components/examples/IpAddressManagement400SubusersLimitError","modelName":"__components_examples_IpAddressManagement400SubusersLimitError"},"subusers caller id error":{"value":{"errors":[{"field":"subusers","message":"cannot contain caller’s userID"}]},"refName":"#/components/examples/IpAddressManagement400SubusersCallerIdError","modelName":"__components_examples_IpAddressManagement400SubusersCallerIdError"},"subusers is_auto_warmup error":{"value":{"errors":[{"field":"subusers","message":"these users must have at least one IP that is not in warmup: 123, 456"}]},"refName":"#/components/examples/IpAddressManagement400IsAutoWarmupSubusersError","modelName":"__components_examples_IpAddressManagement400IsAutoWarmupSubusersError"}}}}}},{"responseCode":"401","schema":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","example-1":{"errors":[{"field":"after_key","message":"must be a numeric value"}]},"description":"IP Address Management Error Response Schema","x-examples":{"example-1":{"errors":[{"field":"","message":"missing required scope: scope1, scope2"}]}},"refName":"IpAddressManagementErrorResponse","modelName":"IpAddressManagementErrorResponse","properties":{"errors":{"type":"array","description":"An array of error objects.","items":{"type":"object","properties":{"field":{"type":"string","description":"Indicates which field caused the error. This may be an empty string if no specific field is responsible for the error."},"message":{"type":"string","description":"An error-specific message that provides more information about the error's cause."}}}}}},"examples":{"Missing required scope":{"value":{"errors":[{"field":"","message":"missing required scope: scope1, scope2"}]}}}},"application/xml":{"schema":{"type":"object","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"message":{"type":"string"}}}}},"x-examples":{"example-1":{"errors":[{"field":"","message":"missing required scope: scope1, scope2"}]}}}}},"refName":"#/components/responses/IpAddressManagement401","modelName":"__components_responses_IpAddressManagement401"}},{"responseCode":"500","schema":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"object","example-1":{"errors":[{"field":"after_key","message":"must be a numeric value"}]},"description":"IP Address Management Error Response Schema","x-examples":{"example-1":{"errors":[{"field":"","message":"internal server error"}]}},"refName":"IpAddressManagementErrorResponse","modelName":"IpAddressManagementErrorResponse","properties":{"errors":{"type":"array","description":"An array of error objects.","items":{"type":"object","properties":{"field":{"type":"string","description":"Indicates which field caused the error. This may be an empty string if no specific field is responsible for the error."},"message":{"type":"string","description":"An error-specific message that provides more information about the error's cause."}}}}}},"examples":{"Generic 500":{"value":{"errors":[{"field":"","message":"internal server error"}]}}}}},"refName":"#/components/responses/IpAddressManagement500","modelName":"__components_responses_IpAddressManagement500"}}]
```

Add a Twilio SendGrid IP Address

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

const data = {
  is_auto_warmup: true,
  is_parent_assigned: true,
  subusers: ["12345"],
};

const request = {
  url: `/v3/send_ips/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"))

data = {
    "is_auto_warmup": True,
    "is_parent_assigned": True,
    "subusers": ["12345"],
}

response = sg.client.send_ips.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 data =
            @"{
            ""is_auto_warmup"": true,
            ""is_parent_assigned"": true,
            ""subusers"": [
                ""12345""
            ]
        }";

        var response = await client.RequestAsync(
            method: SendGridClient.Method.POST, urlPath: "send_ips/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;
import java.util.Arrays;

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("/send_ips/ips");
            request.setBody(new JSONObject(new HashMap<String, Object>() {
                {
                    put("is_auto_warmup", true);
                    put("is_parent_assigned", true);
                    put("subusers", Arrays.asList("12345"));
                }
            }).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/send_ips/ips", host)
	request.Method = "POST"
	request.Body = []byte(`{
  "is_auto_warmup": true,
  "is_parent_assigned": true,
  "subusers": [
    "12345"
  ]
}`)
	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('{
    "is_auto_warmup": true,
    "is_parent_assigned": true,
    "subusers": [
        "12345"
    ]
}');

try {
    $response = $sg->client
        ->send_ips()
        ->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('{
  "is_auto_warmup": true,
  "is_parent_assigned": true,
  "subusers": [
    "12345"
  ]
}')

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

```bash
curl -X POST "https://api.sendgrid.com/v3/send_ips/ips" \
--header "Authorization: Bearer $SENDGRID_API_KEY" \
--header "Content-Type: application/json" \
--data '{"is_auto_warmup": true, "is_parent_assigned": true, "subusers": ["12345"]}'
```
