---
title: "Connect a client"
method: PUT
path: "/agents/{id}/connection"
tags: ["Connections"]
---

# Connect a client

`PUT /agents/{id}/connection`

## Request

- Base URL: `https://app.artil.ai/api`
- URL: `https://app.artil.ai/api/agents/{id}/connection`
- Auth: one of:
  - HTTP bearer
  - OAuth 2
    - Authorization code: `https://mcp.artil.ai/oauth/authorize`
    - Token URL: `https://mcp.artil.ai/oauth/token` scopes: `agent`

Make the calling client the one that hears the agent's new messages, in place of any other. Stream the agent's events with the connection's id to hear them. Only the agent's own token can connect it.

## Path parameters

- `id` string, uuid, required

## Request body

- object
  - `client` string, required
  - `machine` string

## Response `200`

The agent's new connection

- Connection
  - `id` string, uuid, required
  - `client` string, required
  - `machine` string, nullable, required
  - `tokenId` string, uuid, required: The agent's token the client connected with

## Other responses

- `4XX`: The request failed; the error says why
- `5XX`: The request failed; the error says why

---

[API](https://skmtc.dev/artil/apis/artil-api.md) - [All operations](https://skmtc.dev/artil/apis/artil-api/llms.txt) - [OpenAPI document](https://skmtc.dev/artil/apis/artil-api/revisions/55db0efa0cb8?raw)
