> **Building with AI coding agents?** Install the authstack plugin with one command. This equips your agent with accurate Scalekit implementation patterns.
>
> **Recommended**:
> ```bash
> npx @scalekit-inc/cli setup
> ```
>
> Global:
> ```bash
> npm install -g @scalekit-inc/cli
> scalekit setup
> ```
>
> Supports Claude Code, Cursor, GitHub Copilot, Codex + skills for other Agent Skills-compatible agents.
> Skills: integrate-agentkit, implement-saaskit, add-mcp-oauth, implement-sso, implement-scim.
> [Full setup guide](https://docs.scalekit.com/dev-kit/build-with-ai/)

---

# Search connected accounts

`GET /api/v1/connected_accounts:search`

Search for connected accounts in your environment using a text query that matches against identifiers, providers, or connectors. The search performs case-insensitive matching across account details. Returns paginated results with account status and authentication type information.

**Query parameters**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `query` | string | Yes | Search term to match against connected account identifiers, providers, or connectors. Must be at least 3 characters. Case insensitive. |
| `connection_id` | string | No | Connection ID to filter connected accounts. |
| `page_size` | integer | No | Maximum number of connected accounts to return per page. Value must be between 1 and 30. |
| `page_token` | string | No | Token from a previous response for pagination. Provide this to retrieve the next page of results. |

**Response (200)**

| Name | Type | Description |
| --- | --- | --- |
| `connected_accounts` | array of object | List of connected accounts matching the search query. Excludes sensitive authorization details. |
| `connected_accounts.authorization_type` | string (enum) | Authorization mechanism type. One of: `OAUTH`, `API_KEY`, `BASIC_AUTH`, `BEARER_TOKEN`, `CUSTOM`, `BASIC`, `OAUTH_M2M`, `TRELLO_OAUTH1`, `GOOGLE_DWD`, `TRUSTED_IDP`, `SMART_FHIR`, `NO_AUTH`. |
| `connected_accounts.connection_id` | string | Parent connection configuration reference. |
| `connected_accounts.connector` | string | The connection name, as shown in **AgentKit** > **Connections**. |
| `connected_accounts.id` | string | Unique connected account identifier. |
| `connected_accounts.identifier` | string | Your app's ID for the user, the value passed when the account was created. |
| `connected_accounts.is_org_wide_credential` | boolean | Whether this is the shared credential of an org-wide connection, which every user's tool calls on that connection use. `false` for a user's own account. |
| `connected_accounts.last_used_at` | string | Last usage timestamp. |
| `connected_accounts.provider` | string | The app the account connects to, such as `GMAIL` or `SLACK`. |
| `connected_accounts.status` | string (enum) | Current connection status. One of: `ACTIVE`, `EXPIRED`, `PENDING_AUTH`, `PENDING_VERIFICATION`, `DISCONNECTED`. |
| `connected_accounts.token_expires_at` | string | Token expiration timestamp. |
| `connected_accounts.updated_at` | string | Last modification timestamp. |
| `next_page_token` | string | Pagination token for the next page. Empty if this is the last page. |
| `prev_page_token` | string | Pagination token for the previous page. Empty if this is the first page. |
| `total_size` | integer | Total count of accounts matching the search query across all pages. |

**Errors**

- `400`: Invalid request - query parameter is too short (minimum 3 characters) or validation failed
- `401`: Authentication required - missing or invalid access token

**Request**

```bash
curl -sS -G -X GET \
  "$SCALEKIT_ENVIRONMENT_URL/api/v1/connected_accounts:search" \
  -H "Authorization: Bearer $TOKEN" \
  --data-urlencode "query=user_123"
```

**Response**

```json
{
  "connected_accounts": [
    {
      "id": "ca_24834495392086178",
      "connection_id": "conn_70219645518265104",
      "connector": "gmail",
      "identifier": "user_123",
      "provider": "GMAIL",
      "authorization_type": "OAUTH",
      "status": "ACTIVE",
      "is_org_wide_credential": false,
      "token_expires_at": "2026-10-02T15:30:00Z",
      "last_used_at": "2026-10-02T14:31:07Z",
      "updated_at": "2026-10-02T14:30:00Z"
    }
  ],
  "next_page_token": "",
  "prev_page_token": "",
  "total_size": 1
}
```

**Python:** Call this endpoint over REST, as the example shows.

```python
import os

import requests

env_url = os.environ["SCALEKIT_ENVIRONMENT_URL"]
token = requests.post(
    f"{env_url}/oauth/token",
    data={
        "grant_type": "client_credentials",
        "client_id": os.environ["SCALEKIT_CLIENT_ID"],
        "client_secret": os.environ["SCALEKIT_CLIENT_SECRET"],
    },
).json()["access_token"]

response = requests.get(
    f"{env_url}/api/v1/connected_accounts:search",
    headers={"Authorization": f"Bearer {token}"},
    params={"query": "user_123"},
)
response.raise_for_status()
result = response.json()
```

**Node.js:** Call this endpoint over REST, as the example shows.

```ts
const envUrl = process.env.SCALEKIT_ENVIRONMENT_URL!;
const tokenResponse = await fetch(`${envUrl}/oauth/token`, {
  method: "POST",
  body: new URLSearchParams({
    grant_type: "client_credentials",
    client_id: process.env.SCALEKIT_CLIENT_ID!,
    client_secret: process.env.SCALEKIT_CLIENT_SECRET!,
  }),
});
const token = (await tokenResponse.json()).access_token;

const params = new URLSearchParams({ query: "user_123" });
const response = await fetch(`${envUrl}/api/v1/connected_accounts:search?${params}`, {
  method: "GET",
  headers: {
    Authorization: `Bearer ${token}`,
  },
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const result = await response.json();
```


Part of [Connected accounts](https://docs.scalekit.com/agentkit/reference/connected-accounts/) in the [AgentKit API reference](https://docs.scalekit.com/agentkit/reference/). Authentication: https://docs.scalekit.com/agentkit/reference/authentication.md. Errors and rate limits: https://docs.scalekit.com/agentkit/reference/errors.md. Pagination: https://docs.scalekit.com/agentkit/reference/pagination.md


---

## More Scalekit documentation

| Resource | What it contains | When to use it |
|----------|-----------------|----------------|
| [/llms.txt](/llms.txt) | Structured index with routing hints per product area | Start here — find which documentation set covers your topic before loading full content |
| [/llms-full.txt](/llms-full.txt) | Complete documentation for all Scalekit products in one file | Use when you need exhaustive context across multiple products or when the topic spans several areas |
| [sitemap-0.xml](https://docs.scalekit.com/sitemap-0.xml) | Full URL list of every documentation page | Use to discover specific page URLs you can fetch for targeted, page-level answers |
