# ConnectedApp

> Connected apps: the MCP clients your account's owner allowed to connect, and NoClick's own connections (its assistant's), each a caller of its own with the bounds set for it. Only the owner, signed in, lists, revokes and restores them.

## noclick.ConnectedApp

```python
class ConnectedApp
```

One connection, revoked or not: the client (`client_name`, and `client_id`, `noclick:` for one NoClick
makes itself), the capability groups it holds (`read`, `build`, `deploy`, `spend`, `delete`), its monthly
cap and the amount under which a purchase it makes goes through unasked (`None`: none of its own, and it asks
before every one), what it spent this month, and the user it acts for (`None`: your account). `restorable`:
once revoked, the owner may turn it back on as it was (a connection NoClick makes); a client a person connected
connects again instead.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `client_name` | `str` |  |
| `client_id` | `str` |  |
| `client_uri` | `str | None` |  |
| `capabilities` | `list[str]` |  |
| `spend_cap_usd_per_month` | `float | None` |  |
| `auto_approve_under_usd` | `float | None` |  |
| `spent_usd_this_month` | `float` |  |
| `user_id` | `str | None` |  |
| `restorable` | `bool` |  |
| `created_at` | `datetime | None` |  |
| `last_used_at` | `datetime | None` |  |
| `revoked_at` | `datetime | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `revoked` | `bool` |  |

### ConnectedApp.list

```python
noclick.ConnectedApp.list(*, limit=None, client=None) -> list[ConnectedApp]
```

Every connection, newest first, revoked ones too (or the first `limit`). The account's signed-in owner's
alone: a key, a user's session, an app's code or an MCP connection gets `noclick.PermissionDenied`.

Parameters:

- `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: `list[ConnectedApp]` Each `ConnectedApp`.

Usage:

```python
for app in noclick.ConnectedApp.list():
    print(app.client_name, app.capabilities, "revoked" if app.revoked else "live")
```

### ConnectedApp.revoke

```python
noclick.ConnectedApp.revoke(connected_app_id, *, client=None) -> ConnectedApp
```

End a connection: its next call fails. Revoking one again changes nothing. The signed-in owner's alone.

Parameters:

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

Returns: `ConnectedApp` It, with `revoked_at` set.

Usage:

```python
noclick.ConnectedApp.revoke(app.id)
```

### ConnectedApp.restore

```python
noclick.ConnectedApp.restore(connected_app_id, *, client=None) -> ConnectedApp
```

Turn a revoked connection NoClick makes (`restorable`: its assistant's) back on, as it was when revoked:
its groups, cap, auto-approve amount and own approval settings, never wider. Its next call works; restoring a
live one changes nothing. A client a person connected raises `noclick.Conflict` (it connects again, as a new
connection). The signed-in owner's alone: a key, an app's code, an MCP connection or an agent gets
`noclick.PermissionDenied`.

Parameters:

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

Returns: `ConnectedApp` It, live (`revoked_at` is `None`).

Usage:

```python
[assistant] = [a for a in noclick.ConnectedApp.list() if a.restorable and a.revoked]
noclick.ConnectedApp.restore(assistant.id)
```
