# Retrieve the API key's environment (/docs/api-reference/environment/get-environment)

Which environment, project and organization the API key belongs to, and the key itself. Any valid key can read its own environment (no permission needed): use it to check a key, show where it sends and what it may do.

`GET https://api.coss.com/v1/environment`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.environment.get();
```

HTTP:

```sh
curl -X GET "https://api.coss.com/v1/environment" \
  -H "Authorization: Bearer $COSS_API_KEY"
```

Python:

```python
from coss import Coss

client = Coss()  # api_key= or COSS_API_KEY

client.environment.get()
```

Go:

```go
import (
	"context"

	cossclient "github.com/cosscom/coss-go/client"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

client.Environment.Get(
    context.TODO(),
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.environment.get
```

PHP:

```php
<?php

use Coss\Coss;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->environment->get();
```

Java:

```java
import com.coss.Coss;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.environment().get();
```

.NET:

```csharp
using Coss;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Environment.GetAsync();
```

## Response 200

The API key's environment.

- `object` ("environment", required)
- `id` (string, required): The environment's id.
- `name` (string, required): The environment's name.
- `slug` (string, required): The environment's slug, as in dashboard URLs.
- `mode` ("live" | "sandbox", required): `live` delivers email; `sandbox` (`coss_test_` keys) never does.
- `project` (object, required): The project it belongs to.
  - `id` (string, required): The project's id.
  - `name` (string, required): The project's name.
  - `slug` (string, required): The project's slug, as in dashboard URLs.
- `organization` (object, required): The organization it belongs to.
  - `id` (string, required): The organization's id.
  - `name` (string, required): The organization's name.
  - `slug` (string, required): The organization's slug, as in dashboard URLs.
  - `api_version` (string, required): The organization's pinned API version: what requests without a `Coss-Version` header and new webhook endpoints get.
  - `hipaa_mode` (boolean, required): Whether the organization is in HIPAA mode, which refuses some requests with `hipaa_mode_restriction`. Its compliance settings page lists what the mode changes.
- `api_key` (object, required): The API key making this request.
  - `id` (string, required): The key's id.
  - `name` (string | null, required): The key's name. `null`: none.
  - `start` (string | null, required): The key's first characters, as shown in the dashboard.
  - `access` ("full" | "restricted", required): `full`: every permission, including ones new products add later. `restricted`: only `permissions`, chosen when the key was created.
  - `permissions` (string[], required): What the key may do now, as `resource:action` (the names `insufficient_permissions` errors use), e.g. `email:send`.

Example:

```json
{
  "object": "environment",
  "id": "env_01k7c8m4q2f3e9v6t5r1n0p8yz",
  "name": "Development",
  "slug": "development",
  "mode": "sandbox",
  "project": {
    "id": "proj_01k7c8m4q2f3e9v6t5r1n0p8yz",
    "name": "Default",
    "slug": "default"
  },
  "organization": {
    "id": "org_01k7c8m4q2f3e9v6t5r1n0p8yz",
    "name": "Acme",
    "slug": "acme",
    "api_version": "2026-10-10"
  },
  "api_key": {
    "id": "key_01k7c8m4q2f3e9v6t5r1n0p8yz",
    "name": "Backend",
    "start": "coss_test_Ab",
    "access": "restricted",
    "permissions": [
      "email:send",
      "email:read"
    ]
  }
}
```

## Errors

- `400`: The `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).