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.
Authentication
- Base URL
https://api.distito.com/workspace-v2- Header
x-api-key: <your API key>
Parameters
| Parameter | Description |
|---|---|
X-Researcher-Idstring, in header | Optional. An identifier of your own for the person that the call acts for. Distito stores it as |
Examples
Set these variables in your shell, then run an example. An example stops with an error that names each variable that you did not set.
export DISTITO_API_URL=https://api.distito.com/workspace-v2
export DISTITO_API_KEY=<your API key>
DISTITO_API_URLThe base URL of the Workspace API.
DISTITO_API_KEYYour API key. A workspace administrator makes it on the API keys page of the web app,
/app/account/api-keys/.
curl
#!/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
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
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)
Responses
200 — The workspace
| Field | Description |
|---|---|
tenantIdstringrequired | The identifier of the workspace. |
displayNamestring | The name of the workspace, as its members see it in the web app. |
memberCountinteger | The number of members of the workspace, invited members included. |
maxMembersinteger | The largest number of members that the workspace can have. |
403 — The request names no member of the workspace
| Field | Description |
|---|---|
messagestringrequired | |
errorstringrequired | |
detailsobject | |
requestIdstring |
# 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)
```