# Get Teammate Subuser Access

## API Overview

Twilio SendGrid's Teammates feature allows multiple users, or "Teammates," to work from a single SendGrid account.

Teammates enables groups of users with different roles and responsibilities to share one account, where each of these users has access to varying SendGrid features depending on their needs. By only giving your individual team members access to the features that they need to do their jobs, you can limit access to sensitive areas of your account. Teammates allows you to add, remove, and manage different users. See the [**Teammate Permissions** documentation](/docs/sendgrid/ui/account-and-settings/teammate-permissions) for more information about managing user permissions.

> \[!NOTE]
>
> Free and Essentials plans allow for adding one Teammate per account and do not offer Single Sign-On (SSO), while Pro and higher plans allow for up to 1,000 Teammates and include SSO and other features. To learn more about the different Email API plans, see the pricing page]\(https://sendgrid.com/en-us/pricing).

## Teammates vs Subusers

You can think of Subusers like subaccounts. Each Subuser account is its own email ecosystem with isolated contacts, templates, suppressions, and data. Subusers feed off their parent account email credits, and all billing rolls up to the parent account. Teammates may have access to a parent account, a group of Subusers, or a single Subuser account only.

## Operation overview

```json
{"path":"https://api.sendgrid.com/v3/teammates/{teammate_name}/subuser_access","method":"get","servers":[{"url":"https://api.sendgrid.com","description":"for global users and subusers"},{"url":"https://api.eu.sendgrid.com","description":"for EU regional subusers"}]}
```

**This operation allows you to retrieve the Subusers that can be accessed by a specified Teammate.**

This operation will return the Subusers available to a Teammate, including the scopes available. If the Teammate is an administrator, all Subusers will be returned.

## 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":"teammate_name","in":"path","description":"The username of the Teammate for whom you want to retrieve Subuser access information.","required":true,"schema":{"type":"string"}}]
```

### Query string

```json
[{"name":"after_subuser_id","in":"query","description":"The Subuser ID from which the API request will begin retrieving Subusers. This query parameter can be used in successive API calls to retrieve additional Subusers.","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit the number of Subusers to be returned. The default `limit` is `100` per request.","required":false,"schema":{"type":"integer","default":100}},{"name":"username","in":"query","description":"A Subuser's username that will be used to filter the returned result.","required":false,"schema":{"type":"string"}}]
```

### Responses

```json
[{"responseCode":"200","schema":{"description":"200 Success","content":{"application/json":{"schema":{"type":"object","example":{"has_restricted_subuser_access":true,"subuser_access":[{"id":1234,"username":"examplesubuser","email":"subuser@example.com","disabled":true,"permission_type":"admin","scopes":["billing.read"]}],"_metadata":{"next_params":{"limit":0,"after_subuser_id":0,"username":"string"}}},"properties":{"has_restricted_subuser_access":{"type":"boolean","description":"When this property is set to `true`, the Teammate has permissions to operate only on behalf of a Subuser. This property value is `true` when the `subuser_access` property is not empty. The `subuser_access` property determines which Subusers the Teammate may act on behalf of."},"subuser_access":{"type":"array","description":"Specifies which Subusers the Teammate may access and act on behalf of. If this property is populated, the `has_restricted_subuser_access` property will be `true`.","items":{"type":"object","description":"An array of Subusers to which the Teammate has access.","properties":{"id":{"type":"integer","description":"The ID of a Subuser to which the Teammate has access. You can retrieve Subuser IDs from the [Subusers API](/docs/sendgrid/api-reference/subusers-api/)."},"username":{"type":"string","description":"The username of a Subuser to which the Teammate has access."},"email":{"type":"string","description":"The email address of a Subuser to which the Teammate has access."},"disabled":{"type":"boolean","description":"Indicates if the Subuser is active for the SendGrid account."},"permission_type":{"type":"string","description":"The level of access the Teammate has to the specified Subuser. This property value may be either `admin` or `restricted`. When is property is set to `restricted`, the Teammate has only the permissions assigned in the `scopes` property.","enum":["admin","restricted"],"refName":"PermissionType","modelName":"PermissionType"},"scopes":{"type":"array","description":"The permissions or scopes that the Teammate can access on behalf of the Subuser. See [**Teammate Permissions**](/docs/sendgrid/ui/account-and-settings/teammate-permissions) for a complete list of available scopes.","items":{"type":"string"}}}}},"_metadata":{"type":"object","description":"This object contains response metadata. The presence of the `after_subuser_id` property in the metadata indicates that some items are still outstanding and have not been retrieved. You can use the `after_subuser_id` value to retrieve additional items with another request.","properties":{"next_params":{"type":"object","properties":{"limit":{"type":"integer","description":"The limit specified in the `limit` query parameter to constrain the number of Subusers returned."},"after_subuser_id":{"type":"integer","description":"The `after_subuser_id` property represents the last processed Subuser. If the `after_subuser_id` property is `null`, there are no more entries available."},"username":{"type":"string","description":"The username of a Subuser passed in the `name` query parameter to filter results by username."}}}}}}}}}}},{"responseCode":"400","schema":{"description":"400 Bad request","content":{"application/json":{"schema":{"type":"object","description":"An object containing an array of errors objects.","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"The message representing the error from the API."},"field":{"type":"string","description":"The field associated with the error."}}}}}},"example":{"errors":[{"message":"Bad request","field":""}]}}}}},{"responseCode":"401","schema":{"description":"401 Forbidden","content":{"application/json":{"schema":{"type":"object","description":"An object containing an array of errors objects.","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"The message representing the error from the API."},"field":{"type":"string","description":"The field associated with the error."}}}}}},"example":{"errors":[{"message":"Unauthorized","field":""}]}}}}},{"responseCode":"403","schema":{"description":"403 Forbidden","content":{"application/json":{"schema":{"type":"object","description":"An object containing an array of errors objects.","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"The message representing the error from the API."},"field":{"type":"string","description":"The field associated with the error."}}}}}},"example":{"errors":[{"message":"Forbidden","field":""}]}}}}},{"responseCode":"500","schema":{"description":"500","content":{"application/json":{"schema":{"type":"object","description":"An object containing an array of errors objects.","properties":{"errors":{"type":"array","items":{"type":"object","properties":{"message":{"type":"string","description":"The message representing the error from the API."},"field":{"type":"string","description":"The field associated with the error."}}}}}},"example":{"errors":[{"message":"Server error","field":""}]}}}}}]
```

Get Teammate Subuser Access

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

const teammate_name = "teammate_name";
const queryParams = { limit: 100 };

const request = {
  url: `/v3/teammates/${teammate_name}/subuser_access`,
  method: "GET",
  qs: queryParams,
};

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

teammate_name = "teammate_name"
params = {"limit": 100}

response = sg.client.teammates._(teammate_name).subuser_access.get(
    query_params=params
)

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 teammateName = "teammate_name";
        var queryParams = @"{'limit': 100}";

        var response = await client.RequestAsync(
            method: SendGridClient.Method.GET,
            urlPath: $"teammates/{teammateName}/subuser_access",
            queryParams: queryParams);

        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("/teammates/teammate_name/subuser_access");
            request.addQueryParam("limit", "100");
            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/teammates/teammate_name/subuser_access", host)
	request.Method = "GET"
	queryParams := make(map[string]string)
	queryParams["limit"] = "100"
	request.QueryParams = queryParams
	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);
$query_params = json_decode('{
    "limit": 100
}');
$teammate_name = "teammate_name";

try {
    $response = $sg->client
        ->teammates()
        ->_($teammate_name)
        ->subuser_access()
        ->get(null, $query_params);
    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'])
params = JSON.parse('{
  "limit": 100
}')
teammate_name = "teammate_name"

response = sg.client.teammates._(teammate_name).subuser_access.get(query_params: params)
puts response.status_code
puts response.headers
puts response.body
```

```bash
curl -G -X GET "https://api.sendgrid.com/v3/teammates/teammate_name/subuser_access?limit=100" \
--header "Authorization: Bearer $SENDGRID_API_KEY"
```
