---
title: "Tool sessions"
description: "Context4 tool sessions: create and configure sessions, discover exposed actions and retrieve dynamic MCP URLs through the API."
group: "Technical documentation"
order: 34
---

## Deployment addresses

- Documentation: https://ctx4.me/docs.md
- Agent index: https://ctx4.me/docs/agent-index.json
- Console and connections: https://console.ctx4.me/integrations
- MCP: https://ctx4.me/mcp
- HTTP API: https://ctx4.me/v1
- Composio base URL: https://ctx4.me/compat/context4/v1
- OpenAPI: https://ctx4.me/docs/openapi.json
- HTTP/MCP inventory: https://ctx4.me/docs/api-index.json
- Composio routes: https://ctx4.me/docs/compat-routes.json
- Connectors: https://ctx4.me/docs/connectors.json


# Tool sessions

Generated from the public Context4 OpenAPI. Authenticate with `Authorization: Bearer` and an API key. General rules: [API](https://ctx4.me/docs/api.md). Full contract: [OpenAPI JSON](https://ctx4.me/docs/openapi.json). In the JSON below, `$ref` points to a named schema in the Schemas section.

## createToolSession

`POST /v1/tool-sessions`

Deployment URL: `https://ctx4.me/v1/tool-sessions`. Replace parameters in braces with actual IDs from the API.

Create a tool session (returns the per-session MCP URL)

Capability: `tool-sessions:write`.

### Parameters

| Name | Location | Required | Type and constraints |
| --- | --- | --- | --- |
| `Idempotency-Key` | header | yes | &#123;"type":"string"&#125; Client-chosen key (8-128 chars of [A-Za-z0-9._:-]); replays with the same payload return the original outcome |

### Request body

Required. [CreateToolSessionRequest](https://ctx4.me/docs/api-schemas-3.md#createtoolsessionrequest)

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/CreateToolSessionRequest"
      }
    }
  }
}
```

### Responses and errors

| HTTP | Meaning | Format and schema |
| --- | --- | --- |
| 201 | The created session with its per-session MCP URL | `application/json` [ToolSessionWithMcp](https://ctx4.me/docs/api-schemas-3.md#toolsessionwithmcp) |
| 400 | Problem (validation_failed) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 401 | Problem (authentication_required, invalid_api_key, api_key_expired, api_key_revoked) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 403 | Problem (capability_missing, forbidden) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 404 | Problem (not_found) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 409 | Problem (conflict) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 429 | Problem (rate_limited) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 500 | Problem (internal) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 503 | Problem (service_unavailable) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |

Successful response headers:
```json
{
  "X-Request-Id": {
    "description": "Correlation id echoed on every response",
    "schema": {
      "type": "string"
    }
  },
  "RateLimit-Limit": {
    "description": "Per-key request limit for the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Remaining": {
    "description": "Requests remaining in the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Reset": {
    "description": "Seconds until the current window resets",
    "schema": {
      "type": "integer"
    }
  }
}
```

## getToolSession

`GET /v1/tool-sessions/{toolSessionId}`

Deployment URL: `https://ctx4.me/v1/tool-sessions/{toolSessionId}`. Replace parameters in braces with actual IDs from the API.

Get one tool session with its configuration

Capability: `tool-sessions:read`.

### Parameters

| Name | Location | Required | Type and constraints |
| --- | --- | --- | --- |
| `toolSessionId` | path | yes | &#123;"type":"string","format":"uuid","example":"9b2f6f2e-4b0a-4bd2-8b7e-3f8a1c2d4e5f"&#125;  |

### Responses and errors

| HTTP | Meaning | Format and schema |
| --- | --- | --- |
| 200 | The session view including its configuration | `application/json` [ToolSession](https://ctx4.me/docs/api-schemas-3.md#toolsession) |
| 400 | Problem (validation_failed) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 401 | Problem (authentication_required, invalid_api_key, api_key_expired, api_key_revoked) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 403 | Problem (capability_missing, forbidden) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 404 | Problem (not_found) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 429 | Problem (rate_limited) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 500 | Problem (internal) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 503 | Problem (service_unavailable) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |

Successful response headers:
```json
{
  "X-Request-Id": {
    "description": "Correlation id echoed on every response",
    "schema": {
      "type": "string"
    }
  },
  "RateLimit-Limit": {
    "description": "Per-key request limit for the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Remaining": {
    "description": "Requests remaining in the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Reset": {
    "description": "Seconds until the current window resets",
    "schema": {
      "type": "integer"
    }
  }
}
```

## patchToolSession

`PATCH /v1/tool-sessions/{toolSessionId}`

Deployment URL: `https://ctx4.me/v1/tool-sessions/{toolSessionId}`. Replace parameters in braces with actual IDs from the API.

Update session tool enablement (CAS)

Capability: `tool-sessions:write`.

### Parameters

| Name | Location | Required | Type and constraints |
| --- | --- | --- | --- |
| `toolSessionId` | path | yes | &#123;"type":"string","format":"uuid","example":"9b2f6f2e-4b0a-4bd2-8b7e-3f8a1c2d4e5f"&#125;  |

### Request body

Required. [PatchToolSessionRequest](https://ctx4.me/docs/api-schemas-3.md#patchtoolsessionrequest)

```json
{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/PatchToolSessionRequest"
      }
    }
  }
}
```

### Responses and errors

| HTTP | Meaning | Format and schema |
| --- | --- | --- |
| 200 | The updated session view | `application/json` [ToolSession](https://ctx4.me/docs/api-schemas-3.md#toolsession) |
| 400 | Problem (validation_failed) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 401 | Problem (authentication_required, invalid_api_key, api_key_expired, api_key_revoked) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 403 | Problem (capability_missing, forbidden) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 404 | Problem (not_found) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 409 | Problem (conflict) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 429 | Problem (rate_limited) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 500 | Problem (internal) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 503 | Problem (service_unavailable) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |

Successful response headers:
```json
{
  "X-Request-Id": {
    "description": "Correlation id echoed on every response",
    "schema": {
      "type": "string"
    }
  },
  "RateLimit-Limit": {
    "description": "Per-key request limit for the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Remaining": {
    "description": "Requests remaining in the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Reset": {
    "description": "Seconds until the current window resets",
    "schema": {
      "type": "integer"
    }
  }
}
```

## listToolSessionTools

`GET /v1/tool-sessions/{toolSessionId}/tools`

Deployment URL: `https://ctx4.me/v1/tool-sessions/{toolSessionId}/tools`. Replace parameters in braces with actual IDs from the API.

Session-scoped tool discovery (pinned snapshot, exposed tools only)

Capability: `tool-sessions:read`.

### Parameters

| Name | Location | Required | Type and constraints |
| --- | --- | --- | --- |
| `toolSessionId` | path | yes | &#123;"type":"string","format":"uuid","example":"9b2f6f2e-4b0a-4bd2-8b7e-3f8a1c2d4e5f"&#125;  |
| `cursor` | query | no | &#123;"type":"string","minLength":1,"maxLength":400,"pattern":"^[A-Za-z0-9_-]+$","description":"Opaque pagination cursor from a previous response"&#125; Opaque pagination cursor from a previous response |
| `limit` | query | no | &#123;"type":"integer","minimum":1,"maximum":100,"description":"Page size (1-100, default 20)"&#125; Page size (1-100, default 20) |

### Responses and errors

| HTTP | Meaning | Format and schema |
| --- | --- | --- |
| 200 | The session's exposed tools with pinned schemas | `application/json` [SessionToolListResponse](https://ctx4.me/docs/api-schemas-3.md#sessiontoollistresponse) |
| 400 | Problem (validation_failed) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 401 | Problem (authentication_required, invalid_api_key, api_key_expired, api_key_revoked) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 403 | Problem (capability_missing, forbidden) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 404 | Problem (not_found) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 429 | Problem (rate_limited) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 500 | Problem (internal) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |
| 503 | Problem (service_unavailable) | `application/problem+json` [Problem](https://ctx4.me/docs/api-schemas-1.md#problem) |

Successful response headers:
```json
{
  "X-Request-Id": {
    "description": "Correlation id echoed on every response",
    "schema": {
      "type": "string"
    }
  },
  "RateLimit-Limit": {
    "description": "Per-key request limit for the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Remaining": {
    "description": "Requests remaining in the current window",
    "schema": {
      "type": "integer"
    }
  },
  "RateLimit-Reset": {
    "description": "Seconds until the current window resets",
    "schema": {
      "type": "integer"
    }
  }
}
```

