Skip to content

Agents

List and manage agents in an account.

AgentsResource

AgentsResource(http: HTTPClient)

Bases: BaseResource

Synchronous agents resource.

list

list(account_id: int) -> list[Agent]

List all agents in the account.

Parameters:

Name Type Description Default
account_id int

The account ID

required

Returns:

Type Description
list[Agent]

List of Agent objects

Raises:

Type Description
ChatwootAuthError

If authentication fails

ChatwootPermissionError

If user doesn't have access

Examples:

>>> agents = client.agents.list(account_id=1)
... for agent in agents:
...     print(agent.name, agent.role)

get

get(account_id: int, agent_id: int) -> Agent

Get agent details.

Parameters:

Name Type Description Default
account_id int

The account ID

required
agent_id int

The agent ID

required

Returns:

Type Description
Agent

Agent object

Raises:

Type Description
ChatwootNotFoundError

If agent not found

ChatwootAuthError

If authentication fails

Examples:

>>> agent = client.agents.get(account_id=1, agent_id=10)
>>> print(agent.email)

add

add(
    account_id: int,
    name: str,
    email: str,
    role: str,
    **kwargs: Any,
) -> Agent

Add a new agent to the account.

Parameters:

Name Type Description Default
account_id int

The account ID

required
name str

Agent's name

required
email str

Agent's email

required
role str

Agent's role ('agent' or 'administrator')

required
**kwargs Any

Additional agent attributes

{}

Returns:

Type Description
Agent

Created Agent object

Raises:

Type Description
ChatwootValidationError

If validation fails

ChatwootAuthError

If authentication fails

Examples:

>>> agent = client.agents.add(
...     account_id=1,
...     name="John Doe",
...     email="john@example.com",
...     role="agent"
... )

update

update(
    account_id: int, agent_id: int, **kwargs: Any
) -> Agent

Update agent details.

Parameters:

Name Type Description Default
account_id int

The account ID

required
agent_id int

The agent ID

required
**kwargs Any

Agent attributes to update

{}

Returns:

Type Description
Agent

Updated Agent object

Raises:

Type Description
ChatwootNotFoundError

If agent not found

ChatwootValidationError

If validation fails

Examples:

>>> agent = client.agents.update(
...     account_id=1,
...     agent_id=10,
...     name="Jane Doe",
...     role="administrator"
... )

remove

remove(account_id: int, agent_id: int) -> None

Remove agent from the account.

Parameters:

Name Type Description Default
account_id int

The account ID

required
agent_id int

The agent ID to remove

required

Raises:

Type Description
ChatwootNotFoundError

If agent not found

ChatwootPermissionError

If user doesn't have permission

Examples:

>>> client.agents.remove(account_id=1, agent_id=10)

AsyncAgentsResource

AsyncAgentsResource(http: AsyncHTTPClient)

Bases: AsyncBaseResource

Asynchronous agents resource.

list async

list(account_id: int) -> list[Agent]

List all agents in the account (async).

Parameters:

Name Type Description Default
account_id int

The account ID

required

Returns:

Type Description
list[Agent]

List of Agent objects

get async

get(account_id: int, agent_id: int) -> Agent

Get agent details (async).

Parameters:

Name Type Description Default
account_id int

The account ID

required
agent_id int

The agent ID

required

Returns:

Type Description
Agent

Agent object

add async

add(
    account_id: int,
    name: str,
    email: str,
    role: str,
    **kwargs: Any,
) -> Agent

Add a new agent to the account (async).

Parameters:

Name Type Description Default
account_id int

The account ID

required
name str

Agent's name

required
email str

Agent's email

required
role str

Agent's role

required
**kwargs Any

Additional agent attributes

{}

Returns:

Type Description
Agent

Created Agent object

update async

update(
    account_id: int, agent_id: int, **kwargs: Any
) -> Agent

Update agent details (async).

Parameters:

Name Type Description Default
account_id int

The account ID

required
agent_id int

The agent ID

required
**kwargs Any

Agent attributes to update

{}

Returns:

Type Description
Agent

Updated Agent object

remove async

remove(account_id: int, agent_id: int) -> None

Remove agent from the account (async).

Parameters:

Name Type Description Default
account_id int

The account ID

required
agent_id int

The agent ID to remove

required