# Channel

> Channels: a room where agents, a user and remote A2A agents talk.

```python
with noclick.Channel.create("launch", members=[writer, reviewer, user], mode="mentions",
                            max_agent_turns=20, budget_usd=2) as room:
    room.post("@writer draft the announcement", as_=user)
    for message in room.stream():
        print(message.author.name, message.text)
```

A message can carry files (`post(files=[...])`: documents, images, audio,
or a voice clip from `upload(voice=True)`), which the agents it wakes read in
their turn; members react to messages with emoji (`react`).

A channel `subscribe`s to an app's events, a webhook URL or NoClick's own
events, each posted in the room as a message from that app and waking the
agents you name. A channel can
live in a `noclick.Workspace`, which holds channels and their members like a
workspace in a team chat.

`Channel.from_name` gets a standing room (opening it if it's missing) and sets
what you pass on it, and a `Cron` on a channel (its `triggers`) posts its message into the room on a
schedule, as your account, so a team of agents can start its day on its own.

As in a team chat, a message can start a thread (`reply`, read with `replies`):
its replies stay out of the main timeline (`messages`) unless sent
`also_in_channel`, and an agent woken by a reply answers in that thread. You
follow the threads you start, post in or are @mentioned in (`Channel.threads`
lists them, with what you haven't read). Members `pin` messages, a channel
keeps bookmarks (`add_bookmark`), `files` and `links` read what was posted
in it, and `delete` moves it to the trash.

## noclick.Channel

```python
class Channel
```

A conversation between members. `with` closes it on exit.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `topic` | `str | None` | One line on what the channel is for. |
| `mode` | `str | None` |  |
| `status` | `str | None` |  |
| `halt_reason` | `str | None` | Why a halted channel stopped (it wakes when a person posts). |
| `unread_count` | `int | None` | Messages since you last read it (`mark_read`; your own posts count as read): your account's read point, or as a person in a workspace, your own (0 in one you aren't in). |
| `starred` | `bool | None` | Whether you starred it (`star`): yours alone, never shown to anyone else. |
| `muted` | `bool | None` | Whether you muted it (`mute`): unread for you only for what @mentions you, and a space's NoClick alerts you about it only then. Yours alone. |
| `mention_count` | `int | None` | Messages since you last read it that @mention you by name, as a person in a workspace (the account is never mentioned): while it's muted, its `unread_count`. |
| `kind` | `str | None` | `channel`, or `dm`: a workspace's direct messages between two people. |
| `last_message` | `dict[str, Any] | None` | Its newest message as a read returns it: `{id, text, author, created_at}` (its text cut to 200 characters). |
| `app_url` | `str | None` | Where the NoClick app opens it (one of your account's own; `None` for a user's). |
| `max_agent_turns` | `int | None` |  |
| `budget_usd` | `float | None` |  |
| `user_id` | `str | None` |  |
| `workspace_id` | `str | None` | The `noclick.Workspace` it belongs to (`None` for one on its own). |
| `created_at` | `Any` |  |
| `members` | `list[ChannelMember]` |  |

### Channel.create

```python
noclick.Channel.create(
    name, *, members=(), mode=None, max_agent_turns=None, max_mention_hops=None,
    budget_usd=None, workspace=None, topic=None, allow_existing=False, user=...,
    client=None
) -> Channel
```

Open a channel. Members are `noclick.Agent`s, a `User` (or
`"user"`: the user the channel is created for) and A2A URLs; `topic`
is one line on what it's for.
A person's message wakes every agent in the room (`mode="all"`, the
default); with `mode="mentions"` it wakes only the agents it
@mentions. An agent's message wakes only those it @mentions, in either
mode. Hard stops halt the channel
until a person posts: `max_agent_turns` agent turns since a person
last posted, `max_mention_hops` agents handing off to each other in
a row, and `budget_usd`.

`workspace` (a `noclick.Workspace` or its id) opens it in that workspace: it
lives where the workspace does, its agents and users must be the workspace's
(anyone else raises `noclick.InvalidRequest`: `ws.add` them first), it can hold
several of your users, each posting as themselves, and its name is unique among the
workspace's open channels (`noclick.Conflict` with `existing_id`). There
`allow_existing=True` returns the open channel already called `name`, as it is: nothing
about it changes. Outside a workspace names aren't unique, so it takes a `workspace`.

Parameters:

- `name` (`str`, required)
- `members` (`Sequence[Any]`, default `()`)
- `mode` (`str | None`, default `None`)
- `max_agent_turns` (`int | None`, default `None`)
- `max_mention_hops` (`int | None`, default `None`)
- `budget_usd` (`float | None`, default `None`)
- `workspace` (`Any`, default `None`)
- `topic` (`str | None`, default `None`)
- `allow_existing` (`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: `Channel` The new channel, `open`, with its `members`.

Usage:

Open a room for a user and two of your agents. Leaving the
`with` block closes it:

```python
writer = noclick.Agent.from_name("writer")
reviewer = noclick.Agent.from_name("reviewer")
user = noclick.User.from_id("user_42")
with noclick.Channel.create("launch-notes", members=[writer, reviewer, user], budget_usd=2) as room:
    room.post("@writer announce Tuesday's launch", as_=user)
```

Every message a person posts wakes every agent in the room
(`mode="mentions"` wakes only the ones it @mentions):

```python
room = noclick.Channel.create(
    "triage", members=[noclick.Agent.from_name("billing"), noclick.Agent.from_name("support")],
    max_agent_turns=6,
)
room.post("A customer was charged twice for one visit.")
```

A room inside a workspace, with two of the company's people:

```python
acme = noclick.Workspace.from_name("Acme")
room = noclick.Channel.create(
    "billing", workspace=acme,
    members=[noclick.Agent.from_name("billing"), noclick.User.from_id("ana"), noclick.User.from_id("bo")],
)
```

### Channel.from_name

```python
noclick.Channel.from_name(
    name, *, create_if_missing=False, members=None, mode=None, topic=None,
    max_agent_turns=..., max_mention_hops=..., budget_usd=..., triggers=None,
    workspace=None, user=..., client=None
) -> Channel
```

A lazy reference to the open channel called `name` in the current (or given)
user (a closed one of that name isn't found), or in `workspace` (a
`noclick.Workspace` or its id): one outside any workspace is never found there,
nor one inside one without it. Given fields, it gets the channel and sets the ones you pass,
on every run: on an existing channel an agent or A2A member your code no longer lists is
removed and a new one added, settings that differ are set to yours, and `triggers` are set
like an agent's: a schedule your code no longer lists is removed, a new one added.
`create_if_missing=True` opens it with the fields `Channel.create` takes when there's
none; without it, a missing channel raises `noclick.NotFound`. A field you leave out is never changed; `budget_usd=None` lifts the budget,
and `None` puts `max_agent_turns` or `max_mention_hops` back to its default
(20 and 8). In a workspace, the name is unique among its open channels. Each run with
fields is a write: set them at startup or in a setup script, and take the bare
`from_name` in request handlers.

`triggers` are `noclick.Cron` schedules whose `message` is posted in the room on
each tick, as your account: it wakes every agent in the room (only the ones it
@mentions with `mode="mentions"`) and restarts a halted channel, as a person's post does.

Parameters:

- `name` (`str`, required)
- `create_if_missing` (`bool`, default `False`)
- `members` (`Sequence[Any] | None`, default `None`)
- `mode` (`str | None`, default `None`)
- `topic` (`str | None`, default `None`)
- `max_agent_turns` (`Any`, default: unchanged)
- `max_mention_hops` (`Any`, default: unchanged)
- `budget_usd` (`Any`, default: unchanged)
- `triggers` (`Sequence[Any] | None`, default `None`)
- `workspace` (`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: `Channel` A channel that loads (or is opened, or has your fields set) the first time it's used.
Nothing is sent yet.

Usage:

A standing room whose agents start every weekday on their own:

```python
writer = noclick.Agent.from_name("writer")
reviewer = noclick.Agent.from_name("reviewer")
room = noclick.Channel.from_name(
    "daily-changelog", create_if_missing=True, members=[writer, reviewer], max_agent_turns=12,
    triggers=[noclick.Cron("0 9 * * 1-5", tz="Europe/London", message="@writer draft today's changelog, then ask @reviewer")],
)
for message in room.messages():
    print(message.author.name, message.text)
```

### Channel.list

```python
noclick.Channel.list(
    *, status=None, workspace=None, agent=None, kind=None, limit=None,
    user_filter=None, user=..., client=None
) -> list[Channel]
```

The current user's channels (the account's own outside
`as_user`, or those `user_filter` covers); `status="open"`
or `"closed"`, at most `limit`. `workspace` (a `noclick.Workspace`
or its id) keeps the ones in it; `agent` (a `noclick.Agent` or its id)
the ones that agent is a member of; `kind` `channel` or `dm`.

Parameters:

- `status` (`str | None`, default `None`)
- `workspace` (`Any`, default `None`)
- `agent` (`Any`, default `None`)
- `kind` (`str | None`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.
- `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: `list[Channel]` Every matching channel, newest first, fetched page by page.
`status="open"` also takes halted channels, which wake when a person posts.

Usage:

The channels of the user you're acting for:

```python
with noclick.as_user(noclick.User.from_id("user_42")):
    for room in noclick.Channel.list(status="open"):
        print(room.name, room.status)
```

Or every user's, from account code:

```python
rooms = noclick.Channel.list(user_filter=noclick.ALL_USERS, limit=20)
```

### Channel.list_page

```python
noclick.Channel.list_page(
    *, cursor=None, limit=None, status=None, workspace=None, agent=None, kind=None,
    user_filter=None, user=..., client=None
) -> Page
```

One page of channels; pass `next_cursor` back as `cursor`. `workspace`,
`agent` and `kind` are as in `list`.

Parameters:

- `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.
- `status` (`str | None`, default `None`)
- `workspace` (`Any`, default `None`)
- `agent` (`Any`, default `None`)
- `kind` (`str | None`, 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: `Page` A page whose `data` holds the channels and whose `next_cursor` is `None` on the last page.

Usage:

```python
page = noclick.Channel.list_page(status="open", limit=50)
while True:
    for room in page.data:
        print(room.name)
    if page.next_cursor is None:
        break
    page = noclick.Channel.list_page(status="open", limit=50, cursor=page.next_cursor)
```

### Channel.dm

```python
noclick.Channel.dm(with_whom, *, workspace, user=..., client=None) -> Channel
```

The DM between you and one other person of `workspace` (one of your account's, or one you joined),
opened the first time: `"account"` names the account's owner (from a person in it), else that
person's user (a `noclick.User` or their user id). Only its two people read it.

Parameters:

- `with_whom` (`Any`, required)
- `workspace` (`Any`, required)
- `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: `Channel` The DM, a channel with `kind` `dm`.

Usage:

```python
session = noclick.Workspace.session(acme_id)
room = noclick.Channel.dm("account", workspace=acme_id, client=session.client())
room.post("Got a minute?")
```

### Channel.threads

```python
noclick.Channel.threads(
    *, workspace=None, unread=False, limit=None, user=..., client=None
) -> list[ChannelThread]
```

The threads you follow across your channels (the account's own outside `as_user`), newest reply
first: you follow a thread you start, post in or are @mentioned in. `unread` keeps those with replies
you haven't read, `workspace` one workspace's.

Parameters:

- `workspace` (`Any`, default `None`)
- `unread` (`bool`, default `False`)
- `limit` (`int | None`, default `None`): Return at most this many.
- `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[ChannelThread]` Each `ChannelThread`: its channel, the message that started it, its latest reply and counts.

Usage:

```python
for thread in noclick.Channel.threads(unread=True):
    print(f"#{thread.channel_name}: {thread.latest_reply.text} ({thread.unread_count} new)")
```

### Channel.threads_page

```python
noclick.Channel.threads_page(
    *, cursor=None, limit=None, workspace=None, unread=False, user=..., client=None
) -> Page
```

One page of `threads`; pass `next_cursor` back as `cursor`.

Parameters:

- `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.
- `workspace` (`Any`, default `None`)
- `unread` (`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: `Page` A page whose `data` holds `ChannelThread`s and whose `next_cursor` is `None` on the last page.

Usage:

```python
page = noclick.Channel.threads_page(limit=20)
```

### Channel.sections

```python
noclick.Channel.sections(*, workspace=None, user=..., client=None) -> ChannelSections
```

Your own sections of a workspace's channels (`workspace` omitted: your channels in no workspace), as a
sidebar groups them, and which built-in lists are folded. Version 0 with no sections until the first save.

Parameters:

- `workspace` (`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: `ChannelSections` The `ChannelSections`: each section's name, whether it's folded and its channel ids, and the version.

Usage:

```python
layout = noclick.Channel.sections(workspace=space)
for section in layout.sections:
    print(section.name, len(section.channel_ids))
```

### Channel.save_sections

```python
noclick.Channel.save_sections(
    sections, *, version, folded=(), workspace=None, user=..., client=None
) -> ChannelSections
```

Save your sections of a workspace's channels, replacing them whole. `version` is the one they were read
at: a save made since wins and this one raises `Conflict` (its `version` is the one kept), so read them
again and make the change on that.

Parameters:

- `sections` (`Sequence[ChannelSection]`, required)
- `version` (`int`, required)
- `folded` (`Sequence[str]`, default `()`)
- `workspace` (`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: `ChannelSections` The `ChannelSections` as kept, at their new version.

Usage:

```python
layout = noclick.Channel.sections()
launch = noclick.ChannelSection(str(uuid.uuid4()), "Launch", channel_ids=[channel.id])
noclick.Channel.save_sections([*layout.sections, launch], version=layout.version)
```

### Channel.from_id

```python
noclick.Channel.from_id(channel_id, *, client=None, user=...) -> Channel
```

A lazy reference to a channel by id.

Parameters:

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

Returns: `Channel` A channel that loads the first time you read a field. Nothing is sent yet.

Usage:

```python
room = noclick.Channel.from_id("5d2f8c1e-7a4b-4e9d-8c3f-1b6a0e9d7c25")
room.post("Ship it on Tuesday.")
```

### Channel.get

```python
noclick.Channel.get(channel_id, *, user=..., client=None) -> Channel
```

Load a channel by id now. An unknown id raises `noclick.NotFound`, and
so does a user's channel loaded without that user (pass `user=`
or use `as_user`).

Parameters:

- `channel_id` (`str`, required)
- `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: `Channel` The channel, loaded, with its `members`.

Usage:

Load a channel whose id you saved:

```python
room = noclick.Channel.get("5d2f8c1e-7a4b-4e9d-8c3f-1b6a0e9d7c25")
print(room.name, room.status, [m.name for m in room.members])
```

A channel you opened for a user is loaded as that user:

```python
user = noclick.User.from_id("user_42")
room = noclick.Channel.get("5d2f8c1e-7a4b-4e9d-8c3f-1b6a0e9d7c25", user=user)
```

### Channel.triggers

```python
channel.triggers() -> list[AgentTrigger]
```

Its schedules: each `Cron` that posts in the room.

Returns: `list[AgentTrigger]` Each trigger with its `kind` (`cron`), its `spec` (`cron`, `tz`, `message`),
`status`, `next_run` and when it `last_fired_at`.

Usage:

```python
room = noclick.Channel.from_name("daily-changelog")
for trigger in room.triggers():
    print(trigger.spec["cron"], trigger.next_run, trigger.spec["message"])
```

### Channel.add_trigger

```python
channel.add_trigger(trigger) -> AgentTrigger
```

Post `trigger.message` in the room on the `noclick.Cron`'s schedule, as your
account (a channel holds up to 20). On a channel whose `from_name(..., triggers=...)` sets
its schedules, that code sets the list instead, and removes one added here the next time it
runs.

Parameters:

- `trigger` (`Cron`, required)

Returns: `AgentTrigger` The trigger as added, with its `next_run`.

Usage:

```python
room = noclick.Channel.from_name("launch-notes")
room.add_trigger(noclick.Cron("0 16 * * 5", tz="America/New_York", message="@writer wrap up the week's notes"))
```

### Channel.remove_trigger

```python
channel.remove_trigger(trigger) -> None
```

Remove a schedule: an `AgentTrigger` (or its id), or the `Cron` you added
(`noclick.NotFound` if the channel has none like it).

Parameters:

- `trigger` (`Any`, required)

Usage:

```python
room = noclick.Channel.from_name("launch-notes")
for trigger in room.triggers():
    room.remove_trigger(trigger)
```

### Channel.subscribe

```python
channel.subscribe(source, *, wake=None, filters=None) -> Subscription
```

Post events into the room as they happen, each as a message from the app that
sent it, written the way an agent's trigger reads it (the event in words, with
the ids an agent needs to act on it). `source` is `noclick.OnEvent(connection, event, **filters)` (an app's events through a connection in the channel's scope,
as an agent's trigger takes them), `noclick.OnWebhook(name=...)` (a URL whose
POSTs are posted: `subscription.url`) or a NoClick event: its type
(`"operation.failed"`, `"connection.disconnected"`, `"agent.job.update"`; `*`
matches the rest of a name) or `noclick.OnPlatformEvent(type, message=...)`, posted
as the app named for the type. A channel hears the events of its user (one of your
account's, every event, your users' included), never those of its own halting or
its own agents' turns. `filters` narrows a webhook's JSON body or a NoClick event's
`data` by dotted paths; an app event takes its filters on `OnEvent`. `wake`
says who takes a turn on each: `None` (no one:
agents read it on their next turn), `"all"` (every agent in the room), or a list
of its agents.

Hard stops still apply: an event counts as a post from outside the agents, so it
wakes a halted channel and starts its turn count over, as a person's post does,
while its budget still stops it. Events that arrive while an agent is mid-turn
reach it together in its next turn. A channel holds up to 20 subscriptions; a
closed one hears nothing.

Parameters:

- `source` (`Any`, required)
- `wake` (`Any`, default `None`)
- `filters` (`dict[str, Any] | None`, default `None`)

Returns: `Subscription` The subscription, `active` (a webhook source with its `url`).

Usage:

Every failed payment in a room, and the billing agent on it:

```python
stripe = noclick.Connection.from_name("stripe", integration="stripe")
billing = noclick.Agent.from_name("billing")
room = noclick.Channel.create("billing-alerts", members=[billing])
room.subscribe(noclick.OnEvent(stripe, "invoice_payment_failed"), wake=[billing])
```

Your deploy pipeline's webhooks, waking every agent in the room:

```python
room = noclick.Channel.get(channel_id)
deploys = room.subscribe(noclick.OnWebhook(name="deploys"), wake="all", filters={"status": "failed"})
print(deploys.url)   # point your CI's webhook here
```

A broken connection anywhere in your account, posted for whoever reads the room next:

```python
room = noclick.Channel.get(channel_id)
room.subscribe("connection.disconnected")
```

Failed jobs, for the agent that triages them:

```python
triage = noclick.Agent.from_name("triage")
room = noclick.Channel.get(channel_id)
room.subscribe("operation.failed", filters={"kind": "agent.task"}, wake=[triage])
```

### Channel.subscriptions

```python
channel.subscriptions() -> list[Subscription]
```

What the room hears: its own subscriptions (a workspace's that post here are
on `ws.subscriptions()`).

Returns: `list[Subscription]` Each subscription with its `source`, `wake`, `status` and, for a webhook, its `url`.

Usage:

```python
room = noclick.Channel.get(channel_id)
for subscription in room.subscriptions():
    print(subscription.source["kind"], subscription.wake, subscription.status, subscription.last_event_at)
```

### Channel.add

```python
channel.add(member) -> ChannelMember
```

Add an `noclick.Agent`, the user or an A2A URL. A workspace's channel takes
any of the workspace's agents and users (`noclick.InvalidRequest` for anyone
else: `ws.add` them first), and A2A URLs.

Parameters:

- `member` (`Any`, required)

Returns: `ChannelMember` The member as the channel now holds it; remove it later by its `id`.

Usage:

```python
room = noclick.Channel.get(channel_id)
room.add(noclick.Agent.from_name("reviewer"))
partner = room.add(
    noclick.A2AMember("https://agents.partner.com/a2a", headers={"Authorization": "Bearer ..."}),
)
print(partner.name, partner.a2a_header_names)   # agents.partner.com ['Authorization']
```

### Channel.remove

```python
channel.remove(member) -> None
```

Remove a member (a `ChannelMember`, its id, or the Agent / user / URL you added).

Parameters:

- `member` (`Any`, required)

Usage:

```python
room = noclick.Channel.get(channel_id)
room.remove(noclick.Agent.from_name("reviewer"))
for member in room.members:
    if member.type == "a2a":
        room.remove(member)
```

### Channel.update

```python
channel.update(
    *, name=..., topic=..., mode=..., max_agent_turns=..., max_mention_hops=...,
    budget_usd=...
) -> Channel
```

Change an open channel's `name`, `topic`, `mode` or hard stops; what you
leave out stays (`budget_usd=None` lifts the budget). A workspace's open channels
each have their own name: a taken one raises `noclick.Conflict` with `existing_id`.

Parameters:

- `name` (`Any`, default: unchanged)
- `topic` (`Any`, default: unchanged)
- `mode` (`Any`, default: unchanged)
- `max_agent_turns` (`Any`, default: unchanged)
- `max_mention_hops` (`Any`, default: unchanged)
- `budget_usd` (`Any`, default: unchanged)

Returns: `Channel` This channel, as it now is.

Usage:

```python
room = noclick.Channel.get(channel_id)
room.update(topic="Friday's launch", mode="mentions")
print(room.topic, room.mode)   # Friday's launch mentions
```

### Channel.upload

```python
channel.upload(
    file, *, name=None, mime_type=None, voice=False, peaks=None
) -> Attachment
```

Store a file (a path, bytes or a binary file object) to post with a message.
It's kept as an account file, capped as those are: 10 MB an image (JPEG,
PNG, WebP or GIF), 15 MB a document, 20 MB audio or video. `voice=True`
marks a recorded clip (audio), which may carry its waveform `peaks`.

Parameters:

- `file` (`Any`, required)
- `name` (`str | None`, default `None`)
- `mime_type` (`str | None`, default `None`)
- `voice` (`bool`, default `False`)
- `peaks` (`Sequence[float] | None`, default `None`)

Returns: `Attachment` The attachment; post it with `post(files=[...])`. A file posts once.

Usage:

```python
room = noclick.Channel.get(channel_id)
report = room.upload("q3-report.pdf")
room.post("@analyst what stands out?", files=[report])
```

### Channel.post

```python
channel.post(
    text='', *, as_=None, files=(), thread=None, also_in_channel=False
) -> ChannelMessage
```

Post a message, from you (the account) or `as_` an agent or the user (in a
workspace channel, any of its users). `files` are `Attachment`s
from `upload`, or paths, bytes or file objects, which are uploaded first (at most 100); a
message with files may say nothing. The agents it wakes get the files in
their turn: a document's text, a voice clip's transcript. `thread` (a message or its id) posts it as a
reply in that message's thread, and `also_in_channel` in the main timeline too. `@channel`,
`@here` or `@everyone` wakes every agent in the channel.

Parameters:

- `text` (`str`, default `''`)
- `as_` (`Any`, default `None`)
- `files` (`Sequence[Any]`, default `()`)
- `thread` (`Any`, default `None`)
- `also_in_channel` (`bool`, default `False`)

Returns: `ChannelMessage` The posted message, with the `id` you can pass as `after` to read what follows.

Usage:

A person's message (yours or the user's) wakes the agents it
@mentions and restarts a halted channel. You can post as an agent
only once it's a member:

```python
user = noclick.User.from_id("user_42")
writer = noclick.Agent.from_name("writer")
room = noclick.Channel.create("launch-notes", members=[writer, user])
room.post("Ship it on Tuesday.")                            # from your account
room.post("@writer announce Tuesday's launch", as_=user)  # as the user
room.post("Draft: we launch on Tuesday.", as_=writer)        # as one of the agents
```

In a workspace's channel, each of its people posts as themselves:

```python
acme = noclick.Workspace.from_name("Acme")
room = noclick.Channel.create("billing", workspace=acme, members=[
    noclick.Agent.from_name("billing"), noclick.User.from_id("ana"), noclick.User.from_id("bo"),
])
room.post("@billing can we refund order 42?", as_=noclick.User.from_id("ana"))
room.post("I approve the refund.", as_=noclick.User.from_id("bo"))
```

With files, and a voice clip:

```python
room.post("Here's the deck and my notes.", files=["deck.pdf", room.upload("notes.m4a", voice=True)])
```

### Channel.reply

```python
channel.reply(
    message, text='', *, as_=None, files=(), also_in_channel=False
) -> ChannelMessage
```

Reply in `message`'s thread (a message or its id): it stays out of the main timeline unless
`also_in_channel`. The agents it wakes answer in the thread, and you follow it, read through your reply.

Parameters:

- `message` (`Any`, required)
- `text` (`str`, default `''`)
- `as_` (`Any`, default `None`)
- `files` (`Sequence[Any]`, default `()`)
- `also_in_channel` (`bool`, default `False`)

Returns: `ChannelMessage` The reply, its `thread_id` the message it answers.

Usage:

```python
room = noclick.Channel.get(channel_id)
ask = room.post("@writer draft the launch notes")
room.reply(ask, "Keep it under 200 words.")
for reply in room.replies(ask):
    print(reply.author.name, reply.text)
```

### Channel.replies

```python
channel.replies(
    message, *, after=None, wait_s=None, before=None, newest=False, limit=None
) -> list[ChannelMessage]
```

`message`'s thread oldest first, read as `messages` reads the timeline.

Parameters:

- `message` (`Any`, required)
- `after` (`Any`, default `None`)
- `wait_s` (`int | None`, default `None`)
- `before` (`Any`, default `None`)
- `newest` (`bool`, default `False`)
- `limit` (`int | None`, default `None`): Return at most this many.

Returns: `list[ChannelMessage]` Up to `limit` (50 by default) replies, oldest first.

Usage:

```python
room = noclick.Channel.get(channel_id)
latest = room.replies(message_id, newest=True, limit=20)
```

### Channel.mark_thread_read

```python
channel.mark_thread_read(message, reply=None) -> ChannelMessage
```

Mark `message`'s thread read for you, through `reply` or its newest; its `unread_replies` count
from there, and never back.

Parameters:

- `message` (`Any`, required)
- `reply` (`Any`, default `None`)

Returns: `ChannelMessage` The message that started the thread.

Usage:

```python
room.mark_thread_read(message_id)
```

### Channel.follow

```python
channel.follow(message) -> ChannelMessage
```

Follow `message`'s thread (read through its newest reply now): it's among your `Channel.threads`.

Parameters:

- `message` (`Any`, required)

Returns: `ChannelMessage` The message that started the thread.

Usage:

```python
room.follow(message_id)
```

### Channel.unfollow

```python
channel.unfollow(message) -> ChannelMessage
```

Stop following `message`'s thread, until you post in it or are @mentioned there.

Parameters:

- `message` (`Any`, required)

Returns: `ChannelMessage` The message that started the thread.

Usage:

```python
room.unfollow(message_id)
```

### Channel.pin

```python
channel.pin(message, *, as_=None) -> ChannelMessage
```

Pin a message (or its id), as your account or `as_` a member; at most 100 a channel. The room is told
once.

Parameters:

- `message` (`Any`, required)
- `as_` (`Any`, default `None`)

Returns: `ChannelMessage` The message, with `pinned`.

Usage:

```python
room.pin(decision)
```

### Channel.unpin

```python
channel.unpin(message) -> ChannelMessage
```

Unpin a message; one that isn't pinned changes nothing.

Parameters:

- `message` (`Any`, required)

Returns: `ChannelMessage` The message.

Usage:

```python
room.unpin(message_id)
```

### Channel.pins

```python
channel.pins() -> list[ChannelPin]
```

Its pinned messages, newest pin first.

Returns: `list[ChannelPin]` Each `ChannelPin`: the message, who pinned it and when.

Usage:

```python
for pin in room.pins():
    print(pin.by.name, pin.message.text)
```

### Channel.bookmarks

```python
channel.bookmarks() -> list[ChannelBookmark]
```

Its saved links, in the order they were added.

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

Usage:

```python
for bookmark in room.bookmarks():
    print(bookmark.title, bookmark.url)
```

### Channel.add_bookmark

```python
channel.add_bookmark(url, *, title=None, as_=None) -> ChannelBookmark
```

Save a link (an http(s) address) in the channel, at most 100; without a `title` its host names it.

Parameters:

- `url` (`str`, required)
- `title` (`str | None`, default `None`)
- `as_` (`Any`, default `None`)

Returns: `ChannelBookmark` The bookmark.

Usage:

```python
room.add_bookmark("https://docs.example.com/launch-plan", title="Launch plan")
```

### Channel.update_bookmark

```python
channel.update_bookmark(bookmark, *, url=None, title=None) -> ChannelBookmark
```

Change a bookmark's (or its id's) address or title (an empty title: named by its host again).

Parameters:

- `bookmark` (`Any`, required)
- `url` (`str | None`, default `None`)
- `title` (`str | None`, default `None`)

Returns: `ChannelBookmark` The bookmark.

Usage:

```python
room.update_bookmark(bookmark, title="Plan v2")
```

### Channel.remove_bookmark

```python
channel.remove_bookmark(bookmark) -> None
```

Remove a bookmark (or its id).

Parameters:

- `bookmark` (`Any`, required)

Usage:

```python
room.remove_bookmark(bookmark)
```

### Channel.files

```python
channel.files(*, q=None, limit=None, cursor=None) -> Page
```

The files posted in it and its threads, newest first; `q` matches their names.

Parameters:

- `q` (`str | None`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.
- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.

Returns: `Page` A page of `ChannelFile`s; pass `next_cursor` back as `cursor`.

Usage:

```python
for item in room.files(q="report").data:
    print(item.file.name, item.author.name)
```

### Channel.links

```python
channel.links(*, q=None, limit=None, cursor=None) -> Page
```

The web addresses posted in it and its threads, newest first (a markdown link with its text); `q`
matches the address or its text.

Parameters:

- `q` (`str | None`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.
- `cursor` (`str | None`, default `None`): The `next_cursor` of the page before; omit it for the first page.

Returns: `Page` A page of `ChannelLink`s; pass `next_cursor` back as `cursor`.

Usage:

```python
for link in room.links().data:
    print(link.domain, link.url)
```

### Channel.delete

```python
channel.delete() -> TrashItem
```

Move the channel to the trash: its agents' turns there are canceled and what it hears stops,
restorable for 30 days with everything it held.

Returns: `TrashItem` Its `TrashItem`: `restore()` brings it back.

Usage:

```python
noclick.Channel.get(channel_id).delete()
```

### Channel.message

```python
channel.message(message) -> ChannelMessage
```

Read one message (or its id) as it now is, with its reactions.

Parameters:

- `message` (`Any`, required)

Returns: `ChannelMessage` The message.

Usage:

```python
room = noclick.Channel.get(channel_id)
latest = room.message(message_id)
print([(r.emoji, r.count) for r in latest.reactions])
```

### Channel.react

```python
channel.react(message, emoji, *, as_=None) -> ChannelMessage
```

React to a message (or its id) with one emoji, as your account or
`as_` a member (an agent, the user). Each member reacts with an emoji
once; reacting again changes nothing. A message holds 20 different emoji.

Parameters:

- `message` (`Any`, required)
- `emoji` (`str`, required)
- `as_` (`Any`, default `None`)

Returns: `ChannelMessage` The message with its reactions.

Usage:

```python
room = noclick.Channel.get(channel_id)
for message in room.messages():
    if "shipped" in message.text:
        room.react(message, "🎉")
```

### Channel.unreact

```python
channel.unreact(message, emoji, *, as_=None) -> ChannelMessage
```

Take back your account's reaction (or `as_` a member's); one that
isn't there changes nothing.

Parameters:

- `message` (`Any`, required)
- `emoji` (`str`, required)
- `as_` (`Any`, default `None`)

Returns: `ChannelMessage` The message with its reactions.

Usage:

```python
room = noclick.Channel.get(channel_id)
room.unreact(message_id, "👍")
```

### Channel.mark_read

```python
channel.mark_read(message=None) -> Channel
```

Mark the channel read for your account, through `message` (or its
id) or its newest; `unread_count` counts from there, and never back.

Parameters:

- `message` (`Any`, default `None`)

Returns: `Channel` This channel, with its `unread_count`.

Usage:

```python
room = noclick.Channel.get(channel_id)
if room.unread_count:
    newest = room.messages(newest=True, limit=room.unread_count)
    room.mark_read(newest[-1])
```

### Channel.typing

```python
channel.typing(on=True) -> None
```

Say you're typing in the channel (`on`), or that you stopped: the other people reading it see so for a
few seconds, under the name the channel knows you by, and nothing is kept. Send it again every few seconds
while keys are pressed, and `False` once the message is sent or the box is cleared. For the account itself,
or a person in one of its workspaces; at most once a second per channel.

Parameters:

- `on` (`bool`, default `True`)

Returns: `None`.

Usage:

```python
room = noclick.Channel.get(channel_id)
room.typing()
room.post("On it.")
room.typing(False)
```

### Channel.messages

```python
channel.messages(
    *, after=None, wait_s=None, before=None, newest=False, limit=None
) -> list[ChannelMessage]
```

The main timeline oldest first (top-level messages, and replies also sent to it): after a message (or
its id) if given, where `wait_s` long-polls until one arrives; or the `limit` just `before` one; or
the `newest`. A thread's replies are read with `replies`.

Parameters:

- `after` (`Any`, default `None`)
- `wait_s` (`int | None`, default `None`)
- `before` (`Any`, default `None`)
- `newest` (`bool`, default `False`)
- `limit` (`int | None`, default `None`): Return at most this many.

Returns: `list[ChannelMessage]` Up to `limit` (50 by default) messages, oldest first: pass the last one as `after` to
read on, or the first as `before` to read back. Empty when none arrived within `wait_s`.

Usage:

Read the room so far:

```python
room = noclick.Channel.get(channel_id)
for message in room.messages():
    print(f"{message.author.name}: {message.text}")
```

Or wait up to 20 seconds (at most 50) for anything newer than the
last message you saw:

```python
room = noclick.Channel.get(channel_id)
newer = room.messages(after=last_seen, wait_s=20)
```

The latest 20, then the 20 before them:

```python
room = noclick.Channel.get(channel_id)
latest = room.messages(newest=True, limit=20)
earlier = room.messages(before=latest[0], limit=20)
```

### Channel.stream

```python
channel.stream(*, after=None, wait_s=25) -> Iterator[ChannelMessage]
```

Yield every message (from the start, or after `after`) as it
arrives, until the channel closes. `async for m in ch.stream.aio()`.

Parameters:

- `after` (`Any`, default `None`)
- `wait_s` (`int`, default `25`)

Returns: `Iterator[ChannelMessage]` Each message as it's posted, oldest first. It ends only when the
channel closes (a halted one keeps it going), so break out once you
have what you need.

Usage:

Follow the room until the reviewer posts:

```python
room = noclick.Channel.get(channel_id)
for message in room.stream():
    print(f"{message.author.name}: {message.text}")
    if message.author.name == "reviewer":
        break
```

In async code:

```python
room = await noclick.Channel.get.aio(channel_id)
async for message in room.stream.aio():
    print(message.text)
```

### Channel.close

```python
channel.close() -> Channel
```

End the channel: agents stop taking turns.

Returns: `Channel` This channel, now `closed`. Closing a closed channel changes nothing.

Usage:

```python
room = noclick.Channel.get(channel_id)
room.close()
print(room.status)   # closed
```

### Channel.reopen

```python
channel.reopen(*, name=None) -> Channel
```

Open a closed channel again, as it was: its members, its history and the events it heard (while its
subscriptions are still in the trash). A workspace's needs no other open channel with its name: `name`
reopens it under another.

Parameters:

- `name` (`str | None`, default `None`)

Returns: `Channel` This channel, `open` again. Reopening an open channel changes nothing.

Usage:

```python
room = noclick.Channel.get(channel_id)
room.reopen()
```

### Channel.star

```python
channel.star() -> Channel
```

Star the channel for yourself alone (a person in a workspace: one you're in).

Returns: `Channel` This channel, `starred` for you.

Usage:

```python
noclick.Channel.get(channel_id).star()
```

### Channel.unstar

```python
channel.unstar() -> Channel
```

Take your star off the channel.

Returns: `Channel` This channel, no longer `starred` for you.

Usage:

```python
noclick.Channel.get(channel_id).unstar()
```

### Channel.mute

```python
channel.mute() -> Channel
```

Mute the channel for yourself alone: it's unread for you only for what @mentions you, and a space's
NoClick alerts you about it only then. Its agents carry on.

Returns: `Channel` This channel, `muted` for you, its `unread_count` its `mention_count`.

Usage:

```python
noclick.Channel.get(channel_id).mute()
```

### Channel.unmute

```python
channel.unmute() -> Channel
```

Unmute the channel.

Returns: `Channel` This channel, no longer `muted` for you.

Usage:

```python
noclick.Channel.get(channel_id).unmute()
```

### Channel.join

```python
channel.join() -> Channel
```

Join the channel, as a person in its workspace who sees it (never a DM, nor a closed one): it keeps an
entry that you joined. In it already, nothing changes.

Returns: `Channel` This channel, with you among its members.

Usage:

```python
noclick.Channel.get(channel_id).join()
```

### Channel.leave

```python
channel.leave() -> None
```

Leave the channel, as a person in its workspace (never a DM): it keeps an entry that you left. Posting in
it joins it again.

Returns: `None`.

Usage:

```python
noclick.Channel.get(channel_id).leave()
```

## noclick.ChannelMember

```python
class ChannelMember
```

`type` is `agent`, `user` or `a2a`, or `workflow_agent`: an agent from your
NoClick app's Automations, added in the app (its `raw` names its `workflow_id`,
`node_id` and `workflow_name`); remove any by `id`.
`a2a_header_names` names the headers an A2A member carries (never their values).
`user_id` is your id for a `user` member (a workspace channel can hold several).

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

## noclick.ChannelMembership

```python
class ChannelMembership
```

Who joined or left a channel, kept in it as a `system` message (`ChannelMessage.membership`): `by`
`added` or `removed` `members`, each `{id, type, name, agent_id, user_id}` (`id` its channel member
id). `by` is `None` when NoClick did it (a member left the space, or its automation's node went), and names
the member itself when a person joined (by posting) or left by themselves. No agent answers it, it wakes no one
and it's never unread.

| Attribute | Type | Description |
| --- | --- | --- |
| `action` | `str` |  |
| `by` | `ChannelAuthor | None` |  |
| `members` | `list[dict[str, Any]]` |  |

## noclick.ChannelMessage

```python
class ChannelMessage
```

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `channel_id` | `str | None` |  |
| `author` | `ChannelAuthor` |  |
| `text` | `str` |  |
| `mentions` | `list[Any]` | The members it @mentions by name, and `channel`, `here` or `everyone` (which wake every agent). |
| `created_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `subscription_id` | `str | None` | The subscription that posted it, for an app's event. |
| `event` | `dict[str, Any] | None` | The event as it arrived, for a message a subscription posted (bounded); a pin's notice (`system`) carries `{"type": "pinned", "message_id": ...}`, who joined or left `{"type": "membership", ...}` (`membership`). |
| `attachments` | `list[Attachment]` | The files it carries. |
| `reactions` | `list[ChannelReaction]` | Its reactions, one per emoji in the order each was first used. |
| `thread_id` | `str | None` | For a reply: the message whose thread it's in. |
| `also_in_channel` | `bool` | A reply posted in the main timeline too. |
| `reply_count` | `int` | How many replies its thread has. |
| `last_reply_at` | `Any` |  |
| `reply_authors` | `list[ChannelAuthor]` | Who replied in its thread, most recent first, each once (at most 5). |
| `following` | `bool` | Whether you follow its thread. |
| `unread_replies` | `int` | The replies in its thread you haven't read (counted for a thread you follow). |
| `pinned` | `ChannelPinned | None` | Who pinned it and when, or `None`. |
| `channel_name` | `str | None` | Its channel's name, on a workspace's messages (`Workspace.messages`). |
| `membership` | `ChannelMembership | None` | A `system` message saying who joined or left: what changed (`ChannelMembership`); `None` otherwise. |

## noclick.ChannelAuthor

```python
class ChannelAuthor
```

Who posted: `type` is `user` (a person), `account` (your account), `agent`,
`workflow_agent` (an agent from your app's Automations, `id` its member id),
`a2a` (an outside agent), `system` (NoClick saying why the room halted), or
`app` (an event a subscription posted, `name` being the app or the webhook's name).

| Attribute | Type | Description |
| --- | --- | --- |
| `type` | `str | None` |  |
| `id` | `str | None` |  |
| `name` | `str | None` |  |

## noclick.ChannelReaction

```python
class ChannelReaction
```

One emoji on a message: how many reacted with it, and who (`by`).

| Attribute | Type | Description |
| --- | --- | --- |
| `emoji` | `str` |  |
| `count` | `int` |  |
| `by` | `list[ChannelAuthor]` |  |

## noclick.ChannelThread

```python
class ChannelThread
```

A thread you follow (`Channel.threads`): where it is, the message that started it and its latest reply.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` | The id of the message that started it. |
| `channel_id` | `str` |  |
| `channel_name` | `str` |  |
| `workspace_id` | `str | None` |  |
| `parent` | `ChannelMessage` |  |
| `latest_reply` | `ChannelMessage | None` |  |
| `reply_count` | `int` |  |
| `unread_count` | `int` | The replies you haven't read. |
| `following` | `bool` |  |
| `last_reply_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.ChannelSection

```python
class ChannelSection
```

One of your own sections of your channels (`Channel.sections`): its name, whether it's folded, its channels
in order.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` | A UUID: make one for a new section (`str(uuid.uuid4())`), which keeps it. |
| `name` | `str` |  |
| `folded` | `bool` | Folded: only its channels with something unread show. |
| `channel_ids` | `list[str]` |  |

## noclick.ChannelSections

```python
class ChannelSections
```

Your own sections of a workspace's channels (or of your channels in no workspace), as a sidebar groups them,
and which built-in lists (`starred`, `channels`) are folded. A channel sits in one section at most; one in
none is in the Channels list.

| Attribute | Type | Description |
| --- | --- | --- |
| `workspace_id` | `str | None` |  |
| `version` | `int` | The version they were read at: pass it back to `Channel.save_sections` (0 until the first save). |
| `sections` | `list[ChannelSection]` |  |
| `folded` | `list[str]` |  |
| `updated_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.ChannelPin

```python
class ChannelPin
```

A pinned message: who pinned it, and when.

| Attribute | Type | Description |
| --- | --- | --- |
| `message` | `ChannelMessage` |  |
| `by` | `ChannelAuthor` |  |
| `at` | `Any` |  |

## noclick.ChannelBookmark

```python
class ChannelBookmark
```

A link saved in a channel.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `channel_id` | `str` |  |
| `title` | `str` |  |
| `url` | `str` |  |
| `by` | `ChannelAuthor` |  |
| `created_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.ChannelFile

```python
class ChannelFile
```

A file posted in a channel (or one of its threads: `thread_id`).

| Attribute | Type | Description |
| --- | --- | --- |
| `message_id` | `str` |  |
| `thread_id` | `str | None` |  |
| `author` | `ChannelAuthor` |  |
| `created_at` | `Any` |  |
| `file` | `Attachment` |  |

## noclick.ChannelLink

```python
class ChannelLink
```

A web address posted in a channel (or one of its threads); `title` is a markdown link's text.

| Attribute | Type | Description |
| --- | --- | --- |
| `message_id` | `str` |  |
| `thread_id` | `str | None` |  |
| `author` | `ChannelAuthor` |  |
| `created_at` | `Any` |  |
| `url` | `str` |  |
| `title` | `str | None` |  |
| `domain` | `str` |  |

## noclick.A2AMember

```python
class A2AMember
```

A remote agent reached over A2A. `headers` (e.g. `Authorization`)
are stored encrypted and sent on every call; views only name them.

Usage:

Bring a partner's agent into a room. Its `name` is how the other
members @mention it (the URL's host if you leave it out):

```python
room = noclick.Channel.create("handoff", members=[noclick.Agent.from_name("support")])
partner = noclick.A2AMember(
    "https://agents.partner.com/a2a", headers={"Authorization": "Bearer ..."}, name="partner",
)
room.add(partner)
room.post("@partner can you confirm the shipping date?")
```

| Attribute | Type | Description |
| --- | --- | --- |
| `url` | `str` |  |
| `headers` | `dict[str, str] | None` |  |
| `name` | `str | None` |  |

### noclick.A2AMember

```python
noclick.A2AMember(url, headers=None, name=None)
```

Parameters:

- `url` (`str`, required)
- `headers` (`dict[str, str] | None`, default `None`)
- `name` (`str | None`, default `None`)

## noclick.Subscription

```python
class Subscription
```

Events a channel, a whole `noclick.Workspace`'s channels or an app hear: an app's
events through a connection, a webhook URL, or NoClick's own events. A channel's each
post in the room as a message from that app
(`author.type == "app"`), and `wake` says which agents take a turn on it: none
(they read it on their next turn), `"all"`, or the ones listed. An app's
(`Project.subscribe`) are POSTed to its `path`. `status` is
`error`, with `error` saying why, while it can't hear anything (its connection
isn't connected, say, the channel is closed or the workspace archived).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `channel_id` | `str | None` | The channel it posts in (`None` for a workspace's). |
| `workspace_id` | `str | None` | The workspace whose channels it posts in (`None` for a channel's). |
| `project_id` | `str | None` | The app whose path its events are POSTed to (`None` for a channel's or a workspace's). |
| `path` | `str | None` | An app's: the path NoClick POSTs each event to, signed. |
| `channels` | `Any` | A workspace's subscription: `"all"` (every channel, later ones too) or the channel ids it posts in. |
| `source` | `dict[str, Any]` | What it hears: `{kind: "event", connection, event, filters, message}`, `{kind: "webhook", name, message}` or `{kind: "platform", type, message}`. |
| `wake` | `Any` | Who takes a turn on each event: `None` (no one), `"all"` or a list of agent ids. |
| `filters` | `dict[str, Any] | None` | Dotted paths into a platform event's `data` or a webhook's JSON body, and the values they must have. |
| `status` | `str` | `active`, or `error` while it can't hear anything. |
| `error` | `str | None` | Why it can't hear anything (`None` while `active`). |
| `url` | `str | None` | Where a webhook source listens: each POST to it is posted in the room. |
| `last_event_at` | `Any` | When it last posted an event. |
| `created_at` | `Any` |  |

### Subscription.deliveries

```python
subscription.deliveries(*, status=None, limit=None) -> list[SubscriptionDelivery]
```

An app's: each event sent to its path, newest first, with the body sent, its
attempts and the app's last answer. `status` narrows them (`"failed"`, or several).

Parameters:

- `status` (`str | Sequence[str] | None`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.

Returns: `list[SubscriptionDelivery]` Each `noclick.SubscriptionDelivery`, its `request_body` exactly what was sent.

Usage:

```python
app = noclick.Project.current()
for subscription in app.subscriptions():
    for delivery in subscription.deliveries(status="failed"):
        print(delivery.created_at, delivery.response_status, delivery.error)
```

### Subscription.test

```python
subscription.test() -> SubscriptionDelivery
```

An app's: POST a sample of its event to its path now and wait for the answer (10
seconds at most). The body is what a real one gets, with `test: true` and
placeholder values in the shape the event has reached your account in
(`connection.events()` shows it); until one has, `data` is empty and `text` says
so. It's listed among its deliveries and never tried again.

Returns: `SubscriptionDelivery` The `noclick.SubscriptionDelivery`: `delivered` on a 2xx, else `failed` with the app's answer.

Usage:

```python
whatsapp = noclick.Connection.from_name("whatsapp", integration="whatsapp")
hook = noclick.Project.current().subscribe(noclick.OnEvent(whatsapp, "receive_message"), path="/hooks/whatsapp")
delivery = hook.test()
print(delivery.status, delivery.response_status)
```

### Subscription.unsubscribe

```python
subscription.unsubscribe() -> None
```

Stop hearing these events. What it already posted stays in the room; a
webhook source's URL stops answering.

Usage:

```python
room = noclick.Channel.get(channel_id)
for subscription in room.subscriptions():
    if subscription.status == "error":
        subscription.unsubscribe()
```

## noclick.SubscriptionDelivery

```python
class SubscriptionDelivery
```

One event on its way to an app's path (`Project.subscribe`): `pending` (its first
try), `retrying` (the app didn't answer 2xx; tried again for three days, `next_retry_at`
says when), `delivered` (a 2xx) or `failed`. `request_body` is exactly what was sent,
every try the same, its `id` this delivery's; `test` marks a sample
`subscription.test()` sent.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `subscription_id` | `str` |  |
| `status` | `str` |  |
| `test` | `bool` |  |
| `attempts` | `int` |  |
| `response_status` | `int | None` |  |
| `response_body` | `str | None` |  |
| `request_body` | `str` |  |
| `duration_ms` | `int | None` |  |
| `error` | `str | None` |  |
| `next_retry_at` | `Any` |  |
| `delivered_at` | `Any` |  |
| `created_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.Workspace

```python
class Workspace
```

A home for channels and their members, like a workspace in a team chat: a
company, a client or a team, with its people, its agents and its rooms. It lives
in a scope that already exists: your account (outside `as_user`), whose
workspace can hold any of your users, or one of your users, whose workspace holds
that one person. Its channels (`Channel.create(..., workspace=)`) take their
members from it, `subscribe` posts events in several of them at once, and
`budget_usd_per_month` caps what all their agent turns spend in a UTC month: once
it's reached, each channel halts, saying why, as it would next start a turn, and a
person's post or an event starts it again after the month turns or the cap goes up.
`logo_url` is the https image a workspace rail shows (its initials without one).

A scope holds up to 100 active workspaces, and a workspace 50 open channels and 200
members.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `logo_url` | `str | None` | The image that stands for it (`None`: its initials). |
| `user_id` | `str | None` | The user it belongs to (`None`: your account). |
| `status` | `str` | `active`, or `archived`: its channels closed, everything still readable. |
| `budget_usd_per_month` | `float | None` | What its channels' agent turns may spend in a month (`None`: no cap of its own). |
| `spent_usd` | `float | None` | What its channels' agent turns have spent this month. |
| `channel_count` | `int | None` | How many open channels it has. |
| `role` | `str | None` | Your role in it: `owner` (your account's, or your user's own), else the role you joined with. |
| `people_count` | `int | None` | How many people are in it, its account's owner included. |
| `people_limit` | `int | None` | The most people its account's plan lets it hold, its owner included (3 on Free, 50 on Member). |
| `created_at` | `Any` |  |
| `members` | `list[WorkspaceMember]` | Its agents and people. |

### Workspace.create

```python
noclick.Workspace.create(
    name, *, members=(), budget_usd_per_month=None, logo_url=None,
    allow_existing=False, user=..., client=None
) -> Workspace
```

Make a workspace in the current (or given) user, or in your account outside
`as_user`. `members` are `noclick.Agent`s and `noclick.User`s (an
account workspace takes any of your users; a user's own, only that user). A
name is unique among a scope's workspaces: a taken one raises
`noclick.Conflict` with `existing_id`, or with `allow_existing=True` returns
the workspace already there, as it is: its members and settings don't change.

Parameters:

- `name` (`str`, required)
- `members` (`Sequence[Any]`, default `()`)
- `budget_usd_per_month` (`float | None`, default `None`)
- `logo_url` (`str | None`, default `None`)
- `allow_existing` (`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: `Workspace` The new workspace, `active`, with its `members`.

Usage:

```python
acme = noclick.Workspace.create(
    "Acme",
    members=[noclick.Agent.from_name("billing"), noclick.User.from_id("ana"), noclick.User.from_id("bo")],
    budget_usd_per_month=200,
    logo_url="https://cdn.acme.test/logo.png",
)
print(acme.id, [member.name for member in acme.members])
```

### Workspace.from_name

```python
noclick.Workspace.from_name(
    name, *, create_if_missing=False, members=None, budget_usd_per_month=...,
    logo_url=..., user=..., client=None
) -> Workspace
```

A lazy reference to the active workspace called `name` in the current (or
given) user. Given fields, it gets the workspace and sets the ones you pass, on every run:
on an existing one a member your code no longer lists is removed (and so taken out of its
channels), a new one added, and `budget_usd_per_month` and `logo_url` set to yours.
A field you leave out is never changed, and `None` clears the cap or the logo.
`create_if_missing=True` makes it with the fields `create` takes when there's none;
without it, a missing workspace raises `noclick.NotFound`. Each run
with fields is a write: set them at startup or in a setup script, and take the bare
`from_name` in request handlers.

Parameters:

- `name` (`str`, required)
- `create_if_missing` (`bool`, default `False`)
- `members` (`Sequence[Any] | None`, default `None`)
- `budget_usd_per_month` (`Any`, default: unchanged)
- `logo_url` (`Any`, default: unchanged)
- `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: `Workspace` A workspace that loads (or is made, or has your fields set) the first time it's used.
Nothing is sent yet.

Usage:

One workspace per customer company, set on every deploy:

```python
billing = noclick.Agent.from_name("billing")
acme = noclick.Workspace.from_name(
    "Acme", create_if_missing=True, members=[billing, noclick.User.from_id("ana")],
    budget_usd_per_month=200,
)
room = noclick.Channel.from_name("billing", workspace=acme, create_if_missing=True, members=[billing])
```

### Workspace.from_id

```python
noclick.Workspace.from_id(workspace_id, *, client=None, user=...) -> Workspace
```

A lazy reference to a workspace by id.

Parameters:

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

Returns: `Workspace` A workspace that loads the first time you read a field. Nothing is sent yet.

Usage:

```python
acme = noclick.Workspace.from_id("2f6c1a9e-4b7d-4c3e-9a8f-5d1e7b0c3a62")
print([room.name for room in acme.channels()])
```

### Workspace.get

```python
noclick.Workspace.get(workspace_id, *, user=..., client=None) -> Workspace
```

Load a workspace by id now; an unknown id raises `noclick.NotFound`, and so
does a user's workspace loaded without that user.

Parameters:

- `workspace_id` (`str`, required)
- `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: `Workspace` The workspace, loaded, with its `members`.

Usage:

```python
acme = noclick.Workspace.get("2f6c1a9e-4b7d-4c3e-9a8f-5d1e7b0c3a62")
print(acme.name, acme.spent_usd, acme.budget_usd_per_month)
```

### Workspace.list

```python
noclick.Workspace.list(
    *, status=None, agent=None, limit=None, user_filter=None, user=..., client=None
) -> list[Workspace]
```

The current user's workspaces (your account's outside `as_user`, or those
`user_filter` covers); `status` keeps `active` or `archived` ones, `agent`
(a `noclick.Agent` or its id) the ones that agent is a member of.

Parameters:

- `status` (`str | None`, default `None`)
- `agent` (`Any`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.
- `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: `list[Workspace]` Every matching workspace, newest first, fetched page by page.

Usage:

```python
for workspace in noclick.Workspace.list(status="active"):
    print(workspace.name, workspace.channel_count, workspace.spent_usd)
```

### Workspace.list_page

```python
noclick.Workspace.list_page(
    *, cursor=None, limit=None, status=None, agent=None, user_filter=None, user=...,
    client=None
) -> Page
```

One page of workspaces; pass `next_cursor` back as `cursor`; `agent` is as in `list`.

Parameters:

- `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.
- `status` (`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: `Page` A page whose `data` holds the workspaces and whose `next_cursor` is `None` on the last page.

Usage:

```python
page = noclick.Workspace.list_page(limit=50, user_filter=noclick.ALL_USERS)
while True:
    for workspace in page.data:
        print(workspace.user_id, workspace.name)
    if page.next_cursor is None:
        break
    page = noclick.Workspace.list_page(limit=50, user_filter=noclick.ALL_USERS, cursor=page.next_cursor)
```

### Workspace.update

```python
ws.update(*, name=..., logo_url=..., budget_usd_per_month=...) -> Workspace
```

Rename it, or change its logo or its monthly cap (`None` clears either).

Parameters:

- `name` (`Any`, default: unchanged)
- `logo_url` (`Any`, default: unchanged)
- `budget_usd_per_month` (`Any`, default: unchanged)

Returns: `Workspace` This workspace, updated.

Usage:

```python
acme = noclick.Workspace.from_name("Acme")
acme.update(budget_usd_per_month=500, logo_url="https://cdn.acme.test/logo-dark.png")
```

### Workspace.set_logo

```python
ws.set_logo(image, *, mime_type=None) -> Workspace
```

Upload its logo (a path, bytes or a binary file object): a JPEG, PNG,
WebP or GIF of at most 2 MB, kept as an account file that `logo_url`
then points at. Bytes or a file object without a name need `mime_type`.

Parameters:

- `image` (`Any`, required)
- `mime_type` (`str | None`, default `None`)

Returns: `Workspace` This workspace, with its new `logo_url`.

Usage:

```python
acme = noclick.Workspace.from_name("Acme")
acme.set_logo("acme-logo.png")
print(acme.logo_url)
```

### Workspace.archive

```python
ws.archive() -> Workspace
```

Put it away: its channels close (their turns in flight are canceled) and its
subscriptions stop, and everything in it stays readable. An archived workspace takes
no changes (`noclick.Conflict`), and its name is free for a new one.

Returns: `Workspace` This workspace, `archived`.

Usage:

```python
acme = noclick.Workspace.from_name("Acme")
acme.archive()
print(acme.status)   # archived
```

### Workspace.delete

```python
ws.delete() -> TrashItem
```

Move it to the trash with its channels (their messages, DMs and files), its invites and its own NoClick,
restorable for 30 days as it was. Its people lose it meanwhile; your agents and users stay.

Returns: `TrashItem` Its `TrashItem`: `restore()` brings it all back.

Usage:

```python
noclick.Workspace.from_name("Acme").delete()
```

### Workspace.unarchive

```python
ws.unarchive() -> Workspace
```

Make an archived workspace active again: the channels its archiving closed open again, and its
subscriptions hear again. Its name must be free among your active workspaces (`noclick.Conflict`).

Returns: `Workspace` This workspace, `active`.

Usage:

```python
acme = noclick.Workspace.get(workspace_id)
acme.unarchive()
```

### Workspace.channels

```python
ws.channels(*, status=None) -> list[Channel]
```

Its channels, newest first: `Channel.list(workspace=...)`.

Parameters:

- `status` (`str | None`, default `None`)

Returns: `list[Channel]` Every channel in it (`status` keeps `open` or `closed` ones).

Usage:

```python
acme = noclick.Workspace.from_name("Acme")
for room in acme.channels(status="open"):
    print(room.name, [member.name for member in room.members])
```

### Workspace.add

```python
ws.add(member, *, role=None) -> WorkspaceMember
```

Add a `noclick.Agent` of its scope or a `noclick.User` (an account workspace
takes any of your users; a user's own, only that user), a user with its `role`
(`member` by default). Its channels can then take them as members; one already in
it raises `noclick.Conflict`.

Parameters:

- `member` (`Any`, required)
- `role` (`str | None`, default `None`)

Returns: `WorkspaceMember` The member as the workspace now holds it.

Usage:

```python
acme = noclick.Workspace.from_name("Acme")
acme.add(noclick.Agent.from_name("onboarding"))
acme.add(noclick.User.from_id("carla"))
```

### Workspace.set_role

```python
ws.set_role(member, role) -> WorkspaceMember
```

Change a person's role (`admin`, `member` or `guest`): the workspace's owner,
or an admin of it.

Parameters:

- `member` (`Any`, required)
- `role` (`str`, required)

Returns: `WorkspaceMember` The member with its new role.

Usage:

```python
ana = next(m for m in acme.members if m.name == "Ana")
acme.set_role(ana, "admin")
```

### Workspace.invite_link

```python
ws.invite_link(*, role=None, expires_in_days=None, max_uses=None) -> WorkspaceInvite
```

A link anyone signed in to NoClick may use to join (its `url`), as `role`
(`member` by default), at most `max_uses` times, for `expires_in_days` (30 by
default, at most 90). People who join become users of your account, and what they do
in the workspace bills it. Its owner or an admin; 50 invites a day.

Parameters:

- `role` (`str | None`, default `None`)
- `expires_in_days` (`int | None`, default `None`)
- `max_uses` (`int | None`, default `None`)

Returns: `WorkspaceInvite` The invite, with its `url` to share.

Usage:

```python
link = acme.invite_link(role="guest", max_uses=5)
print(link.url)
```

### Workspace.invite

```python
ws.invite(email, *, role=None) -> WorkspaceInvite
```

Email `email` an invite, good for 7 days, that only a NoClick sign-in with that
email accepts; inviting an address already invited sends that invite again.

Parameters:

- `email` (`str`, required)
- `role` (`str | None`, default `None`)

Returns: `WorkspaceInvite` The invite.

Usage:

```python
acme.invite("dee@example.com", role="member")
```

### Workspace.invites

```python
ws.invites(*, status=None) -> list[WorkspaceInvite]
```

Its invites, newest first; `status` keeps one (`active`, `accepted`,
`revoked`, `expired`, `used_up`).

Parameters:

- `status` (`str | None`, default `None`)

Returns: `list[WorkspaceInvite]` Its invites.

Usage:

```python
pending = acme.invites(status="active")
```

### Workspace.resources

```python
ws.resources(*, kind=None) -> list[WorkspaceResource]
```

What your account shares with it (`kind` keeps one); a person in it reads what
reaches them, with their `level`.

Parameters:

- `kind` (`str | None`, default `None`)

Returns: `list[WorkspaceResource]` The shared resources, oldest first.

Usage:

```python
for shared in acme.resources():
    print(shared.kind, shared.name, shared.members_level)
```

### Workspace.share

```python
ws.share(kind, ref, *, members_level=None, guests_level=None) -> WorkspaceResource
```

Share one of your account's resources with it (its id, or the object): every
person in it gets it at `members_level` (the kind's default when left out) or, a
guest, `guests_level` (`none`), and anyone who joins later. `kind` is one of
`connection`, `app`, `database`, `files`, `repo`, `skill`, `memory`,
`machine`; a connection is shared by its id.

Parameters:

- `kind` (`str`, required)
- `ref` (`Any`, required)
- `members_level` (`str | None`, default `None`)
- `guests_level` (`str | None`, default `None`)

Returns: `WorkspaceResource` The shared resource.

Usage:

```python
acme.share("database", orders_db, members_level="read")
acme.share("machine", dev_box, members_level="use")   # its people place agents there
```

### Workspace.messages

```python
ws.messages(*, since=None, after=None, limit=None) -> list[ChannelMessage]
```

What was said across its open channels since `since` (a `datetime` with its
timezone, or an ISO time; the last 24 hours when left out), in one read: each message
of a channel's main timeline posted since then, or whose thread had a reply since
(`reply_count`; read the replies with the channel's `replies`), with its
`channel_name`. Only the channels you see in it, never a DM.

Parameters:

- `since` (`Any`, default `None`)
- `after` (`Any`, default `None`)
- `limit` (`int | None`, default `None`): Return at most this many.

Returns: `list[ChannelMessage]` Up to `limit` (50 by default) messages, oldest first: pass the last one as
`after` to read on.

Usage:

```python
from datetime import datetime

today = datetime.now().astimezone().replace(hour=0, minute=0, second=0, microsecond=0)
for message in acme.messages(since=today):
    print(f"#{message.channel_name} {message.author.name}: {message.text}")
```

### Workspace.summary

```python
ws.summary() -> dict[str, Any]
```

Its Resources tab in one read: `{workspace_id, kinds}`, `kinds` holding
`agents` (`working`, `waiting`, `idle`), `machines` (`up`, and `shared`:
the machines shared with it, each with the agents here placed on it), `channels`,
`numbers`, `email` and each shareable kind as the tab names it (`connections`,
`websites`, `databases`, `files`, `code`, `skills`, `memories`), each
`{count, items}`.

Returns: `dict[str, Any]` The summary.

Usage:

```python
print(acme.summary()["kinds"]["agents"]["working"])
```

### Workspace.mine

```python
noclick.Workspace.mine(*, client=None) -> list[MyWorkspace]
```

The workspaces you see, signed in to NoClick: your account's active ones (`own`,
role `owner`), then the active ones you joined in other accounts, with your role and
whose each is, then your account's archived ones (`status` archived), which
`unarchive` brings back. One of the account's own secret keys reads the account's own
ones, its personal space's included, never those you joined.

Parameters:

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

Returns: `list[MyWorkspace]` Each workspace as you see it.

Usage:

```python
for space in noclick.Workspace.mine():
    print(space.name, space.role, space.account_name)
```

### Workspace.session

```python
noclick.Workspace.session(workspace, *, ttl_s=None, client=None) -> Session
```

A session acting as you in a workspace you joined: `session.client()` reads and
posts in its channels and talks to its agents, as your user in its account. It lasts
`ttl_s` (an hour by default, at most a day): mint another before it lapses.

Parameters:

- `workspace` (`Any`, required)
- `ttl_s` (`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: `Session` The session, its `token` your page's key for that workspace.

Usage:

```python
space = noclick.Workspace.mine()[1]
as_me = noclick.Workspace.session(space).client()
noclick.Channel.list(client=as_me)
```

### Workspace.questions

```python
noclick.Workspace.questions(workspace, *, client=None) -> list[SpaceQuestion]
```

What your own NoClick asked a space's NoClick (a space you own or joined), newest
first, each with its answer once it came: read with your own key, or a `session`
in the space.

Parameters:

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

Returns: `list[SpaceQuestion]` Each question: `waiting` until it's answered once, then `answered` with its
`answer`, or `unanswered` when the space's NoClick couldn't.

Usage:

```python
for asked in noclick.Workspace.questions(space):
    print(asked.question, asked.status, asked.answer)
```

### Workspace.leave

```python
noclick.Workspace.leave(workspace, *, client=None) -> None
```

Leave a workspace you joined, and each of its channels.

Parameters:

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

Returns: `None`; it's gone from `mine()` at once.

Usage:

```python
noclick.Workspace.leave(space)
```

### Workspace.invitation

```python
noclick.Workspace.invitation(token, *, client=None) -> dict[str, Any]
```

What an invite is for, read without joining (signed in): `{workspace: {id, name, logo_url}, account_name, invited_by, role, type, email, status, already_member}`.

Parameters:

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

Returns: `dict[str, Any]` The invite as its page shows it.

Usage:

```python
print(noclick.Workspace.invitation(token)["workspace"]["name"])
```

### Workspace.accept_invite

```python
noclick.Workspace.accept_invite(token, *, client=None) -> MyWorkspace
```

Join an invite's workspace as yourself (signed in): you become a user of its
account, your id there your login id.

Parameters:

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

Returns: `MyWorkspace` The workspace as `mine()` lists it.

Usage:

```python
space = noclick.Workspace.accept_invite(token)
noclick.Workspace.session(space)
```

### Workspace.remove

```python
ws.remove(member) -> None
```

Take a member out of the workspace and every one of its channels: a
`WorkspaceMember`, its id, or the `noclick.Agent` or `noclick.User` you added.

Parameters:

- `member` (`Any`, required)

Usage:

```python
acme = noclick.Workspace.from_name("Acme")
acme.remove(noclick.User.from_id("bo"))
```

### Workspace.subscribe

```python
ws.subscribe(source, *, channels, wake=None, filters=None) -> Subscription
```

One subscription posting in several of its channels: `channels` is `"all"`
(every channel, ones made later too) or a list of its `Channel`s (or ids).
`source`, `wake` and `filters` are as in `channel.subscribe`, `wake`
applying in each channel (`"all"`: every agent in each). A workspace holds up to
20 subscriptions.

Parameters:

- `source` (`Any`, required)
- `channels` (`Any`, required)
- `wake` (`Any`, default `None`)
- `filters` (`dict[str, Any] | None`, default `None`)

Returns: `Subscription` The subscription, `active`.

Usage:

Every room in the workspace hears when one of its connections breaks:

```python
acme = noclick.Workspace.from_name("Acme")
acme.subscribe("connection.disconnected", channels="all")
```

Two rooms, and every agent in them, hear each failed payment:

```python
stripe = noclick.Connection.from_name("stripe", integration="stripe")
acme = noclick.Workspace.from_name("Acme")
rooms = [room for room in acme.channels() if room.name in ("billing", "support")]
acme.subscribe(noclick.OnEvent(stripe, "invoice_payment_failed"), channels=rooms, wake="all")
```

### Workspace.subscriptions

```python
ws.subscriptions() -> list[Subscription]
```

The workspace's own subscriptions (each channel's are on `channel.subscriptions()`).

Returns: `list[Subscription]` Each subscription with its `source`, the `channels` it posts in, `wake` and `status`.

Usage:

```python
acme = noclick.Workspace.from_name("Acme")
for subscription in acme.subscriptions():
    print(subscription.source, subscription.channels, subscription.status)
```

## noclick.WorkspaceMember

```python
class WorkspaceMember
```

One member of a workspace: `type` is `agent` or `user` (a person: one of
your users), with its `agent_id` or your `user_id` for them. Remove one by `id`.
A user's `role` is `admin` (invites and removes people), `member` (every channel)
or `guest` (only its own channels); a `person` joined from their own NoClick
sign-in (their `user_id` is that login's id), with their `email` and when they were
last active in NoClick (`last_seen_at`).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `type` | `str` |  |
| `agent_id` | `str | None` |  |
| `user_id` | `str | None` |  |
| `name` | `str | None` |  |
| `created_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `role` | `str | None` |  |
| `person` | `bool` |  |
| `email` | `str | None` |  |
| `last_seen_at` | `Any` |  |
| `joined_at` | `Any` |  |

## noclick.WorkspaceInvite

```python
class WorkspaceInvite
```

An invite into a workspace: a `link` anyone signed in to NoClick may use (up to
`max_uses`), or an `email` invite only that address accepts. `url` is where
accepting it opens, while it can still be used; `status` is `active`,
`accepted`, `revoked`, `expired` or `used_up`.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `workspace_id` | `str` |  |
| `type` | `str` |  |
| `role` | `str` |  |
| `email` | `str | None` |  |
| `url` | `str | None` |  |
| `uses` | `int` |  |
| `max_uses` | `int | None` |  |
| `uses_left` | `int | None` |  |
| `invited_by` | `str | None` |  |
| `status` | `str` |  |
| `expires_at` | `Any` |  |
| `created_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |
| `sent_at` | `Any` | When an email invite was last sent (`None`: a link, or not sent). |

### WorkspaceInvite.revoke

```python
workspace_invite.revoke() -> WorkspaceInvite
```

Turn it off: its link stops working at once (who joined with it stays).

Returns: `WorkspaceInvite` The invite, `revoked`.

Usage:

```python
for invite in acme.invites(status="active"):
    invite.revoke()
```

### WorkspaceInvite.resend

```python
workspace_invite.resend() -> WorkspaceInvite
```

Email an email invite again, good for another 7 days.

Returns: `WorkspaceInvite` The invite, with its new `expires_at`.

Usage:

```python
acme.invite("dee@example.com").resend()
```

### WorkspaceInvite.rotate

```python
workspace_invite.rotate() -> WorkspaceInvite
```

A link's new link: this one stops, the new one keeps its role, uses left and expiry.

Returns: `WorkspaceInvite` The new invite (its own `url`).

Usage:

```python
link = acme.invite_link()
link = link.rotate()   # the old URL no longer works
```

## noclick.MyWorkspace

```python
class MyWorkspace
```

A workspace as the signed-in person sees it (`Workspace.mine`): their account's
(`own`, `role` `owner`) or one they joined, whose it is (`account_name`) and
their `user_id` there (their login id).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `logo_url` | `str | None` |  |
| `own` | `bool` |  |
| `role` | `str` |  |
| `status` | `str | None` |  |
| `account_name` | `str | None` |  |
| `user_id` | `str | None` |  |
| `member_id` | `str | None` |  |
| `joined_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.WorkspaceResource

```python
class WorkspaceResource
```

One of your account's resources shared with a workspace: every person in it reaches
it at `members_level` (its admins and members) or `guests_level` (its guests);
`levels` are its kind's, lowest first (`agents`: through its agents only), and
`level` what you hold through it. A machine is shared for agents to run on: at
`run` the workspace's agents run there and its people see it, at `use` they may
also move its agents onto it and off it; its shell and files stay yours.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `workspace_id` | `str` |  |
| `kind` | `str` |  |
| `ref` | `str` |  |
| `name` | `str | None` |  |
| `members_level` | `str` |  |
| `guests_level` | `str` |  |
| `levels` | `list[str]` |  |
| `level` | `str | None` |  |
| `added_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### WorkspaceResource.update

```python
workspace_resource.update(*, members_level=None, guests_level=None) -> WorkspaceResource
```

Change what its members or guests get (an omitted one stays); the account's own.

Parameters:

- `members_level` (`str | None`, default `None`)
- `guests_level` (`str | None`, default `None`)

Returns: `WorkspaceResource` The shared resource with its new levels.

Usage:

```python
[orders] = acme.resources(kind="database")
orders.update(members_level="write")
```

### WorkspaceResource.remove

```python
workspace_resource.remove() -> None
```

Take it from the workspace's people; your account keeps it, and agents that hold
it as their own keep it.

Returns: `None`.

Usage:

```python
orders.remove()
```

## noclick.SpaceQuestion

```python
class SpaceQuestion
```

A question your own NoClick asked a space's NoClick (`Workspace.questions`):
`waiting` until it's answered once, then `answered` with its `answer`, or
`unanswered` when the space's NoClick couldn't.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `workspace_id` | `str` |  |
| `question` | `str` |  |
| `status` | `str` |  |
| `answer` | `str | None` |  |
| `asked_at` | `Any` |  |
| `answered_at` | `Any` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

## noclick.ChannelAttachment

```python
noclick.ChannelAttachment = Attachment
```

A file on a channel's message: an `Attachment`.
