Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs(proxy-execute): address review feedback

Devin AIf17f5b6b28dc
diff --git a/docs/content/docs/proxy-execute.mdx b/docs/content/docs/proxy-execute.mdx
index c87a91361..4727086a6 100644
--- a/docs/content/docs/proxy-execute.mdx
+++ b/docs/content/docs/proxy-execute.mdx
@@ -15,7 +15,7 @@ Proxy execute is a form of [direct tool execution](/docs/sessions-vs-direct-exec
## When to use proxy execute
-### 1. Custom API calls when native tools don't cover your use case
+### 1. Endpoints not covered by a predefined tool
You need a specific endpoint on a toolkit (for example, an unusual LinkedIn or Notion endpoint) that isn't exposed as a predefined Composio tool. Instead of extracting the raw OAuth token and making the call yourself, send the request through proxy execute and let Composio attach credentials.
@@ -49,14 +49,14 @@ console.log(data);
</Tab>
</Tabs>
-### 2. Direct Google, Microsoft, or other toolkit API calls
+### 2. Request shapes a predefined tool cannot express
AI workflows that talk to Gmail, Drive, Sheets, Outlook, or Teams often need request shapes beyond the pre-built actions — custom query parameters, partial field masks, advanced filters. Proxy execute gives you the full HTTP surface of the upstream API while keeping auth managed by Composio.
<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
<Tab value="Python">
```python
-# Read a specific range from a Google Sheet with a custom valueRenderOption
+# Read a Google Sheet range with custom render options
response = composio.tools.proxy(
endpoint="/v4/spreadsheets/1abc.../values/Sheet1!A1:D100",
method="GET",
@@ -75,7 +75,7 @@ print(response["data"])
import { Composio } from '@composio/core';
const composio = new Composio({ apiKey: 'your_api_key' });
// ---cut---
-// Read a specific range from a Google Sheet with a custom valueRenderOption
+// Read a Google Sheet range with custom render options
const { data } = await composio.tools.proxyExecute({
endpoint: '/v4/spreadsheets/1abc.../values/Sheet1!A1:D100',
method: 'GET',
@@ -93,45 +93,22 @@ console.log(data);
### 3. Terminal and CLI agents that would otherwise use raw tokens
-Agents running in a terminal often fall back to `curl` commands with a hardcoded bearer token. Routing those calls through proxy execute keeps credentials server-side and avoids leaking tokens into shell history, log files, or process state.
+Agents running in a terminal often fall back to `curl` calls with a hardcoded bearer token. Replacing that with a call to Composio's proxy endpoint keeps user credentials server-side — no tokens in shell history, env files, or process state.
-<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
-<Tab value="Python">
-```python
-# Equivalent of: curl -H "Authorization: Bearer $TOKEN" https://api.github.com/user/repos
-response = composio.tools.proxy(
- endpoint="/user/repos",
- method="GET",
- connected_account_id="ca_github_user_123",
- parameters=[
- {"name": "per_page", "value": "50", "type": "query"},
- {"name": "sort", "value": "updated", "type": "query"},
- ],
-)
-
-print(response["data"])
-```
-</Tab>
-<Tab value="TypeScript">
-```typescript
-import { Composio } from '@composio/core';
-const composio = new Composio({ apiKey: 'your_api_key' });
-// ---cut---
-// Equivalent of: curl -H "Authorization: Bearer $TOKEN" https://api.github.com/user/repos
-const { data } = await composio.tools.proxyExecute({
- endpoint: '/user/repos',
- method: 'GET',
- connectedAccountId: 'ca_github_user_123',
- parameters: [
- { name: 'per_page', value: '50', in: 'query' },
- { name: 'sort', value: 'updated', in: 'query' },
- ],
-});
-
-console.log(data);
+```bash
+curl --location 'https://backend.composio.dev/api/v3.1/tools/execute/proxy' \
+ --header "x-api-key: $COMPOSIO_API_KEY" \
+ --header 'Content-Type: application/json' \
+ --data '{
+ "endpoint": "/user/repos",
+ "method": "GET",
+ "connected_account_id": "ca_github_user_123",
+ "parameters": [
+ { "name": "per_page", "value": "50", "type": "query" },
+ { "name": "sort", "value": "updated", "type": "query" }
+ ]
+ }'
```
-</Tab>
-</Tabs>
## Quick start
@@ -176,7 +153,7 @@ console.log(data);
</Tab>
</Tabs>
-The `endpoint` can be an **absolute URL** (`https://api.example.com/v1/resource`) or a **relative path** (`/v1/resource`). Relative paths are resolved against the toolkit's default base URL, so you only need the absolute form when calling a host that isn't the toolkit's standard API (for example, a regional Salesforce or Zendesk domain).
+The `endpoint` can be an **absolute URL** (`https://api.example.com/v1/resource`) or a **relative path** (`/v1/resource`). Relative paths are resolved against the toolkit's default base URL — only use the absolute form when calling a host that isn't the toolkit's standard API (for example, a regional Salesforce or Zendesk domain).
## Parameters
@@ -325,11 +302,11 @@ Do not set the `Authorization` header yourself — Composio injects the correct
### Uploading a file
-Use `binary_body` to upload binary content. You can either point at a URL that Composio fetches server-side or inline the bytes as base64.
+Use `binary_body` to upload binary content. You can point at a URL that Composio fetches server-side, or inline the bytes as base64.
```bash
curl --location 'https://backend.composio.dev/api/v3.1/tools/execute/proxy' \
- --header 'x-api-key: <YOUR_API_KEY>' \
+ --header "x-api-key: $COMPOSIO_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"endpoint": "/upload",
@@ -339,72 +316,22 @@ curl --location 'https://backend.composio.dev/api/v3.1/tools/execute/proxy' \
}'
```
+<Callout type="warn">
+`binary_body` posts the file as the request body with a single `Content-Type` header. It does **not** build a `multipart/form-data` payload, so APIs that require multipart uploads (for example, Twitter / X media upload, Slack `files.upload`, some Google upload endpoints) are not supported today. For those, wrap the call in a [custom tool](/docs/tools-direct/custom-tools) that constructs the multipart body yourself.
+</Callout>
+
See the [binary data changelog entry](/docs/changelog/2025/12/30) for the full upload and download flow.
## Error handling
-Proxy execute forwards the upstream response verbatim — `status`, `headers`, and `data` reflect what the toolkit API returned. Handle the common failures explicitly.
+Proxy execute forwards the upstream response verbatim — `status`, `headers`, and `data` reflect what the toolkit API returned. Check `status` and branch on the common failures.
| Status | Typical cause | How to resolve |
|---|---|---|
-| `401 Unauthorized` | The connected account's token expired, was revoked, or is for the wrong project. | Re-authenticate the user with `session.authorize()` or [import fresh credentials](/docs/importing-existing-connections). Verify the `connected_account_id` belongs to the caller's project. |
+| `400 Bad Request` | Malformed endpoint path, invalid body, or unsupported `method`. | Check the upstream API docs for the expected request shape; proxy execute does not validate upstream schemas. |
+| `401 Unauthorized` | The connected account's token expired, was revoked, or is for the wrong project. | Re-authenticate the user, or [import fresh credentials](/docs/importing-existing-connections). Verify the `connected_account_id` belongs to the caller's project. |
| `403 Forbidden` | The user's OAuth scopes or API key permissions do not cover this endpoint. | Update the [auth config scopes](/docs/auth-configuration/custom-auth-configs) and have the user re-consent. For API keys, regenerate with the required permissions. |
| `429 Too Many Requests` | Upstream rate limit (GitHub, Google, etc.). | Honor the `Retry-After` header from the response, back off exponentially, and batch requests where possible. Composio does not retry automatically. |
-| `400 Bad Request` | Malformed endpoint path, invalid body, or unsupported `method`. | Check the upstream API docs for the expected request shape; proxy execute does not validate upstream schemas. |
-
-<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
-<Tab value="Python">
-```python
-response = composio.tools.proxy(
- endpoint="/user/repos",
- method="GET",
- connected_account_id="ca_github_user_123",
-)
-
-status = response["status"]
-if status == 401:
- raise RuntimeError("Connected account needs re-authentication")
-if status == 429:
- retry_after = response["headers"].get("retry-after", "60")
- raise RuntimeError(f"Rate limited; retry after {retry_after}s")
-if status >= 400:
- raise RuntimeError(f"Upstream error {status}: {response['data']}")
-
-data = response["data"]
-```
-</Tab>
-<Tab value="TypeScript">
-```typescript
-import { Composio } from '@composio/core';
-const composio = new Composio({ apiKey: 'your_api_key' });
-// ---cut---
-const response = await composio.tools.proxyExecute({
- endpoint: '/user/repos',
- method: 'GET',
- connectedAccountId: 'ca_github_user_123',
-});
-
-if (response.status === 401) {
- throw new Error('Connected account needs re-authentication');
-}
-if (response.status === 429) {
- const retryAfter = response.headers?.['retry-after'] ?? '60';
- throw new Error(`Rate limited; retry after ${retryAfter}s`);
-}
-if (response.status >= 400) {
- throw new Error(`Upstream error ${response.status}: ${JSON.stringify(response.data)}`);
-}
-
-const data = response.data;
-```
-</Tab>
-</Tabs>
-
-## When not to use proxy execute
-
-- **When a predefined tool already covers the action.** Prefer [native tools](/docs/tools-direct/executing-tools) — they have schemas, validation, and modifier support. Falling back to a raw HTTP call removes all of that.
-- **When you need agent-managed tool calling.** Sessions (`composio.create()` + `session.tools()`) handle tool discovery, auth state, and retries for LLM-driven flows. See [Sessions vs direct execution](/docs/sessions-vs-direct-execution).
-- **When you're tempted to store the raw access token on your side.** If you are only doing this to make custom API calls, proxy execute removes the need entirely.
## What to read next