# Get the current team

`GET https://console.advinservers.com/api/v1/client/teams/context`

### Overview

Returns the current team, its owner, your role and permissions under `active`. `teams` lists the teams you can access, with owned teams first. The remaining fields count owned teams, memberships and teams other than the current one. Leaving or deleting a team selects the account's default team.

### Permissions

Requires the account permission `teams.read` (View teams).

## Authorization

Send `Authorization: Bearer <token>` with the request. Your API key, sent as a bearer token. Create one in the control panel under API Keys, give it only the permissions the integration needs, and copy it when it is created. It cannot be shown again. Each key is restricted to one owned team. The key determines the team for every request.

## Response 200

The record, as a JSON object. There is no envelope.

- `active` (object, required): The team this request is working in.
  - `id` (string, required): The team's id.
  - `name` (string, required): What the team is called.
  - `is_owner` (boolean, required): True when the account owns this team rather than having been invited into it.
  - `owner` (object, required): The account the team belongs to. Both fields are null if that account has gone.
    - `name` (string | null, required): The name shown to customers.
    - `email` (string | null, required): The email address.
  - `role` (object | null, required): The role you hold here, or null when you own the team: ownership is not a role.
    - `id` (string, required): The id ID.
    - `name` (string, required): The name shown to customers.
  - `permissions` (string[], required): The permission keys you hold here. An account holder holds every key there is.
- `teams` (object[], required): Every team the account can work in, the ones it owns first and its default first among those.
  - `id` (string, required): The team's UUID.
  - `name` (string, required): What the team is called.
  - `is_owner` (boolean, required): True when the account owns this team rather than having been invited into it.
  - `is_default` (boolean, required): True for the account's default team, which is where anything created without naming a team lands.
  - `is_active` (boolean, required): True for the team this request is working in.
  - `role` (object | null, required): The role held here, or null when the account owns the team: ownership is not a role.
    - `id` (string, required): The id ID.
    - `name` (string, required): The name shown to customers.
- `owned_team_count` (integer, required): How many teams the account owns.
- `membership_count` (integer, required): How many teams the account has been invited into.
- `other_team_count` (integer, required): Those two added together, less the one this request is in.

```json
{
  "active": {
    "id": "fbb31f5f-bd6f-4019-a3ed-1062a28f56f7",
    "name": "Anomalous Materials",
    "is_owner": true,
    "owner": {
      "name": "Gordon Freeman",
      "email": "gordon.freeman@blackmesa.example.com"
    },
    "role": null,
    "permissions": [
      "team.read",
      "team.manage",
      "alert.read",
      "alert.manage",
      "server.read",
      "server.power",
      "server.console",
      "server.update",
      "server.credentials",
      "server.reinstall",
      "server.transfer",
      "backup.read",
      "backup.create",
      "backup.restore",
      "backup.download",
      "backup.delete",
      "snapshot.read",
      "snapshot.create",
      "snapshot.restore",
      "snapshot.delete",
      "snapshot.update",
      "snapshot.transfer",
      "firewall.read",
      "firewall.update",
      "firewall.delete",
      "network.read",
      "network.update",
      "network.transfer",
      "network.delete",
      "sshkey.read",
      "sshkey.update",
      "sshkey.delete",
      "script.read",
      "script.update",
      "script.delete",
      "iso.read",
      "iso.update",
      "iso.delete",
      "measured_boot.read",
      "measured_boot.update",
      "measured_boot.delete",
      "billing.read",
      "billing.manage",
      "billing.purchase"
    ]
  },
  "teams": [
    {
      "id": "fbb31f5f-bd6f-4019-a3ed-1062a28f56f7",
      "name": "Anomalous Materials",
      "is_owner": true,
      "is_default": true,
      "is_active": true,
      "role": null
    },
    {
      "id": "48454223-c5ac-461f-bead-ba8dda13eea9",
      "name": "Lambda Complex",
      "is_owner": true,
      "is_default": false,
      "is_active": false,
      "role": null
    }
  ],
  "owned_team_count": 2,
  "membership_count": 0,
  "other_team_count": 1
}
```

## Errors

- `401`: The key was missing, malformed, revoked, or belongs to an account that no longer exists.
- `403`: Access denied. Check the key's team, permissions and allowed IP addresses. Some actions, such as managing API keys, require a browser session. The response message explains the reason.
- `429`: Too many requests. The `Retry-After` header says how many seconds to wait. Limits are per account, so several keys on one account share them.

## Example request

```bash
curl --request GET \
  --url 'https://console.advinservers.com/api/v1/client/teams/context' \
  --header 'Authorization: Bearer <token>' \
  --header 'Accept: application/json'
```
