# API reference: workspace

The signed-in caller's workspace: the activity feed and one cheap overview for the workspace rail and the Inbox header. The feed is the audit log, filtered to what the caller could already see.

## GET /v1/activity

`listActivity` · scope `key:read` · The activity feed: what happened to what you can see

The audit log as a feed a person can read, newest first. A row is visible to the caller in two cases:

- the resource's own read rule already grants it to the caller. That is, the caller is its owner user, a member of its owner org, or its creator (runs, rollouts, plans, coach sessions).
- the caller took the action

A row about a repo is shown on that second ground only while the caller can still read the repo. Public repos grant nothing here. This is the caller's own feed. It is not a public timeline.

Visibility is part of the query. It is not applied as a filter over a page. So nothing about a resource the caller cannot see reaches the page arithmetic, including a count.

`summary` is one sentence the UI can show verbatim. `cost_usd` is set only on the row where a cost was incurred. That is the row for a finished run, a coach session, a planner decision or a closed endpoint session. So summing a page never counts a dollar twice. `actor.kind` says which credential wrote the row. `actor.agent` is `planner` only when a plan's planner took the action. An API key is reported as a key, whoever held it.

Parameters:

- `actor_kind` (query): `person` (a web session), `key` (an API key), `system` (the hub on its own), or `agent`. `agent` covers the rows a plan's planner took, whichever credential it acted as.
- `resource_type` (query)
- `since` (query): Only rows at or after this instant (RFC 3339).
- `owner` (query): Only rows about resources owned by this handle (user or org). An unknown handle is an empty page, not a 404.
- `limit` (query): Page size.
- `cursor` (query): Opaque cursor from the previous page's `next_cursor`.

Responses:

- `200`: A page of activity, newest first.
- `401`: Missing or invalid credentials.
- `422`: Request failed validation.

## GET /v1/me/overview

`getMyOverview` · scope `key:read` · Counts for the workspace rail and the Inbox header

One cheap call that returns:

- the approval requests awaiting a person on devices the caller can see (the ten newest with their checks)
- active runs, running endpoints and active plans
- devices online
- today's model spend (coach sessions + planner decisions since UTC midnight), with a sentence saying how it was computed

Every count is a query over the same visibility rule as the list endpoint it summarises. So each count can be cross-checked against that list.

Responses:

- `200`: The caller's overview.
- `401`: Missing or invalid credentials.

## GET /v1/me/usage

`getMyUsage` · scope `key:read` · What an account spent over a time range

The costs the hub recorded for one account over a time range (UTC), in four lines:

- the hub's agent (its AI model calls and its sandbox), against the monthly agent allowance
- Lucen cloud CPU work (hosted robot and model checks, CPU training runs, sim tests), against the monthly CPU allowance
- Lucen cloud GPU work (training runs and inference sessions on a GPU), which has no allowance
- other AI model calls (Coach advice, planner decisions)

Each line lists what spent it, the largest first. So every dollar links to the run, sim test, check or session behind it. Every number is a sum of the ledger's rows. The account is the caller's own, or an organization the caller is a member of (`owner`). Any other handle is `404`.

`range` picks the window. `month` is one calendar month, the default. `today`, `7d` and `30d` are whole UTC days that end with today. `group_by` adds `groups`, the same costs summed another way. The groups add up to `total_usd`. `spend_cap` says where the calendar month stands against the account's cap.

`buckets` splits the same costs over time. A bucket is one hour for `today` and one day otherwise. They run from the start of the range up to the bucket that holds now; a past range has every bucket. The buckets add up to `total_usd`, each bucket's `lines` to its own total, and its `groups` likewise when `group_by` is set. `now` is where the account stands at this moment, whatever `range` is. It holds this calendar month's allowances, this month's Lucen cloud spend as the cap counts it, and the hosted jobs that are queued or running, each with its rate.

Parameters:

- `range` (query): The window: `month` (a calendar month, see `month`), `today`, `7d` or `30d`. A day starts at 00:00 UTC.
- `month` (query): The calendar month as `YYYY-MM`, in UTC, for `range=month`. The current month when absent. With any other range it is `422`.
- `owner` (query): Your own handle (the default) or the slug of an organization you are a member of.
- `group_by` (query): Sum the costs by hardware (`gpu`), by the robot they were for (`robot`), by the API key that started them (`key`), or by the person who started them (`member`).
- `limit` (query): Items listed per line, the largest first. `item_count` counts them all. Groups always sum every item.

Responses:

- `200`: The account's costs over the range.
- `401`: Missing or invalid credentials.
- `404`: Resource not found (or hidden from the caller).
- `422`: Request failed validation.

## PUT /v1/me/spend-cap

`setSpendCap` · scope `session` · Set an account's monthly spend cap

Sets a monthly cap on an account's Lucen cloud spend: hosted training runs, sim tests, robot and model checks, and endpoint sessions.

In `warn` mode the hub warns at 50, 75 and 100 percent. In `stop` mode it also refuses new hosted work once the month's recorded spend reaches the cap. The refusal is `429` until the month ends. Work that is already running keeps running.

Billing is off during beta, so the cap applies to the costs the hub records. Only a signed-in person sets a cap, so no key can raise its own. An organization's cap is set by its owners.

Parameters:

- `owner` (query): Your own handle (the default) or the slug of an organization you own.

Request body: `application/json`, required.

Responses:

- `200`: The cap, and where this month stands against it.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `422`: Request failed validation.

## DELETE /v1/me/spend-cap

`deleteSpendCap` · scope `session` · Remove an account's spend cap

Removes the account's monthly spend cap. Hosted work is then limited only by the allowances. Removing a cap that is not set is a no-op.

Parameters:

- `owner` (query): Your own handle (the default) or the slug of an organization you own.

Responses:

- `204`: The cap is gone.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).

## GET /v1/model-keys

`listModelKeys` · scope `key:read` · List your workspaces' AI model keys

Lists your own workspace and every organization you own. Each entry says where an AI model call for that workspace is billed now.

A stored key is shown by its status only. That is its prefix and last four characters, when it was checked and last used, the last error, the monthly cap and this month's spend.

`feature: off` means this hub cannot store keys. It has no encryption key configured.

Responses:

- `200`: Your workspaces, yours first.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).

## PUT /v1/model-keys/{owner}

`setModelKey` · scope `session` · Add or replace a workspace's key for one vendor

Stores an API key for one vendor (`provider`, Anthropic by default) for a workspace. Every AI model call to that vendor made for the workspace then uses it, and is not charged for the model.

The hub checks the key first with one free call to the vendor. A key the vendor refuses is `422`, naming the vendor's error. Nothing is stored then. `502` means the vendor could not be reached.

The key is encrypted at rest. Responses show its prefix and last four characters only.

`monthly_cap_usd` caps what the workspace's model calls may record in a calendar month (UTC). Leave it out to keep the stored cap, or send `null` to remove it. Leave out `key` to change only the cap of the stored key.

Only a signed-in person may add or remove a key, so no API key can plant a credential that spends. An organization's key is set by its owners. `503` means this hub has no encryption key configured.

Parameters:

- `owner` (path, required): Your own handle, or the slug of an organization you own.

Request body: `application/json`, required.

Responses:

- `200`: The workspace, with the key's status.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `422`: Request failed validation.
- `502`: The vendor could not be reached to check the key. Nothing was stored.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.

## DELETE /v1/model-keys/{owner}

`deleteModelKey` · scope `session` · Remove a workspace's key for one vendor

Deletes the workspace's stored key for the vendor, Anthropic by default. Its AI model calls to that vendor then answer `402` until a key is added again, unless the hub's own key serves the workspace. Removing a key that is not there changes nothing.

Parameters:

- `owner` (path, required): Your own handle, or the slug of an organization you own.
- `provider` (query): The vendor whose key to remove.

Responses:

- `204`: The key is gone.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).

## GET /v1/connections

`listConnections` · scope `key:read` · List your workspaces' GitHub and Hugging Face connections

Lists your own workspace and every organization you own. Each entry shows its GitHub connection and its Hugging Face connection, or null.

A GitHub connection is an installation of the hub's GitHub App. It reads the repos the person chose, and nothing else. The hub uses it to link a run's commit and to compare commits. A Hugging Face connection is a token, stored encrypted. The hub uses it to import private repos and to push policies and datasets. A token is shown by its last four characters only.

`github.available` and `huggingface.available` say whether this hub is set up for each. `connect_url` is where the Connect button goes.

Responses:

- `200`: Your workspaces, yours first.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).

## PUT /v1/connections/{owner}/{provider}

`setConnection` · scope `session` · Connect GitHub or Hugging Face to a workspace

**GitHub.** Send `installation_id` and `code` from GitHub's redirect after the App was installed. The hub exchanges `code` for the person's own GitHub authorization. It then checks that this person can see the installation, so no one can claim another account's installation. The person's GitHub token is not kept. The hub keeps the installation id, the account and the repo list.

**Hugging Face.** Send `code` and `redirect_uri` from "Sign in with Hugging Face", or paste a token as `token`. The hub checks the token with Hugging Face and stores it encrypted.

**Modal.** Send a Modal token as `token_id` and `token_secret`, and the `environment` to run in. The hub checks the token with Modal and stores it encrypted. Jobs with `executor: own_modal` then run in that workspace. Deploy the job functions there first.

A provider that refuses is `422` with its own reason. `502` means it could not be reached. `503` means this hub is not set up for it. Nothing is stored then. Only a signed-in person may connect or disconnect. An organization's connections are set by its owners.

Parameters:

- `owner` (path, required): Your own handle, or the slug of an organization you own.
- `provider` (path, required)

Request body: `application/json`, required.

Responses:

- `200`: The workspace, with its connections.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).
- `409`: State conflict (duplicate handle/slug, wrong repo kind, terminal job, ...).
- `422`: Request failed validation.
- `502`: GitHub or Hugging Face could not be reached. Nothing was stored.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.

## DELETE /v1/connections/{owner}/{provider}

`deleteConnection` · scope `session` · Disconnect GitHub or Hugging Face from a workspace

Forgets the connection. A Hugging Face token is wiped. The GitHub App stays installed on GitHub until you remove it there (`manage_url`). Runs keep their archived code, so their diffs still work. Removing a connection that is not there changes nothing.

Parameters:

- `owner` (path, required): Your own handle, or the slug of an organization you own.
- `provider` (path, required)

Responses:

- `204`: The connection is gone.
- `401`: Missing or invalid credentials.
- `403`: Authenticated but not allowed (visibility, membership or scope).
- `404`: Resource not found (or hidden from the caller).

## POST /v1/github/webhook

`receiveGithubWebhook` · scope `none` · GitHub's events for the hub's GitHub App

GitHub calls this when the App is removed, suspended or given other repos. The hub checks the `X-Hub-Signature-256` header against the App's webhook secret first. A wrong signature is `401` and changes nothing. A removed installation is forgotten everywhere. A changed repo list is read again. Other events are acknowledged and ignored.

Request body: `application/json`, required.

Responses:

- `204`: Received.
- `401`: Missing or invalid credentials.
- `503`: A service this endpoint needs is not configured in this deployment. The API boots with zero secrets. An endpoint that needs one says so instead of returning a stack trace.
