@devries-cameron20 / composio Mirror · read-only / commits / 7a1e7db6a
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 03:37 UTC

feat(sdk): choose the Composio-managed app on auth config create (#5443)

<!-- claude-projects-attribution: {"github_login":"singhbharath03"} --> _Requested by **Bharath** · [project thread](https://claude.ai/code/project/chan_01D1BYJwu19miEBwrY92KKSU?thread=cmsg_01D1BYJwu19miEBwrY92KKSUG1RR49u43qbfrmEGhcp748)_ ## Summary Re-lands #5430 on `next`. It merged into the client-bump branch, which was rewritten before #5408 merged, so the change never reached `next`. Includes jkomyno's SDK reference regeneration (a2e6d60). [PLEN-4983](https://linear.app/composio/issue/PLEN-4983) ## Changes - TS: `authConfigs.create(slug, { type: 'use_composio_managed_auth', managedAppId })`; omitted = toolkit default. - TS: `toolkits.get(slug).composioManagedAuth[]` with `managedAppId`, `isDefault`, `mode`, `scopes`, `userScopes`. - TS: auth config create, get and list responses return `managedAppId` (`string | null`), mapped from `@composio/client` 2.1.35 types. - Python: `ComposioManagedAuthConfigOptions` adds `managed_app_id` to create options; the generated `AuthConfigUnionMember0` overload stays. Responses carry `managed_app_id` from `composio-client` 2.1.35. - Docs: regenerated SDK reference for auth configs. ## Type of change - [x] New feature ## How Has This Been Tested? `@composio/core` typecheck and vitest; Python `test_auth_configs.py` (incl. a create through the real client); mypy on `test_type_inference.py` covering both create option shapes. ## Additional context Not in scope: `toolkits.authorize` and Tool Router sessions still use the default app. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01H6YzWoF7M9fhunCQvA5wxY --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: jkomyno <alberto@composio.dev>

Bharath Singh committed Nov 19, 2026 at 01:32 UTC 7a1e7db6ab3bf004b10204178aa6c41631de0b23
13 files changed +255 -5
.changeset/managed-app-id.md new
+7
@@ -0,0 +1,7 @@
1 +---
2 +'@composio/core': minor
3 +'@composio/slim': minor
4 +'@composio/python-sdk': minor
5 +---
6 +
7 +Choose which Composio-managed app an auth config uses. `composio.toolkits.get(slug)` returns `composioManagedAuth` in TypeScript, one entry per managed app with `managedAppId` and `isDefault`. Pass that id as `managedAppId` (TypeScript) or `managed_app_id` (Python) to `composio.authConfigs.create` / `composio.auth_configs.create`; omit it for the toolkit's default app. Auth config create, get and list responses return `managedAppId` in TypeScript (`null` when the auth config isn't on a managed app).
docs/content/reference/sdk-reference/python/auth-configs.mdx
+14 -3
@@ -30,7 +30,7 @@ def list(**query: Unpack[auth_config_list_params.AuthConfigListParams]) -> auth_
30 Create a new auth config
31
32 ```python
33 -def create(toolkit: str, options: auth_config_create_params.AuthConfig) -> auth_config_create_response.AuthConfig
33 +def create(toolkit: str, options: Union[auth_config_create_params.AuthConfig, ComposioManagedAuthConfigOptions]) -> auth_config_create_response.AuthConfig
34 ```
35
36 **Parameters**
@@ -38,12 +38,23 @@ def create(toolkit: str, options: auth_config_create_params.AuthConfig) -> auth_
38 | Name | Type | Description |
39 |------|------|-------------|
40 | `toolkit` | `str` | The toolkit to create the auth config for. |
41 -| `options` | `auth_config_create_params.AuthConfig` | The options to create the auth config with. |
41 +| `options` | `Union[auth_config_create_params.AuthConfig, ComposioManagedAuthConfigOptions]` | The options to create the auth config with. For a Composio-managed auth config, `managed_app_id` picks the app. |
42
43 **Returns**
44
45 `auth_config_create_response.AuthConfig` — The created auth config.
46
47 +**Example**
48 +
49 +```python
50 +toolkit = composio.toolkits.get("slack")
51 +app = next(a for a in toolkit.composio_managed_auth if not a.is_default)
52 +composio.auth_configs.create(
53 + "slack",
54 + {"type": "use_composio_managed_auth", "managed_app_id": app.managed_app_id},
55 +)
56 +```
57 +
58 ---
59
60 ### get()
@@ -147,4 +158,4 @@ def disable(nanoid: str) -> auth_config_update_status_response.AuthConfigUpdateS
158
159 ---
160
150 -[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/auth_configs.py#L21)
161 +[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/auth_configs.py#L31)
docs/content/reference/sdk-reference/typescript/auth-configs.mdx
+9
@@ -36,6 +36,15 @@ async create(toolkit: string, options?: CreateAuthConfigParams, requestOptions?:
36
37 **Example**
38
39 +```typescript
40 +// Use a specific Composio-managed app; omit managedAppId for the toolkit's default
41 +const { composioManagedAuth } = await composio.toolkits.get('slack');
42 +const slackAuthConfig = await authConfigs.create('slack', {
43 + type: AuthConfigTypes.COMPOSIO_MANAGED,
44 + managedAppId: composioManagedAuth?.find(app => !app.isDefault)?.managedAppId,
45 +});
46 +```
47 +
48 ```typescript
49 const authConfig = await authConfigs.create('my-toolkit', {
50 type: AuthConfigTypes.CUSTOM,
python/composio/core/models/auth_configs.py
+30 -2
@@ -18,6 +18,16 @@ from composio.client.types import (
18 from composio.core.models.base import Resource
19
20
21 +class ComposioManagedAuthConfigOptions(
22 + auth_config_create_params.AuthConfigUnionMember0, total=False
23 +):
24 + """Options for an auth config on a Composio-managed app."""
25 +
26 + managed_app_id: str
27 + """The Composio-managed app to use, as ``composio_managed_auth[].managed_app_id``
28 + from ``composio.toolkits.get(slug)``. Omit to use the toolkit's default app."""
29 +
30 +
31 class AuthConfigs(Resource):
32 """
33 Manage authentication configurations.
@@ -37,20 +47,38 @@ class AuthConfigs(Resource):
47 self, toolkit: str, options: auth_config_create_params.AuthConfigUnionMember1
48 ) -> auth_config_create_response.AuthConfig: ...
49
50 + @t.overload
51 + def create(
52 + self, toolkit: str, options: ComposioManagedAuthConfigOptions
53 + ) -> auth_config_create_response.AuthConfig: ...
54 +
55 @t.overload
56 def create(
57 self, toolkit: str, options: auth_config_create_params.AuthConfigUnionMember0
58 ) -> auth_config_create_response.AuthConfig: ...
59
60 def create(
46 - self, toolkit: str, options: auth_config_create_params.AuthConfig
61 + self,
62 + toolkit: str,
63 + options: t.Union[
64 + auth_config_create_params.AuthConfig, ComposioManagedAuthConfigOptions
65 + ],
66 ) -> auth_config_create_response.AuthConfig:
67 """
68 Create a new auth config
69
70 :param toolkit: The toolkit to create the auth config for.
52 - :param options: The options to create the auth config with.
71 + :param options: The options to create the auth config with. For a
72 + Composio-managed auth config, ``managed_app_id`` picks the app.
73 :return: The created auth config.
74 +
75 + Example:
76 + toolkit = composio.toolkits.get("slack")
77 + app = next(a for a in toolkit.composio_managed_auth if not a.is_default)
78 + composio.auth_configs.create(
79 + "slack",
80 + {"type": "use_composio_managed_auth", "managed_app_id": app.managed_app_id},
81 + )
82 """
83 return self._client.auth_configs.create(
84 toolkit={"slug": toolkit}, auth_config=options
python/tests/test_auth_configs.py
+38
@@ -468,3 +468,41 @@ def test_mutation_response_through_generated_client(
468 assert result.success is True
469 assert result.message == payload["message"]
470 assert result.model_dump(exclude_unset=True) == payload
471 +
472 +
473 +def test_create_on_named_managed_app_through_generated_client():
474 + """managed_app_id reaches the API and the response says which app was used."""
475 + requests = []
476 +
477 + def handler(request: httpx.Request) -> httpx.Response:
478 + requests.append(request)
479 + return httpx.Response(
480 + 201,
481 + json={
482 + "toolkit": {"slug": "slack"},
483 + "auth_config": {
484 + "id": "ac_test",
485 + "auth_scheme": "OAUTH2",
486 + "is_composio_managed": True,
487 + "restrict_to_following_tools": [],
488 + "managed_app_id": "ma_second00001",
489 + },
490 + },
491 + )
492 +
493 + with HttpClient(
494 + provider="test",
495 + auth=ProjectAuth("test"),
496 + http_client=httpx.Client(transport=httpx.MockTransport(handler)),
497 + ) as client:
498 + result = AuthConfigs(client).create(
499 + "slack",
500 + {"type": "use_composio_managed_auth", "managed_app_id": "ma_second00001"},
501 + )
502 +
503 + assert json.loads(requests[0].content)["auth_config"] == {
504 + "type": "use_composio_managed_auth",
505 + "managed_app_id": "ma_second00001",
506 + }
507 + assert result.id == "ac_test"
508 + assert result.managed_app_id == "ma_second00001"
python/tests/test_type_inference.py
+20
@@ -151,3 +151,23 @@ def test_auth_config_response_types() -> None:
151 assert_type(enabled.success, bool)
152 assert_type(disabled.message, str)
153 assert_type(custom.model_dump(), dict[str, Any])
154 +
155 +
156 +def test_auth_config_create_option_types() -> None:
157 + """create accepts managed_app_id and still accepts the generated options type."""
158 + if TYPE_CHECKING:
159 + from composio_client.types.auth_config_create_params import (
160 + AuthConfigUnionMember0,
161 + )
162 + from composio_client.types.auth_config_create_response import AuthConfig
163 +
164 + composio = Composio()
165 + on_app = composio.auth_configs.create(
166 + "slack",
167 + {"type": "use_composio_managed_auth", "managed_app_id": "ma_test"},
168 + )
169 + generated: AuthConfigUnionMember0 = {"type": "use_composio_managed_auth"}
170 + on_default = composio.auth_configs.create("slack", generated)
171 +
172 + assert_type(on_app, AuthConfig)
173 + assert_type(on_default, AuthConfig)
ts/packages/core/src/models/AuthConfigs.ts
+9
@@ -104,6 +104,14 @@ export class AuthConfigs {
104 * @returns {Promise<CreateAuthConfigResponse>} Created auth config
105 *
106 * @example
107 + * // Use a specific Composio-managed app; omit managedAppId for the toolkit's default
108 + * const { composioManagedAuth } = await composio.toolkits.get('slack');
109 + * const slackAuthConfig = await authConfigs.create('slack', {
110 + * type: AuthConfigTypes.COMPOSIO_MANAGED,
111 + * managedAppId: composioManagedAuth?.find(app => !app.isDefault)?.managedAppId,
112 + * });
113 + *
114 + * @example
115 * const authConfig = await authConfigs.create('my-toolkit', {
116 * type: AuthConfigTypes.CUSTOM,
117 * name: 'My Custom Auth Config',
@@ -162,6 +170,7 @@ export class AuthConfigs {
170 parsedOptions.data.toolAccessConfig.toolsForConnectedAccountCreation,
171 }
172 : undefined,
173 + managed_app_id: parsedOptions.data.managedAppId,
174 },
175 };
176 const result = await withCancellation(
ts/packages/core/src/types/authConfigs.types.ts
+14
@@ -78,6 +78,11 @@ export const CreateComposioManagedAuthConfigParamsSchema = z.object({
78 .optional(),
79 toolAccessConfig: AuthConfigCreationToolAccessConfigSchema.optional(),
80 isEnabledForToolRouter: z.boolean().optional(),
81 + /**
82 + * The Composio-managed app to use, as `composioManagedAuth[].managedAppId`
83 + * from `composio.toolkits.get(slug)`. Omit to use the toolkit's default app.
84 + */
85 + managedAppId: z.string().optional(),
86 });
87
88 /**
@@ -90,11 +95,19 @@ export const CreateAuthConfigParamsSchema = z.discriminatedUnion('type', [
95
96 export type CreateAuthConfigParams = z.infer<typeof CreateAuthConfigParamsSchema>;
97
98 +/**
99 + * The Composio-managed app an auth config uses, as
100 + * `composioManagedAuth[].managedAppId` from `composio.toolkits.get(slug)`.
101 + * `null` when the auth config is not linked to a managed app.
102 + */
103 +const AuthConfigManagedAppIdSchema = z.string().nullable();
104 +
105 export const CreateAuthConfigResponseSchema = z.object({
106 id: z.string(),
107 authScheme: z.string(),
108 isComposioManaged: z.boolean(),
109 toolkit: z.string(),
110 + managedAppId: AuthConfigManagedAppIdSchema,
111 });
112 export type CreateAuthConfigResponse = z.infer<typeof CreateAuthConfigResponseSchema>;
113
@@ -120,6 +133,7 @@ export const AuthConfigRetrieveResponseSchema = z.object({
133 createdAt: z.string().optional(),
134 lastUpdatedAt: z.string().optional(),
135 toolAccessConfig: AuthConfigToolAccessConfigSchema.optional(),
136 + managedAppId: AuthConfigManagedAppIdSchema,
137 });
138 export type AuthConfigRetrieveResponse = z.infer<typeof AuthConfigRetrieveResponseSchema>;
139
ts/packages/core/src/types/toolkit.types.ts
+21
@@ -125,12 +125,32 @@ export const ToolkitAuthConfigDetailsSchema = z.object({
125 .optional(),
126 });
127
128 +const ToolkitManagedAuthScopesSchema = z.object({
129 + available: z.array(z.string()),
130 +});
131 +
132 +/**
133 + * A Composio-managed app for a toolkit. Pass `managedAppId` to
134 + * `composio.authConfigs.create` to create an auth config on this app.
135 + */
136 +export const ToolkitComposioManagedAuthSchema = z.object({
137 + managedAppId: z.string(),
138 + /** Whether this is the app used when `managedAppId` is omitted. */
139 + isDefault: z.boolean(),
140 + mode: z.string(),
141 + scopes: ToolkitManagedAuthScopesSchema,
142 + /** Present only for Slack. */
143 + userScopes: ToolkitManagedAuthScopesSchema.optional(),
144 +});
145 +
146 export const ToolkitRetrieveResponseSchema = z.object({
147 name: z.string(),
148 slug: z.string(),
149 meta: ToolKitMetaSchema,
150 isLocalToolkit: z.boolean(),
151 composioManagedAuthSchemes: z.array(z.string()).optional(),
152 + /** One entry per Composio-managed app, the default first. */
153 + composioManagedAuth: z.array(ToolkitComposioManagedAuthSchema).optional(),
154 authConfigDetails: z.array(ToolkitAuthConfigDetailsSchema).optional(),
155 baseUrl: z.string().optional(),
156 getCurrentUserEndpoint: z.string().optional(),
@@ -139,6 +159,7 @@ export const ToolkitRetrieveResponseSchema = z.object({
159
160 export type ToolkitAuthField = z.infer<typeof ToolkitAuthFieldSchema>;
161 export type ToolkitAuthConfigDetails = z.infer<typeof ToolkitAuthConfigDetailsSchema>;
162 +export type ToolkitComposioManagedAuth = z.infer<typeof ToolkitComposioManagedAuthSchema>;
163 export type ToolkitRetrieveResponse = z.infer<typeof ToolkitRetrieveResponseSchema>;
164
165 /**
ts/packages/core/src/utils/transformers/authConfigs.ts
+2
@@ -58,6 +58,7 @@ export function transformAuthConfigRetrieveResponse(
58 authConfig.tool_access_config.tools_for_connected_account_creation,
59 }
60 : undefined,
61 + managedAppId: authConfig.managed_app_id,
62 }));
63 }
64
@@ -105,5 +106,6 @@ export function transformCreateAuthConfigResponse(
106 authScheme: response.auth_config.auth_scheme,
107 isComposioManaged: response.auth_config.is_composio_managed,
108 toolkit: response.toolkit.slug,
109 + managedAppId: response.auth_config.managed_app_id,
110 }));
111 }
ts/packages/core/src/utils/transformers/toolkits.ts
+7
@@ -156,6 +156,13 @@ export const transformToolkitRetrieveResponse = (
156 },
157 isLocalToolkit: response.is_local_toolkit,
158 composioManagedAuthSchemes: response.composio_managed_auth_schemes,
159 + composioManagedAuth: response.composio_managed_auth?.map(app => ({
160 + managedAppId: app.managed_app_id,
161 + isDefault: app.is_default,
162 + mode: app.mode,
163 + scopes: app.scopes,
164 + ...(app.user_scopes != null && { userScopes: app.user_scopes }),
165 + })),
166 authConfigDetails: response.auth_config_details?.map(authConfig => ({
167 name: authConfig.name,
168 mode: authConfig.mode,
ts/packages/core/test/AuthConfigs/authConfigs.test.ts
+44
@@ -31,6 +31,7 @@ const mockComposioAuthConfigResponse: ComposioAuthConfigRetrieveResponse = {
31 { name: 'client_secret', type: 'string' },
32 ],
33 is_composio_managed: true,
34 + managed_app_id: 'ma_default0001',
35 created_by: 'user_123',
36 created_at: '2023-01-01T00:00:00Z',
37 last_updated_at: '2023-01-01T00:00:00Z',
@@ -66,6 +67,7 @@ const mockTransformedAuthConfigResponse = {
67 toolsAvailableForExecution: undefined,
68 toolsForConnectedAccountCreation: undefined,
69 },
70 + managedAppId: 'ma_default0001',
71 };
72
73 // Extended mock client with all AuthConfigs methods
@@ -107,6 +109,16 @@ describe('AuthConfigs', () => {
109 // }).toThrow(ValidationError);
110 // });
111
112 + it('keeps a null managed_app_id for auth configs not on a managed app', () => {
113 + expect(
114 + transformAuthConfigRetrieveResponse({
115 + ...mockComposioAuthConfigResponse,
116 + is_composio_managed: false,
117 + managed_app_id: null,
118 + }).managedAppId
119 + ).toBeNull();
120 + });
121 +
122 it('should handle optional fields correctly', () => {
123 const responseWithOptionalFields = {
124 id: 'auth_12345',
@@ -235,6 +247,7 @@ describe('AuthConfigs', () => {
247 id: 'auth_12345',
248 auth_scheme: 'OAUTH2',
249 is_composio_managed: true,
250 + managed_app_id: 'ma_default0001',
251 },
252 toolkit: {
253 slug: 'github',
@@ -266,6 +279,7 @@ describe('AuthConfigs', () => {
279 authScheme: 'OAUTH2',
280 isComposioManaged: true,
281 toolkit: 'github',
282 + managedAppId: 'ma_default0001',
283 });
284 });
285
@@ -275,6 +289,7 @@ describe('AuthConfigs', () => {
289 auth_config: {
290 ...mockCreateResponse.auth_config,
291 is_composio_managed: false,
292 + managed_app_id: null,
293 },
294 });
295
@@ -318,6 +333,7 @@ describe('AuthConfigs', () => {
333 authScheme: 'OAUTH2',
334 isComposioManaged: false,
335 toolkit: 'github',
336 + managedAppId: null,
337 });
338 });
339
@@ -359,7 +375,35 @@ describe('AuthConfigs', () => {
375 authScheme: 'OAUTH2',
376 isComposioManaged: true,
377 toolkit: 'github',
378 + managedAppId: 'ma_default0001',
379 + });
380 + });
381 +
382 + it('sends managedAppId as managed_app_id and returns the app the config uses', async () => {
383 + mockClient.authConfigs.create.mockResolvedValueOnce({
384 + ...mockCreateResponse,
385 + auth_config: { ...mockCreateResponse.auth_config, managed_app_id: 'ma_second00001' },
386 + });
387 +
388 + const result = await authConfigs.create('slack', {
389 + type: 'use_composio_managed_auth',
390 + managedAppId: 'ma_second00001',
391 });
392 +
393 + expect(mockClient.authConfigs.create.mock.calls[0][0].auth_config.managed_app_id).toBe(
394 + 'ma_second00001'
395 + );
396 + expect(result.managedAppId).toBe('ma_second00001');
397 + });
398 +
399 + it('omits managed_app_id when managedAppId is not given', async () => {
400 + mockClient.authConfigs.create.mockResolvedValueOnce(mockCreateResponse);
401 +
402 + await authConfigs.create('slack', { type: 'use_composio_managed_auth' });
403 +
404 + expect(mockClient.authConfigs.create.mock.calls[0][0].auth_config.managed_app_id).toBe(
405 + undefined
406 + );
407 });
408
409 it('should throw ValidationError for invalid create options', async () => {
ts/packages/core/test/utils/transformers/toolkits.test.ts
+40
@@ -176,6 +176,46 @@ describe('transformToolkitRetrieveResponse', () => {
176 expect(details?.authHintUrl).toBe('https://shopify.dev/api-keys');
177 });
178
179 + it('maps every Composio-managed app with its id, default flag and scopes', () => {
180 + const withManagedApps = {
181 + ...rawToolkit,
182 + composio_managed_auth: [
183 + {
184 + managed_app_id: 'ma_default0001',
185 + is_default: true,
186 + mode: 'OAUTH2',
187 + scopes: { available: ['channels:read'] },
188 + user_scopes: { available: ['search:read'] },
189 + },
190 + {
191 + managed_app_id: 'ma_second00001',
192 + is_default: false,
193 + mode: 'OAUTH2',
194 + scopes: { available: ['channels:read'] },
195 + },
196 + ],
197 + } as RawRetrieveResponse;
198 +
199 + const apps = transformToolkitRetrieveResponse(withManagedApps).composioManagedAuth;
200 +
201 + expect(apps).toEqual([
202 + {
203 + managedAppId: 'ma_default0001',
204 + isDefault: true,
205 + mode: 'OAUTH2',
206 + scopes: { available: ['channels:read'] },
207 + userScopes: { available: ['search:read'] },
208 + },
209 + {
210 + managedAppId: 'ma_second00001',
211 + isDefault: false,
212 + mode: 'OAUTH2',
213 + scopes: { available: ['channels:read'] },
214 + },
215 + ]);
216 + expect(apps?.[1]).not.toHaveProperty('userScopes');
217 + });
218 +
219 it('maps meta.app_url to meta.appUrl', () => {
220 const withAppUrl = {
221 ...rawToolkit,