# 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.

## ConnectedApp

```typescript
class ConnectedApp
```

One connection, revoked or not: the client (`clientName`, and `clientId`, `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 (null: none of its own, and it asks before every one), what it spent
this month, and the user it acts for (null: 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` | `string` |  |
| `clientName` | `string` |  |
| `clientId` | `string` |  |
| `clientUri` | `string | null` |  |
| `capabilities` | `string[]` |  |
| `spendCapUsdPerMonth` | `number | null` |  |
| `autoApproveUnderUsd` | `number | null` |  |
| `spentUsdThisMonth` | `number` |  |
| `userId` | `string | null` |  |
| `restorable` | `boolean` |  |
| `createdAt` | `Date | null` |  |
| `lastUsedAt` | `Date | null` |  |
| `revokedAt` | `Date | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `revoked` | `boolean` |  |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

### ConnectedApp.list

```typescript
static list(
  options?: { limit?: number; client?: NoClick },
): Promise<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 rejects with `PermissionDenied`.

    for (const app of await ConnectedApp.list()) console.log(app.clientName, app.revoked ? "revoked" : "live");

Parameters:

- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Each `ConnectedApp`.

### ConnectedApp.revoke

```typescript
static revoke(
  connectedAppId: string,
  options?: { client?: NoClick },
): Promise<ConnectedApp>
```

End a connection: its next call fails. Revoking one again changes nothing. The signed-in owner's alone. Resolves
to it, with `revokedAt` set.

    await ConnectedApp.revoke(app.id);

Parameters:

- `connectedAppId` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: It, with `revoked_at` set.

### ConnectedApp.restore

```typescript
static restore(
  connectedAppId: string,
  options?: { client?: NoClick },
): Promise<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 rejects with `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 rejects with `PermissionDenied`.
Resolves to it, live (`revokedAt` null).

    const assistant = (await ConnectedApp.list()).find((a) => a.restorable && a.revoked);
    if (assistant) await ConnectedApp.restore(assistant.id);

Parameters:

- `connectedAppId` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

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