# usage

> Spend: `noclick.usage(group_by="user")`, `noclick.Usage.series(group_by="agent")`, `noclick.Usage.limits()`, `noclick.Usage.set_account_cap(50)`, the account's ledger: `noclick.Usage.ledger()`, `noclick.Usage.charges()`, `noclick.Usage.billing()`, and the workstreams it's counted under (`noclick.Workstream`).

## noclick.usage

```python
noclick.usage(
    period='month', *, group_by=None, agent=None, user=..., client=None
) -> Usage
```

Spend for `period` (`"month"`), optionally split `group_by`
`"user"`, `"key"`, `"agent"`, `"project"` (each app), `"person"` (who each charge was for: the
person whose message, click or key started the work; the account's owner for work nobody else started) or
`"workstream"` (the line of work it belongs to, as the agent that started it named it), and narrowed to one
`agent` (an `Agent` or its id). Needs the `usage` scope.

Parameters:

- `period` (`str`, default `'month'`)
- `group_by` (`str | None`, default `None`)
- `agent` (`Any`, default `None`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Usage` The period's `total_usd` and, with `group_by`, one group per user, key, agent, app, person or
workstream that spent, largest first; a person's or workstream's group has its `name` (the `None`
workstream is work nobody named one for). Without `group_by`, `groups` is empty.

Usage:

See this month's spend per user:

```python
month = noclick.usage(group_by="user")
print(month.total_usd)
for group in month.groups:
    print(group.id, group.usd, group.events)
```

Inside `as_user`, it covers only that user:

```python
with noclick.as_user("user_42"):
    print(noclick.usage().total_usd)
```

What one agent cost this month, per user it talked to:

```python
support = noclick.Agent.from_name("support")
by_user = noclick.usage(group_by="user", agent=support)
print(by_user.total_usd, by_user["user_42"].usd)
```

What each app spent, to bill its user on:

```python
booking = noclick.Project.from_name("booking", user="user_42")
by_app = noclick.usage(group_by="project")
print(by_app[booking.id].usd)
```

Who on your team spent what:

```python
for person in noclick.usage(group_by="person").groups:
    print(person.name, person.usd)
```

What each line of work cost:

```python
for workstream in noclick.usage(group_by="workstream").groups:
    print(workstream.name or "(unnamed)", workstream.usd)
```

## noclick.Usage

```python
class Usage
```

What the account (or the current user) spent in `period`.

| Attribute | Type | Description |
| --- | --- | --- |
| `period` | `Any` |  |
| `total_usd` | `float` |  |
| `groups` | `list[UsageGroup]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### Usage.__getitem__

```python
usage[group_id] -> UsageGroup
```

The spend of one user, key, agent, app or person id in a grouped usage (`None` is the account's own).

Parameters:

- `group_id` (`str | None`, required)

Returns: `UsageGroup` That id's spend and event count; an id that spent nothing reads as `$0` with no events.

Usage:

```python
user = noclick.User.from_id("user_42")
month = noclick.usage(group_by="user")
print(month[user.id].usd)   # 0.0 for a user who spent nothing
```

### Usage.get

```python
usage.get(group_id, default=None) -> Any
```

The group of an id that spent something in a grouped usage, else `default`.

Parameters:

- `group_id` (`str | None`, required)
- `default` (`Any`, default `None`)

Returns: `Any` The `UsageGroup`, or `default` when the id spent nothing in the period.

Usage:

```python
support = noclick.Agent.from_name("support")
month = noclick.usage(group_by="agent")
if month.get(support.id) is None:
    print("support has cost nothing this month")
```

### Usage.series

```python
noclick.Usage.series(
    *, from_=None, to=None, interval=None, group_by=None, key=None, agent=None,
    user_filter=None, user=..., client=None
) -> UsageSeries
```

Daily spend between `from_` and `to` (default: the current month,
at most 92 days), one line per `group_by` `key`, `user`,
`agent`, `type`, `project` (an app), `person` (who each
charge was for, labelled with their name) or `workstream` (the line
of work it belongs to, labelled with its name). `key` is a key id or
prefix.

Parameters:

- `from_` (`Any`, default `None`)
- `to` (`Any`, default `None`)
- `interval` (`str | None`, default `None`)
- `group_by` (`str | None`, default `None`)
- `key` (`str | None`, default `None`)
- `agent` (`Any`, default `None`)
- `user_filter` (`Any`, default `None`): Which users a read covers: `noclick.ALL_USERS`, `noclick.NO_USER`, a `User`, or your id for one. It filters without acting as that user.
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `UsageSeries` The lines, largest first, each with its `label`, `total_usd` and daily `points`.
A day with no spend has no point.

Usage:

Chart this month's spend by what it was for:

```python
series = noclick.Usage.series(group_by="type")
for line in series.series:
    print(line.label, line.total_usd, [point.usd for point in line.points])
```

Or one agent's last 30 days, one line per user:

```python
from datetime import datetime, timedelta, timezone

support = noclick.Agent.from_name("support")
now = datetime.now(timezone.utc)
series = noclick.Usage.series(from_=now - timedelta(days=30), to=now, group_by="user", agent=support)
```

### Usage.ledger

```python
noclick.Usage.ledger(*, tz=None, client=None) -> UsageLedger
```

The account's ledger, as Settings → Usage reads it: every charge it was billed in its billing period and
the one before (its automations' runs, its chat with NoClick, a teammate's work it pays for, its keys' and
agents' calls), grouped by day in `tz` (an IANA zone, default UTC) and by every field a breakdown splits
by, with names for what they were for. For the signed-in owner and the account's own secret keys;
`noclick.usage()` reads only what its keys and agents spent.

Parameters:

- `tz` (`str | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `UsageLedger` The period, the fields groups are split by, the groups (each with its `key`, `day`, `usd` and
`fields`) and the `directory` naming what they name.

Usage:

```python
ledger = noclick.Usage.ledger(tz="Europe/London")
this_period = [g for g in ledger.groups if g.current and not g.own_resource]
print(sum(g.usd for g in this_period))
```

### Usage.charges

```python
noclick.Usage.charges(
    *, from_=None, to=None, keys=None, day=None, tz=None, cursor=None, limit=None,
    client=None
) -> UsageCharges
```

A page of the ledger's charges, newest first: the billing period's by default (`from_`, `to`),
narrowed to groups (`keys`: `LedgerGroup.key`) or a `day` (`YYYY-MM-DD`) in `tz`, up to `limit`
(500; default 50) a page.

Parameters:

- `from_` (`Any`, default `None`)
- `to` (`Any`, default `None`)
- `keys` (`list[str] | None`, default `None`)
- `day` (`str | None`, default `None`)
- `tz` (`str | None`, default `None`)
- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.
- `limit` (`int | None`, default `None`): Return at most this many.
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `UsageCharges` The charges, the runs they were recorded in, and `next`: pass it as `cursor` for the next page.

Usage:

```python
ledger = noclick.Usage.ledger()
calls = [g.key for g in ledger.groups if g.current and g.subtype == "voice/call"]
page = noclick.Usage.charges(keys=calls)
while page.next:
    page = noclick.Usage.charges(keys=calls, cursor=page.next)
```

### Usage.set_auto_top_up

```python
noclick.Usage.set_auto_top_up(
    *, threshold_usd, amount_usd, monthly_cap_usd, enabled=None, client=None
) -> dict[str, Any]
```

Change auto top-up, as the app's billing settings do (the signed-in owner's alone: it charges
their saved method): refill `amount_usd` when the balance falls below `threshold_usd`, at most
`monthly_cap_usd` a month, all whole dollars within the funds checkout's rules. `enabled` turns
it on (only with a method saved during a payment made with Refill automatically) or off; None keeps
it as it is.

Parameters:

- `threshold_usd` (`float`, required)
- `amount_usd` (`float`, required)
- `monthly_cap_usd` (`float`, required)
- `enabled` (`bool | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `dict[str, Any]` Auto top-up as it stands.

Usage:

```python
noclick.Usage.set_auto_top_up(threshold_usd=10, amount_usd=50, monthly_cap_usd=200)
```

### Usage.billing

```python
noclick.Usage.billing(*, client=None) -> UsageBilling | None
```

The money behind the ledger, as the credit gate reads it: the plan and its pools, the balance, funds
added and what's scheduled to be charged. One of the account's own keys reads those; the signed-in owner
also reads auto top-up and friends' credit.

Parameters:

- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `UsageBilling | None` The money, or None where nobody is billed.

Usage:

```python
money = noclick.Usage.billing()
if money is not None:
    print(money.balance_usd, money.plan.get("included_usd"))
```

### Usage.billing_details

```python
noclick.Usage.billing_details(*, organization_id=None, client=None) -> BillingDetails
```

The plan's Stripe subscription, an older plan's credit top-up subscription and the default card. The
signed-in owner's alone; `organization_id` names a team workspace they own or administer.

Parameters:

- `organization_id` (`str | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `BillingDetails` The `BillingDetails`.

Usage:

```python
details = noclick.Usage.billing_details()
if details.payment_method:
    print(details.payment_method["brand"], details.payment_method["last4"])
```

### Usage.billing_portal

```python
noclick.Usage.billing_portal(*, organization_id=None, client=None) -> str
```

A session on Stripe's customer portal, where the signed-in owner changes their plan, card and invoices:
open its URL within a few minutes. `organization_id` names a team workspace they own or administer.

Parameters:

- `organization_id` (`str | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `str` The portal's URL.

Usage:

```python
print(noclick.Usage.billing_portal())
```

### Usage.credits

```python
noclick.Usage.credits(*, organization_id=None, client=None) -> UsageCredits
```

What NoClick's balance meter shows: the included usage used and its cap, the balance, and whose pool it
is. `organization_id` names a team workspace you're in, whose work draws on its owner's pool.

Parameters:

- `organization_id` (`str | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `UsageCredits` The `UsageCredits`.

Usage:

```python
meter = noclick.Usage.credits()
print(meter.used, meter.limit, meter.period, meter.balance_usd)
```

### Usage.limits

```python
noclick.Usage.limits(*, client=None) -> UsageLimits
```

This month's spend of every capped key, user and agent (account principals), of
every app with a budget, and your account's own monthly cap.

Parameters:

- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `UsageLimits` Each capped key and user with its `cap` and `spent`, each budgeted agent with its
`budget`, `spent` and `subtree_spent`, each budgeted app (`projects`) with its
`budget` and `spent`, when the caps reset (`resets_at`), and the account's cap
(`account`), over its billing period.

Usage:

```python
limits = noclick.Usage.limits()
for cap in limits.users:
    print(cap.id, cap.spent, cap.cap)
for app in limits.projects:
    print(app.name, app.user_id, app.spent, app.budget)
print(limits.resets_at)
print(limits.account.cap_usd, limits.account.spent_usd)   # None, None while no cap is set
```

### Usage.set_account_cap

```python
noclick.Usage.set_account_cap(cap_usd, *, client=None) -> AccountCap
```

Set your account's monthly spending cap, in whole dollars; `None` removes it. Past it,
every call that costs money raises `noclick.SpendCapExceeded` until the billing period
resets. Your account's own keys lower the cap, or set one where there's none; raising or
removing it is your account's owner's (in Settings → Plan and billing in the NoClick app), so
from a key it raises `noclick.PermissionDenied` and changes nothing. Through MCP, and from an
agent on the word of the person whose message started its turn, a raise or a removal waits for
the owner's approval. Needs the `usage` scope.

Parameters:

- `cap_usd` (`int | None`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `AccountCap` The cap as it now stands, with what its billing period has spent and who set it (`set_by`).

Usage:

```python
cap = noclick.Usage.set_account_cap(50)
print(cap.cap_usd, cap.spent_usd, cap.resets_at)
```

## noclick.UsageGroup

```python
class UsageGroup
```

Spend of one user, key, agent, app, person or workstream (`id`) in the period. `name` is a person's
name, with `group_by="person"`, or a workstream's, with `group_by="workstream"`.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str | None` |  |
| `usd` | `float` |  |
| `events` | `int` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `name` | `str | None` |  |

## noclick.UsageSeries

```python
class UsageSeries
```

| Attribute | Type | Description |
| --- | --- | --- |
| `interval` | `str` |  |
| `from_` | `Any` |  |
| `to` | `Any` |  |
| `total_usd` | `float` |  |
| `series` | `list[UsageSeriesLine]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.UsageSeriesLine

```python
class UsageSeriesLine
```

One key, user, agent or usage type's spend over the period. `label` is
a key name (`Console` for the console key), your id for a user, an
agent name or a type label.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str | None` |  |
| `label` | `str | None` |  |
| `total_usd` | `float` |  |
| `events` | `int` |  |
| `points` | `list[UsagePoint]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.UsagePoint

```python
class UsagePoint
```

Spend in one interval starting at `t`.

| Attribute | Type | Description |
| --- | --- | --- |
| `t` | `Any` |  |
| `usd` | `float` |  |
| `events` | `int` |  |

## noclick.UsageLimits

```python
class UsageLimits
```

Every capped key, user and agent with this month's spend, every app with a budget, and your
account's own monthly cap.

| Attribute | Type | Description |
| --- | --- | --- |
| `period_start` | `Any` |  |
| `resets_at` | `Any` |  |
| `keys` | `list[KeyCap]` |  |
| `users` | `list[UserCap]` |  |
| `agents` | `list[AgentBudget]` |  |
| `projects` | `list[ProjectBudget]` | Each app with a `budget_usd_per_month`. |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `account` | `AccountCap | None` | Your account's monthly spending cap, over its billing period. |

## noclick.KeyCap

```python
class KeyCap
```

A capped key's spend this month.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str | None` |  |
| `cap` | `float | None` |  |
| `spent` | `float` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.UserCap

```python
class UserCap
```

A capped user's spend this month; `id` is your id for the user.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `cap` | `float | None` |  |
| `spent` | `float` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.AgentBudget

```python
class AgentBudget
```

A budgeted agent's spend this month; `subtree_spent` adds the agents it spawned.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str | None` |  |
| `budget` | `float | None` |  |
| `spent` | `float` |  |
| `subtree_spent` | `float` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.ProjectBudget

```python
class ProjectBudget
```

A budgeted app's spend this month: `id` and `name` are the app's, `user_id` the
user it belongs to (None for your account's own).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str | None` |  |
| `user_id` | `str | None` |  |
| `budget` | `float | None` |  |
| `spent` | `float` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.UsageLedger

```python
class UsageLedger
```

The account's ledger: every charge it was billed in its billing period (`period_start` to `period_end`)
and the one before (from `previous_start`), grouped; `directory` names what the groups name, by kind
(`workflows`, `agents`, `people`, `projects`, `keys`…) and id.

| Attribute | Type | Description |
| --- | --- | --- |
| `period_start` | `Any` |  |
| `period_end` | `Any` |  |
| `previous_start` | `Any` |  |
| `fields` | `list[str]` |  |
| `groups` | `list[LedgerGroup]` |  |
| `directory` | `dict[str, dict[str, Any]]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.LedgerGroup

```python
class LedgerGroup
```

One group of the account's ledger: its charges in one period (this billing period or the one before), one
day (in the zone the ledger was read in) and one set of breakdown fields, added up. `key` lists its charges
(`Usage.charges(keys=[group.key])`); `subtype` is what was charged for (a model's id, or a service like
`voice/call`); `own_resource` means nobody was charged (the account's own key or resource); `fields` is every
breakdown field by name (`UsageLedger.fields`): the automation, agent step, person, app or key it names.

| Attribute | Type | Description |
| --- | --- | --- |
| `key` | `str` |  |
| `current` | `bool` |  |
| `day` | `str` |  |
| `usage_type` | `str` |  |
| `subtype` | `str` |  |
| `unit` | `str` |  |
| `own_resource` | `bool` |  |
| `charges` | `int` |  |
| `quantity` | `float` |  |
| `usd` | `float` |  |
| `fields` | `dict[str, Any]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.UsageCharges

```python
class UsageCharges
```

A page of the ledger's charges, newest first, with the runs they were recorded in by run id; pass `next`
back as `cursor` for the next page (None at the end).

| Attribute | Type | Description |
| --- | --- | --- |
| `charges` | `list[LedgerCharge]` |  |
| `runs` | `dict[str, dict[str, Any]]` |  |
| `next` | `str | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.LedgerCharge

```python
class LedgerCharge
```

One charge in the account's ledger; `key` is its group's, `metadata` what it was for (the automation,
agent step and run, the number, sender, key or app it names).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `at` | `Any` |  |
| `usage_type` | `str` |  |
| `subtype` | `str` |  |
| `unit` | `str` |  |
| `quantity` | `float` |  |
| `usd` | `float` |  |
| `own_resource` | `bool` |  |
| `key` | `str` |  |
| `metadata` | `dict[str, Any]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.UsageBilling

```python
class UsageBilling
```

The money behind the ledger, as the credit gate reads it: the `plan` with its window and pools (included
usage, Free's daily share, an older plan's top-up), the balance (below zero is owed), funds added this period and
the plan's fee on them, and what's scheduled (`recurring`: a number's month, a connection's hours; `domains`
that renew soon). `auto_top_up` is the signed-in owner's alone, as friends' credit (in `raw`) is.

| Attribute | Type | Description |
| --- | --- | --- |
| `plan` | `dict[str, Any]` |  |
| `balance_usd` | `float` |  |
| `funds_usd` | `float` |  |
| `fees_usd` | `float` |  |
| `recurring` | `list[dict[str, Any]]` |  |
| `domains` | `list[dict[str, Any]]` |  |
| `auto_top_up` | `dict[str, Any] | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.BillingDetails

```python
class BillingDetails
```

The plan's Stripe `subscription` (`status`, `current_period_end`: when it renews, or ends when
`cancel_at_period_end`), an older plan's credit `topup_subscription` (also its `credits_per_month`,
`interval` and `subscription_id`) and the default card (`payment_method`: `brand`, `last4`,
`exp_month`, `exp_year`), each None where there's none.

| Attribute | Type | Description |
| --- | --- | --- |
| `subscription` | `dict[str, Any] | None` |  |
| `topup_subscription` | `dict[str, Any] | None` |  |
| `payment_method` | `dict[str, Any] | None` |  |

## noclick.UsageCredits

```python
class UsageCredits
```

The pool a workspace's work draws on, as NoClick's balance meter reads it, in credits: the included usage
`used` against `limit` in the `period` (`day` where the plan counts by day, else `month`), the month's
`monthly_used` against `monthly_cap`, and the dollar balance drawn after it. `pool_user_id` is whose pool it
is; `is_org_credits` when that's the owner of a team workspace you're in, not you.

| Attribute | Type | Description |
| --- | --- | --- |
| `used` | `float` |  |
| `limit` | `float | None` |  |
| `period` | `str` |  |
| `monthly_used` | `float | None` |  |
| `monthly_cap` | `float | None` |  |
| `balance_usd` | `float | None` |  |
| `tier` | `str | None` |  |
| `pool_user_id` | `str` |  |
| `is_org_credits` | `bool` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.Workstream

```python
class Workstream
```

A line of work your spend is counted under. An agent names one when it starts work (a child's task, a message
it hands another agent, an app's coding job; `Agent.spawn(workstream=)`), from your workstreams or a new name,
and every charge of that work, and of what it starts, belongs to it. A person renames one, or archives it once its
work is done: its charges still read under it, and it leaves the workstreams agents choose from until it's brought
back or an agent names it again.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` | As it was first written; matched whatever its case. |
| `spent_usd` | `float` | What it spent this month (a call acting for one of your users: that user's share). |
| `events` | `int` |  |
| `created_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `archived` | `bool` | Put away: out of the workstreams agents choose from, its charges still under it. |

### Workstream.list

```python
noclick.Workstream.list(*, archived=False, user=..., client=None) -> list[Workstream]
```

Your open workstreams (`archived=True`: the ones put away), most spent this month first, each with what
it spent (as `noclick.usage(group_by="workstream")` counts it). Needs the `usage` scope.

Parameters:

- `archived` (`bool`, default `False`)
- `user` (`Any`, default: the current user): Who the call acts for. Defaults to the user set by `noclick.as_user` (none: the account itself).
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[Workstream]` Each workstream's `id`, `name`, `spent_usd` and `events`. What work nobody named one for spent is
the `None` group of `noclick.usage(group_by="workstream")`.

Usage:

```python
for workstream in noclick.Workstream.list():
    print(workstream.name, workstream.spent_usd)
```

### Workstream.rename

```python
noclick.Workstream.rename(workstream, name, *, client=None) -> Workstream
```

Rename `workstream` (a `Workstream`, its name in any case, or its id) to `name`. Renamed onto
another workstream's name, it merges into that one: its charges so far read as that one's (none is
rewritten), and `raw["merged_from"]` names it. Your account's alone: a call acting for one of your users
can't. Needs the `usage` scope.

Parameters:

- `workstream` (`Any`, required)
- `name` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Workstream` The workstream it reads as now, without this month's spend (`spent_usd` 0; `Workstream.list()` reads
it).

Usage:

```python
noclick.Workstream.rename("website", "Bakery site")
noclick.Workstream.rename("Menu", "Bakery site")   # merges Menu into it
```

### Workstream.archive

```python
noclick.Workstream.archive(workstream, *, client=None) -> Workstream
```

Archive `workstream` (a `Workstream`, its name in any case, or its id) once its work is done: its
charges still read under it, and it leaves `Workstream.list()` (`archived=True` lists it) and the
workstreams agents choose from, until `unarchive` brings it back or an agent names it again. Your account's
alone. Needs the `usage` scope.

Parameters:

- `workstream` (`Any`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Workstream` The workstream, `archived`, without this month's spend.

Usage:

```python
noclick.Workstream.archive("Q3 launch")
```

### Workstream.unarchive

```python
noclick.Workstream.unarchive(workstream, *, client=None) -> Workstream
```

Bring an archived `workstream` back among your open ones. Your account's alone. Needs the `usage`
scope.

Parameters:

- `workstream` (`Any`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Workstream` The workstream, open again, without this month's spend.

Usage:

```python
noclick.Workstream.unarchive("Q3 launch")
```

## noclick.AccountCap

```python
class AccountCap
```

Your account's monthly spending cap: `cap_usd` (None while none is set) and, where one is set,
what its billing period has spent (`spent_usd`), when that period started and resets, and whether
it's `reached`: then every call that costs money raises `noclick.SpendCapExceeded`. `set_by`
says who set it last (None: nobody has, or only NoClick's own hold on an account no person has
claimed).

| Attribute | Type | Description |
| --- | --- | --- |
| `cap_usd` | `float | None` |  |
| `spent_usd` | `float | None` |  |
| `period_start` | `Any` |  |
| `resets_at` | `Any` |  |
| `reached` | `bool` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `set_by` | `CapChange | None` |  |

## noclick.CapChange

```python
class CapChange
```

Who set your account's monthly cap last: `by` (`owner`, signed in; `key`, one of your account's
keys; `connection`, an MCP connection; `agent`, an agent's turn; `assistant`, your NoClick
assistant), the person it was for (`responsible_user_id`: the person whose message started the
agent's turn, the person a connection acts for, else your account's owner), the key it was made with,
the connection (`grant_id`) and agent (`agent_id`, its `turn_id`) it came through and their name
(`client`), the approval a raise ran on, the cap before and after, and when.

| Attribute | Type | Description |
| --- | --- | --- |
| `by` | `str` |  |
| `responsible_user_id` | `str | None` |  |
| `key_id` | `str | None` |  |
| `grant_id` | `str | None` |  |
| `agent_id` | `str | None` |  |
| `turn_id` | `str | None` |  |
| `client` | `str | None` |  |
| `approval_id` | `str | None` |  |
| `cap_before_usd` | `float | None` |  |
| `cap_after_usd` | `float | None` |  |
| `at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
