> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Read a channel context window

GET https://api.runtype.com/v1/surfaces/{surfaceId}/channel-context

Read the recent channel messages a Slack, Telegram or iMessage surface holds for one channel or group (at most 20, newest 24 hours, oldest first), each with the response gate decision recorded for it, and the next-turn labels recorded on those decisions. Skipped messages create no conversation, so this is where their decisions are read.

Reference: https://docs.runtype.com/api-reference/runtype-api/surfaces/read-a-channel-context-window

## Authentication

- `Authorization` header (bearer token, required) — API key or Clerk session token

## Servers

- `https://api.runtype.com` (Production, default)
- `https://api.runtype-staging.com` (Staging)

## Request

### Path parameters

- `surfaceId` (string, required)

### Query parameters

- `channelId` (string, required) — Slack channel ID, Telegram chat ID, or iMessage group ID.

## Response

### 200

The channel window with its gate decisions and labels

- `channelId` (string, required)
- `labels` (list of ChannelContextLabel, required) — Labels on decisions the channel still retains (newest 50 messages, 24 hours), oldest first. Empty until a next turn produces one.
- `messages` (list of ChannelContextMessage, required)
- `provider` (enum, required)
  - Allowed values: `slack`, `telegram`, `imessage`
- `surfaceId` (string, required)

## Errors

### 400 Bad Request Error

Invalid surface ID, or a surface type without a channel context

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 401 Unauthorized Error

Unauthorized

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 403 Forbidden Error

Insufficient permissions

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

### 404 Not Found Error

Surface not found

- `error` (string, required)
- `details` (list of ErrorDetailsItems, optional)

## Types

### ChannelContextLabel

- `decision` (ChannelContextDecision, required)
- `externalMessageId` (string, required) — The labeled message, whose decision the label judges.
- `label` (enum, required) — gate_false_negative: the assistant stayed silent and a person mentioned it soon after. gate_false_positive: the assistant replied and a person pushed back. backfill_false_negative: after a judged context backfill, a person said the answer was already above.
  - Allowed values: `gate_false_negative`, `gate_false_positive`, `backfill_false_negative`
- `labeledAt` (string, required) — ISO timestamp the label was recorded.
- `source` (enum, required) — The next-turn signal that produced the label.
  - Allowed values: `mention_after_silence`, `not_you_reply`, `negative_reaction`, `reply_deleted`, `already_said_reply`

### ChannelContextMessage

- `authorId` (string, required)
- `authorKind` (enum, required)
  - Allowed values: `user`, `assistant`, `bot`
- `decision` (ChannelContextDecision, required)
- `externalMessageId` (string, required)
- `hasAttachment` (boolean, required)
- `mentionsAssistant` (boolean, required)
- `text` (string, required) — Message text, truncated to 1,000 characters.
- `timestamp` (string, required) — ISO timestamp of the provider message.
- `threadId` (string, optional)

### ErrorDetailsItems

- `message` (string, required)
- `code` (string, optional) — Stable Runtype validation code (e.g. MISSING_REQUIRED_FIELD, INVALID_ENUM).
- `path` (string, optional) — Dotted JSON path to the offending field.
- `suggestion` (string, optional) — Actionable hint (allowed values, accepted range, …).

### ChannelContextDecision

- `activated` (boolean, required) — Whether the assistant ran for this message.
- `decision` (enum, required) — The response gate decision. not_judged means no judgment answered: the mode never asks one, or the judgment failed and the message waited for a mention.
  - Allowed values: `not_judged`, `reply`, `silent`, `band`
- `capability` (ChannelContextDecisionCapability, optional) — The capability the judgment chose on a surface with several capabilities and no entry point. In judge mode only route activates a reply.
- `failure` (enum, optional) — Why the judgment did not answer, when one was asked and failed. error: the model call failed for a reason other than a provider server error, for example a missing credential or a rejected request. upstream: the model provider returned a server error. timeout: the model budget ran out. unanswered: the model gave no decision. no_assistant: the surface has no product to describe. preparation: the pre-model loads failed or ran out of time. circuit_open: repeated upstream failures paused judgments, so none was asked. Absent on a decision that answered, and on decisions recorded before this field existed.
  - Allowed values: `error`, `upstream`, `timeout`, `unanswered`, `no_assistant`, `preparation`, `circuit_open`
- `probability` (double, optional) — The judged shouldReply probability; absent when not_judged.

### ChannelContextDecisionCapability

The capability the judgment chose on a surface with several capabilities and no entry point. In judge mode only route activates a reply.

- `outcome` (enum, required)
  - Allowed values: `route`, `clarify`, `decline`, `unanswered`
- `capabilityId` (string, optional)
- `probability` (double, optional)

## Examples

**Response**

```json
{
  "channelId": "string",
  "labels": [
    {
      "decision": {
        "activated": true,
        "decision": "not_judged",
        "capability": {
          "outcome": "route",
          "capabilityId": "string",
          "probability": 1.1
        },
        "failure": "error",
        "probability": 1.1
      },
      "externalMessageId": "string",
      "label": "gate_false_negative",
      "labeledAt": "string",
      "source": "mention_after_silence"
    }
  ],
  "messages": [
    {
      "authorId": "string",
      "authorKind": "user",
      "decision": {
        "activated": true,
        "decision": "not_judged",
        "capability": {
          "outcome": "route",
          "capabilityId": "string",
          "probability": 1.1
        },
        "failure": "error",
        "probability": 1.1
      },
      "externalMessageId": "string",
      "hasAttachment": true,
      "mentionsAssistant": true,
      "text": "string",
      "timestamp": "string",
      "threadId": "string"
    }
  ],
  "provider": "slack",
  "surfaceId": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.runtype.com/v1/surfaces/surfaceId/channel-context"

querystring = {"channelId":"channelId"}

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.runtype.com/v1/surfaces/surfaceId/channel-context?channelId=channelId';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.runtype.com/v1/surfaces/surfaceId/channel-context?channelId=channelId"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.runtype.com/v1/surfaces/surfaceId/channel-context?channelId=channelId")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.runtype.com/v1/surfaces/surfaceId/channel-context?channelId=channelId")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.runtype.com/v1/surfaces/surfaceId/channel-context?channelId=channelId', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.runtype.com/v1/surfaces/surfaceId/channel-context?channelId=channelId");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.runtype.com/v1/surfaces/surfaceId/channel-context?channelId=channelId")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```