# Get the workspace

> The workspace your key belongs to, its environment, and what its plan allows.

<Endpoint method="GET" path="/v1/workspace" />

<CodeTabs>

```bash tab="cURL"
curl https://api.muzekit.com/v1/workspace \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY"
```

```javascript tab="Node"
const res = await fetch("https://api.muzekit.com/v1/workspace", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
});
const workspace = await res.json();
```

```python tab="Python"
import os
import requests

workspace = requests.get(
    "https://api.muzekit.com/v1/workspace",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()
```

</CodeTabs>

`plan` is the editor's plan, the same for Test and Live keys. `live` is false when sessions are refused; `reason` says why (`no_plan`, `payment_failed`, `subscription_paused`). The numbers in `limits` are your plan's (the example below is only an example; see [Pricing](/pricing)). A `null` limit is unlimited. `period` is the current billing period and what it has used: sessions on https (Test and Live share one pool), free localhost sessions and API credits. Yearly plans get twelve months of pools up front.

## Examples

### Check the editor can open before you show it

Run this in a health check or when your admin page loads. When `plan.live` is false, [Create a session](/docs/api-reference/sessions-create) answers `402 plan_required`, so hide your "Open editor" button and tell your team why.

<CodeTabs>

```bash tab="cURL"
curl -s https://api.muzekit.com/v1/workspace \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq '{ live: .plan.live, reason: .plan.reason, status: .plan.status }'
```

```javascript tab="Node"
const { plan } = await fetch("https://api.muzekit.com/v1/workspace", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
}).then((r) => r.json());

if (!plan.live) {
  // "no_plan", "payment_failed" or "subscription_paused"
  alertTeam(`Muzekit editor is off: ${plan.reason}`);
}
```

```python tab="Python"
import os
import requests

plan = requests.get(
    "https://api.muzekit.com/v1/workspace",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()["plan"]

if not plan["live"]:
    # "no_plan", "payment_failed" or "subscription_paused"
    alert_team(f"Muzekit editor is off: {plan['reason']}")
```

</CodeTabs>

### Warn before this period's sessions run out

Compare `period.sessions_used` with `limits.sessions`. Past the pool, a small margin still opens; after it, new sessions answer `402 sessions_exhausted` until you add sessions in Billing or the next period starts. Editors already open keep working.

<CodeTabs>

```bash tab="cURL"
curl -s https://api.muzekit.com/v1/workspace \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq -r '.plan | if .limits.sessions == null then "unlimited"
      else "\(.period.sessions_used) of \(.limits.sessions) sessions" end'
```

```javascript tab="Node"
const { plan } = await fetch("https://api.muzekit.com/v1/workspace", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
}).then((r) => r.json());

const limit = plan.limits.sessions; // null is unlimited
const used = plan.period?.sessions_used ?? 0;
if (limit != null && used / limit >= 0.8) {
  alertTeam(`${used} of ${limit} sessions used; period ends ${plan.period.end}`);
}
```

```python tab="Python"
import os
import requests

plan = requests.get(
    "https://api.muzekit.com/v1/workspace",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()["plan"]

limit = plan["limits"]["sessions"]  # None is unlimited
used = (plan["period"] or {}).get("sessions_used", 0)
if limit is not None and used / limit >= 0.8:
    alert_team(f"{used} of {limit} sessions used; period ends {plan['period']['end']}")
```

</CodeTabs>

### Check API credits before a large batch

Live [renders](/docs/api-reference/renders-create) use API credits: 1 for each image or PDF page, and 1 a second of video. Test renders are free. Read what is left before you queue a [batch](/docs/api-reference/renders-batch) with a Live key; when credits run out, the rest of the batch fails with `api_credits_exhausted`.

<CodeTabs>

```bash tab="cURL"
curl -s https://api.muzekit.com/v1/workspace \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" \
  | jq '.plan.limits.api_credits - .plan.period.api_credits_used'
```

```javascript tab="Node"
const { plan } = await fetch("https://api.muzekit.com/v1/workspace", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
}).then((r) => r.json());

const limit = plan.limits.api_credits; // null is unlimited
const left = limit == null ? Infinity : limit - (plan.period?.api_credits_used ?? 0);
const needed = rows.length; // one single-page PNG per row
if (needed > left) throw new Error(`Needs ${needed} credits, ${left} left`);
```

```python tab="Python"
import math
import os
import requests

plan = requests.get(
    "https://api.muzekit.com/v1/workspace",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()["plan"]

limit = plan["limits"]["api_credits"]  # None is unlimited
used = (plan["period"] or {}).get("api_credits_used", 0)
left = math.inf if limit is None else limit - used
needed = len(rows)  # one single-page PNG per row
if needed > left:
    raise RuntimeError(f"Needs {needed} credits, {left} left")
```

</CodeTabs>

### Confirm a key's environment at deploy

A Test key in production shows your users Test data, and a Live key never opens the editor on localhost. Check `environment` (`test` or `live`) when your server starts.

<CodeTabs>

```bash tab="cURL"
curl -s https://api.muzekit.com/v1/workspace \
  -H "Authorization: Bearer $MUZEKIT_SECRET_KEY" | jq -r .environment
```

```javascript tab="Node"
const ws = await fetch("https://api.muzekit.com/v1/workspace", {
  headers: { Authorization: `Bearer ${process.env.MUZEKIT_SECRET_KEY}` },
}).then((r) => r.json());

if (process.env.NODE_ENV === "production" && ws.environment !== "live") {
  throw new Error(`MUZEKIT_SECRET_KEY is a ${ws.environment} key`);
}
```

```python tab="Python"
import os
import requests

ws = requests.get(
    "https://api.muzekit.com/v1/workspace",
    headers={"Authorization": f"Bearer {os.environ['MUZEKIT_SECRET_KEY']}"},
).json()

if os.environ.get("APP_ENV") == "production" and ws["environment"] != "live":
    raise RuntimeError(f"MUZEKIT_SECRET_KEY is a {ws['environment']} key")
```

</CodeTabs>

## Response

```json
{
  "object": "workspace",
  "id": "ws_…",
  "name": "Acme editor",
  "environment": "test",
  "region": "us",
  "plan": {
    "id": "…",
    "name": "…",
    "status": "active",
    "live": true,
    "reason": null,
    "interval": "monthly",
    "limits": {
      "members": 5,
      "sessions": 40000,
      "localhost_sessions": 10000,
      "api_credits": 25000,
      "ai_credits": 1000,
      "storage_gb": 100,
      "library_picks": 500,
      "origins": 2,
      "render_days": 90,
      "video_length": 300,
      "audio_tracks": 2
    },
    "period": {
      "start": "2026-11-23T10:00:00.000Z",
      "end": "2026-12-23T10:00:00.000Z",
      "sessions_used": 1280,
      "localhost_sessions_used": 410,
      "api_credits_used": 3150
    }
  }
}
```

| Limit | What it caps |
|---|---|
| `members` | Team seats in the dashboard |
| `sessions` | Editor sessions on https a period (Test and Live together) |
| `localhost_sessions` | Free localhost sessions a period (fair use) |
| `api_credits` | API credits a period ([renders](/docs/api-reference/renders-create)) |
| `ai_credits` | AI credits a period |
| `storage_gb` | Storage for uploads and brand files |
| `library_picks` | Ready-made templates you can add from the catalog |
| `origins` | Live domains the editor can be embedded on |
| `render_days` | Days a Live render's files are kept (`expires_at`) |
| `video_length` | Longest video render, in seconds |
| `audio_tracks` | Audio tracks a page of a video |
