# Get a List of Subusers Assigned to an IP

## 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/{ip}/subusers","method":"get","servers":[{"url":"https://api.sendgrid.com","description":"for global users"}]}
```

This operation returns a list of Subuser IDs that have been assigned the specified IP address. To retrieve more information about the returned Subusers, use the [Subusers API](/docs/sendgrid/api-reference/subusers-api/list-all-subusers).

You can use the `after_key` and `limit` query parameters to iterate through paginated results. The maximum limit is 100, meaning you may retrieve up to 100 Subusers per request. If the `after_key` in the API response is not null, there are more Subusers assigned to the IP address than those returned in the request. You can repeat the request with the non-null `after_key` value and the same limit to retrieve the next group of Subusers.

## 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":"ip","in":"path","schema":{"type":"string"},"description":"The `ip` path parameter specifies an IP address to make the request against.","required":true,"refName":"#/components/parameters/IpAddressManagementPathIp","modelName":"__components_parameters_IpAddressManagementPathIp"}]
```

### Query string

```json
[{"name":"after_key","in":"query","required":false,"schema":{"type":"integer"},"description":"Specifies which items to be returned by the API. When the `after_key` is specified, the API will return items beginning from the first item after the item specified. This parameter can be used in combination with `limit` to iterate through paginated results.","refName":"#/components/parameters/IpAddressManagementAfterKey","modelName":"__components_parameters_IpAddressManagementAfterKey"},{"schema":{"type":"integer","maximum":100},"in":"query","name":"limit","description":"Specifies the number of results to be returned by the API. This parameter can be used in combination with the `after_key` parameters to iterate through paginated results. The maximum limit is 100."}]
```

### Responses

```json
[{"responseCode":"200","schema":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"result":{"type":"array","description":"An array of Subuser IDs that have been assigned the specified IP address.","items":{"type":"string"}},"_metadata":{"type":"object","properties":{"next_params":{"type":"object","description":"A collection of fields that can be used to work the endpoint.","properties":{"after_key":{"type":"string","nullable":true,"description":"Specifies which items to be returned by the API. When the `after_key` is specified, the API will return items beginning from the first item after the item specified. This parameter can be used in combination with `limit` to iterate through paginated results. The `after_key` cannot be used in combination with the `before_key` parameter."},"limit":{"type":"string","description":"The `limit` specified in the request. This parameter will be included only if it was specified in the request. This is not the default limit enforced by the API."}}}}}}},"examples":{"200":{"value":{"result":["12345","67890"],"_metadata":{"next_params":{"after_key":null}}}}}}}}},{"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":{"invalid ip":{"value":{"errors":[{"field":"","message":"invalid IP address"}]},"refName":"#/components/examples/IpAddressManagement400InvalidIpError","modelName":"__components_examples_IpAddressManagement400InvalidIpError"},"limit value error":{"value":{"errors":[{"field":"limit","message":"should be > 0 and <= 100"}]},"refName":"#/components/examples/IpAddressManagement400LimitValueError","modelName":"__components_examples_IpAddressManagement400LimitValueError"},"after_key type error":{"value":{"errors":[{"field":"after_key","message":"must be a numeric value"}]},"refName":"#/components/examples/IpAddressManagement400AfterKeyTypeError","modelName":"__components_examples_IpAddressManagement400AfterKeyTypeError"}}}}}},{"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"}}]
```

Get a List of Subusers Assigned to an IP

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

const ip = "ip";

const request = {
  url: `/v3/send_ips/ips/${ip}/subusers`,
  method: "GET",
};

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"))

ip = "ip"

response = sg.client.send_ips.ips._(ip).subusers.get()

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 ip = "ip";

        var response = await client.RequestAsync(
            method: SendGridClient.Method.GET, urlPath: $"send_ips/ips/{ip}/subusers");

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

```java
import com.sendgrid.*;
import java.io.IOException;

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.GET);
            request.setEndpoint("/send_ips/ips/ip/subusers");
            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/ip/subusers", host)
	request.Method = "GET"
	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);
$ip = "ip";

try {
    $response = $sg->client
        ->send_ips()
        ->ips()
        ->_($ip)
        ->subusers()
        ->get();
    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'])
ip = "ip"

response = sg.client.send_ips.ips._(ip).subusers.get()
puts response.status_code
puts response.headers
puts response.body
```

```bash
curl -X GET "https://api.sendgrid.com/v3/send_ips/ips/ip/subusers" \
--header "Authorization: Bearer $SENDGRID_API_KEY"
```
