> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devinenterprise.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Devin ACP WebSocket API

> Connect directly to Devin over the /acp/live WebSocket using the Agent Client Protocol and a Personal Access Token to create, prompt, and stream sessions.

> [!WARNING]
>
> This endpoint does not guarantee full parity with the Agent Client Protocol (ACP) specification, and the API is currently unstable and subject to change at any time. If you need stability guarantees, contact us.

The Devin ACP WebSocket endpoint lets you connect directly to Devin Cloud using the [Agent Client Protocol (ACP)](https://agentclientprotocol.com/). Over a single persistent WebSocket, you can create sessions, send prompts, list or resume existing sessions, and stream live responses, tool calls, and task updates without polling the REST API.

## Endpoint

```text theme={null}
wss://api.devin.ai/acp/live
```

## Authentication

Authenticate with a [Personal Access Token (PAT)](https://docs.devinenterprise.com/api-reference/personal-access-tokens.md) (`cog_...`) in the `Authorization` header on the WebSocket upgrade request:

```http theme={null}
Authorization: Bearer cog_your_token_here
```

A PAT authenticates as your human user across every organization you have access to, with your normal permissions and the full ACP method set. Connections are rejected if your account disables PATs or if the token violates your account's PAT policy.

> [!NOTE]
>
> **Enterprise accounts:** If you want to connect to `/acp/live` using **service user API keys** or an **OAuth app**, reach out to your Cognition account team to request access.

## Transport and protocol

`/acp/live` speaks [Agent Client Protocol (ACP) v2](https://agentclientprotocol.com/) over WebSocket text frames (JSON-RPC 2.0). See the ACP v2 specification for framing, [initialization](https://agentclientprotocol.com/protocol/v2/initialization), [session setup](https://agentclientprotocol.com/protocol/v2/session-setup), and [prompt lifecycle](https://agentclientprotocol.com/protocol/v2/prompt-lifecycle).

Devin-specific notes:

* **Protocol version:** Pass `"protocolVersion": 2` in `initialize`.
* **Organizations and session options:** `session/new` allocates a `devin-...` `sessionId` right away and starts the session on the first `session/prompt`. Pass `_meta["cognition.ai/orgId"]` in `session/new` to target a specific organization (or omit it for your default), and use `session/set_config_option` (for example `org_id` or `repos`) before the first prompt.
* **Listing sessions:** `session/list` supports optional `_meta` filters: `cognition.ai/orgIds`, `cognition.ai/archivedStatus` (`ACTIVE`, `ARCHIVED`, or `ALL`), `cognition.ai/createdAfter`, `cognition.ai/updatedAfter`, and `cognition.ai/content`.
* **Server-initiated requests:** Reply to any server request (such as [elicitation](https://agentclientprotocol.com/protocol/v2/elicitation)) with the matching `id`, or return JSON-RPC error `-32601` for methods your client does not handle.
* **Reconnects:** Send periodic WebSocket pings and handle server-initiated closes during deploy drains or connection-age rotation by reconnecting, running `initialize`, and re-attaching with `session/resume`.

## Minimal example

This Rust example uses the [`agent-client-protocol`](https://crates.io/crates/agent-client-protocol) crate over `tokio-tungstenite` to connect with a Personal Access Token, start an ACP v2 session, send a prompt, and stream Devin's response until the turn completes.

```toml Cargo.toml theme={null}
[dependencies]
agent-client-protocol = { version = "5", features = ["unstable_protocol_v2"] }
futures-util = { version = "0.3", features = ["sink"] }
rustls = { version = "0.23", default-features = false, features = ["ring", "tls12"] }
serde_json = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "sync"] }
tokio-tungstenite = { version = "0.28", features = ["rustls-tls-native-roots"] }
```

```rust src/main.rs theme={null}
use std::io::{self, Write};

use agent_client_protocol::schema::ProtocolVersion;
use agent_client_protocol::v2::{ConnectionTo, schema};
use agent_client_protocol::{Agent, Client, Error, Lines};
use futures_util::{SinkExt, StreamExt};
use tokio::sync::mpsc::unbounded_channel;
use tokio_tungstenite::tungstenite::Message;
use tokio_tungstenite::tungstenite::client::IntoClientRequest;

const ACP_URL: &str = "wss://api.devin.ai/acp/live";

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let token = std::env::var("DEVIN_PAT")?; // cog_...
    let org_id = std::env::var("DEVIN_ORG_ID").ok();

    let mut request = ACP_URL.into_client_request()?;
    request
        .headers_mut()
        .insert("Authorization", format!("Bearer {token}").parse()?);

    let (ws, _) = tokio_tungstenite::connect_async(request).await?;
    let (ws_tx, ws_rx) = ws.split();

    let outgoing = ws_tx
        .sink_map_err(io::Error::other)
        .with(|line: String| async move {
            Ok::<_, io::Error>(Message::Text(line.trim_end().into()))
        });
    let incoming = ws_rx.filter_map(|frame| async move {
        match frame {
            Ok(Message::Text(text)) => Some(Ok(text.to_string())),
            Err(err) => Some(Err(io::Error::other(err))),
            _ => None,
        }
    });

    let (update_tx, mut update_rx) = unbounded_channel();

    Client
        .v2()
        .on_receive_notification(
            async move |notification: schema::UpdateSessionNotification,
                        _cx: ConnectionTo<Agent>| {
                update_tx
                    .send(notification)
                    .map_err(Error::into_internal_error)
            },
            agent_client_protocol::on_receive_notification!(),
        )
        .connect_with(Lines::new(outgoing, incoming), async move |cx| {
            // 1. Initialize (ACP v2)
            cx.send_request(schema::InitializeRequest::new(
                ProtocolVersion::V2,
                schema::Implementation::new("acp-quickstart", "0.1.0"),
            ))
            .block_task()
            .await?;

            // 2. Allocate a new session
            let mut new_session = schema::NewSessionRequest::new("/");
            if let Some(org_id) = org_id {
                let mut meta = serde_json::Map::new();
                meta.insert("cognition.ai/orgId".into(), org_id.into());
                new_session = new_session.meta(meta);
            }
            let opened = cx
                .build_session_from(new_session)
                .start_session()
                .block_task()
                .await?;
            let session = opened.session;

            // 3. Send the first prompt and stream updates until the turn finishes
            session
                .send_prompt("Reply with hello world.")
                .block_task()
                .await?;

            let mut observed_active = false;
            while let Some(notification) = update_rx.recv().await {
                if &notification.session_id != session.session_id() {
                    continue;
                }
                match notification.update {
                    schema::SessionUpdate::AgentMessageChunk(chunk) => {
                        if let schema::ContentBlock::Text(text) = chunk.content {
                            print!("{}", text.text);
                            let _ = io::stdout().flush();
                        }
                    }
                    schema::SessionUpdate::StateUpdate(schema::StateUpdate::Idle(idle))
                        if observed_active =>
                    {
                        println!("\nDone: {:?}", idle.stop_reason);
                        break;
                    }
                    schema::SessionUpdate::StateUpdate(_) => observed_active = true,
                    _ => {}
                }
            }

            session.close().block_task().await?;
            Ok(())
        })
        .await?;

    Ok(())
}
```

## Next steps

* [Personal Access Tokens](https://docs.devinenterprise.com/api-reference/personal-access-tokens.md) — create and manage PATs and enterprise PAT policies
* [Authentication](https://docs.devinenterprise.com/api-reference/authentication.md) — compare PATs and service user API keys
* [API Overview](https://docs.devinenterprise.com/api-reference/overview.md) — explore the Devin REST API


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.