# Get the workspace `GET /workspace`

Returns the workspace that the API key belongs to: its name, the number of its members and the largest number of members that it can have.

## Base URL

https://api.distito.com/workspace-v2

## Authentication

Send the key in the `x-api-key` header. Send the key from a server, or from a dashboard that only the staff of your workspace open. Never put the key in a page that readers load: anybody who can read the page can use the key to act as your workspace.

## Variables

- `DISTITO_API_URL` = `https://api.distito.com/workspace-v2` — The base URL of the Workspace API.
- `DISTITO_API_KEY` — Your API key. A workspace administrator makes it on the API keys page of the web app, `/app/account/api-keys/`.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `X-Researcher-Id` | header | no | string | Optional. An identifier of your own for the person that the call acts for. Distito stores it as `api:<identifier>` on what the call creates, and shows it as the name of the creator. A call that only reads ignores it. |

## Responses

### 200

The workspace

- `tenantId` (string, required) — The identifier of the workspace.
- `displayName` (string) — The name of the workspace, as its members see it in the web app.
- `memberCount` (integer) — The number of members of the workspace, invited members included.
- `maxMembers` (integer) — The largest number of members that the workspace can have.

### 403

The request names no member of the workspace

- `message` (string, required)
- `error` (string, required)
- `details` (object)
- `requestId` (string)

## Examples

### curl

```Shell
#!/bin/sh
set -eu

: "${DISTITO_API_URL:?is not set}"
: "${DISTITO_API_KEY:?is not set}"

curl --fail-with-body --silent --show-error \
	--header "x-api-key: $DISTITO_API_KEY" \
	"$DISTITO_API_URL/workspace"
```

### Node.js

```JavaScript
const required = function (name) {
		const value = process.env[name];
		if (!value) {
			console.error(`${name} is not set`);
			process.exit(1);
		}
		return value;
	},
	apiUrl = required('DISTITO_API_URL'),
	apiKey = required('DISTITO_API_KEY'),
	response = await fetch(`${apiUrl}/workspace`, {
		headers: { 'x-api-key': apiKey }
	}),
	body = await response.text();
console.log(body);
if (response.status >= 400) {
	process.exitCode = 1;
}
```

### Python

```Python
import os
import sys
import urllib.error
import urllib.request


def required(name):
    value = os.environ.get(name)
    if not value:
        sys.exit(f"{name} is not set")
    return value


api_url = required("DISTITO_API_URL")
api_key = required("DISTITO_API_KEY")

request = urllib.request.Request(
    f"{api_url}/workspace",
    headers={"x-api-key": api_key},
)
try:
    with urllib.request.urlopen(request) as response:
        print(response.read().decode())
except urllib.error.HTTPError as error:
    print(error.read().decode())
    sys.exit(1)
```
