# Account

> Your account: its plan, balance, month's spend, counts, limits and defaults (`Account.get`), changing its defaults (`update`), the account at a glance with what waits and what failed (`status`), the public endpoints a publishable key may call, what an id or key prefix names (`resolve`), and a one-tap payment link for its owner.

## noclick.Account

```python
class Account
```

The account at a glance (`GET /v1/account`): its plan's `plan_tier`, `balance` (`remaining_usd`,
`None` when it can't be read, never 0), this `month`'s spend, how many of each thing it has (`counts`), its
`limits` and `features`, its `default_region` and the default a paused user is told (`spending_paused`),
and what the platform offers (`scopes`, `explicit_scopes`). The signed-in owner also reads `email`,
`spend_cap` and `console_key_id`; one of the account's own secret keys reads the rest.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `email` | `str | None` |  |
| `owner` | `dict[str, str] | None` | Who owns it, as NoClick knows them (`name`, `email`, `phone`, each only when known): the signed-in owner's view only. |
| `plan_tier` | `str | None` |  |
| `balance` | `dict[str, Any]` |  |
| `month` | `dict[str, Any]` |  |
| `spend_cap` | `dict[str, Any] | None` |  |
| `counts` | `dict[str, int]` |  |
| `limits` | `dict[str, int]` |  |
| `features` | `dict[str, bool]` |  |
| `default_region` | `str | None` |  |
| `spending_paused` | `PausedSpendingDefault | None` |  |
| `console_key_id` | `str | None` |  |
| `scopes` | `list[str]` | What a key with every scope (`*`) holds. |
| `explicit_scopes` | `list[str]` | The scopes a key holds only when it names them. |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### Account.get

```python
noclick.Account.get(*, client=None) -> Account
```

Read the account: the signed-in owner, or one of the account's own secret keys acting for it (a key acting
for one of its users gets `noclick.PermissionDenied`).

Parameters:

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

Returns: `Account` The account.

Usage:

```python
account = noclick.Account.get()
print(account.plan_tier, account.balance["remaining_usd"])
```

### Account.update

```python
noclick.Account.update(
    *, default_region=..., spending_paused=..., spend_cap_usd=..., client=None
) -> Account
```

Change the account's defaults: only the fields given; `None` clears one. `default_region` is the region
new resources take when a call names none; `spending_paused` what a paused user is told without a message
(a `PausedSpendingDefault`); `spend_cap_usd` the monthly spending cap in whole dollars. The signed-in
owner's alone.

Parameters:

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

Returns: `Account` The account as it is now.

Usage:

```python
noclick.Account.update(default_region="eu", spend_cap_usd=200)
```

### Account.status

```python
noclick.Account.status(*, client=None) -> AccountStatus
```

The account at a glance, as the key calling sees it: which account (or which of its users the key acts
for), its plan, balance, this month's spend against its caps, approvals waiting on a person, what failed in
the last day and what ran last. A user's session is refused.

Parameters:

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

Returns: `AccountStatus` The status.

Usage:

```python
status = noclick.Account.status()
print(status.account.get("name") or status.account["id"], status.balance.get("remaining_usd"))
```

### Account.public_endpoints

```python
noclick.Account.public_endpoints(*, client=None) -> list[PublicEndpoint]
```

What a publishable key may list: the account's public endpoints (a shared agent's page, a published
workflow), each by `kind` and `id`. The signed-in owner's alone.

Parameters:

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

Returns: `list[PublicEndpoint]` Each `PublicEndpoint`.

Usage:

```python
for endpoint in noclick.Account.public_endpoints():
    print(endpoint.kind, endpoint.name, endpoint.url)
```

### Account.resolve

```python
noclick.Account.resolve(ref, *, client=None) -> ObjectRef
```

What `ref` names in the account: an object's id, a key's prefix (`nk_live_ab12…`) or one of your users'
ids. Nothing it names raises `noclick.NotFound`. The signed-in owner's alone.

Parameters:

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

Returns: `ObjectRef` Its `type` and `id`, and the user it belongs to.

Usage:

```python
found = noclick.Account.resolve("nk_live_ab12")
print(found.type, found.id)
```

### Account.payment_link

```python
noclick.Account.payment_link(
    *, kind='funds', amount_usd=None, plan=None, billing_period=None,
    credits_per_month=None, client=None
) -> PaymentLink
```

A one-tap link that pays for the account, made for its owner to open: funds for its balance
(`amount_usd`, whole dollars; the plan's fee is paid with them), or a `plan` to move to. Opening it needs
no sign-in, so only the signed-in owner and the account's assistant make one. Its operation
(`operation_id`) succeeds once they've paid; the same purchase asked for again while its link is open
answers that link.

Parameters:

- `kind` (`str`, default `'funds'`)
- `amount_usd` (`int | None`, default `None`)
- `plan` (`str | None`, default `None`)
- `billing_period` (`str | None`, default `None`)
- `credits_per_month` (`int | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `PaymentLink` The link.

Usage:

```python
link = noclick.Account.payment_link(amount_usd=20)
print(link.price_usd, link.url)
```

## noclick.AccountStatus

```python
class AccountStatus
```

The account at a glance (`Account.status`): `account` (its `id`, `name`, `email`, or `acting_for`:
the user a key acts for), `user_id`, its `plan`, `balance`, `month`, `caps` with what each spent, the
approvals waiting on a person (`approvals_pending`), what failed in the last day (`failing`) and what ran
last (`operations`).

| Attribute | Type | Description |
| --- | --- | --- |
| `account` | `dict[str, Any]` |  |
| `user_id` | `str | None` |  |
| `plan` | `dict[str, Any] | None` |  |
| `balance` | `dict[str, Any]` |  |
| `month` | `dict[str, Any]` |  |
| `caps` | `list[dict[str, Any]]` |  |
| `approvals_pending` | `list[dict[str, Any]]` |  |
| `failing` | `list[dict[str, Any]]` |  |
| `operations` | `dict[str, Any]` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.ObjectRef

```python
class ObjectRef
```

What `Account.resolve` found: the object's `type` and `id`, and the user it belongs to (`None`: the
account).

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

## noclick.PausedSpendingDefault

```python
class PausedSpendingDefault
```

What a paused user is told when a pause names no message (`message`), and the button with it (`action`:
`{"label", "url"}`).

| Attribute | Type | Description |
| --- | --- | --- |
| `message` | `str | None` |  |
| `action` | `dict[str, str] | None` |  |

## noclick.PaymentLink

```python
class PaymentLink
```

A payment link (`Account.payment_link`): what it buys (`label`), what checkout charges (`price_usd`), its
`url`, when it lapses, and its operation.

| Attribute | Type | Description |
| --- | --- | --- |
| `kind` | `str` |  |
| `label` | `str` |  |
| `price_usd` | `float` |  |
| `url` | `str` |  |
| `expires_at` | `datetime | None` |  |
| `operation_id` | `str | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.PublicEndpoint

```python
class PublicEndpoint
```

Something the owner made public that a publishable key may call; `name` and `url` are `None` once it
stopped being public.

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