Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(core): add connection param to connectedAccounts.update() for credential patching
The update() method only supported alias changes. Add the connection param so users can also update credentials (token, api_key, etc.) via the SDK, matching the Python SDK and the PATCH API endpoint.
Dhawal Upadhyay committed
Apr 10, 2026 at 10:43 UTC
ea7a0d2fb47c58f620223eb2153bffaca3d94539
2 files changed
+30
-6
ts/packages/core/src/models/ConnectedAccounts.ts
+13
-6
@@ -467,20 +467,26 @@ export class ConnectedAccounts {
467
}
468
469
/**
470
- * Update a connected account's alias.
470
+ * Update a connected account's alias and/or credentials.
471
*
472
* @param {string} nanoid - The unique identifier of the connected account
473
* @param {UpdateConnectedAccountParams} params - The update parameters
474
- * @param {string} params.alias - Human-readable alias for the account. Must be unique per userId and toolkit within the project. Pass an empty string to clear.
474
* @returns {Promise<ConnectedAccountPatchResponse>} The update response
475
*
476
* @example
477
* ```typescript
478
* // Set an alias
480
- * await composio.connectedAccounts.update('conn_abc123', { alias: 'work-gmail' });
481
- *
482
- * // Clear an alias
483
- * await composio.connectedAccounts.update('conn_abc123', { alias: '' });
479
+ * await composio.connectedAccounts.update('ca_abc123', { alias: 'work-gmail' });
480
+ *
481
+ * // Update credentials
482
+ * await composio.connectedAccounts.update('ca_abc123', {
483
+ * connection: {
484
+ * state: {
485
+ * authScheme: 'BEARER_TOKEN',
486
+ * val: { token: 'new-access-token' },
487
+ * },
488
+ * },
489
+ * });
490
* ```
491
*/
492
async update(
@@ -496,6 +502,7 @@ export class ConnectedAccounts {
502
503
return this.client.connectedAccounts.patch(nanoid, {
504
alias: parsedParams.data.alias,
505
+ connection: parsedParams.data.connection,
506
});
507
}
508
}
ts/packages/core/src/types/connectedAccounts.types.ts
+17
@@ -216,9 +216,26 @@ export type ConnectedAccountRefreshOptions = z.infer<typeof ConnectedAccountRefr
216
export const UpdateConnectedAccountParamsSchema = z.object({
217
alias: z
218
.string()
219
+ .optional()
220
.describe(
221
'Human-readable alias for the account. Must be unique per userId and toolkit within the project. Pass an empty string to clear the alias.'
222
),
223
+ connection: z
224
+ .object({
225
+ state: z.object({
226
+ authScheme: z.enum([
227
+ 'BEARER_TOKEN',
228
+ 'API_KEY',
229
+ 'BASIC',
230
+ 'BASIC_WITH_JWT',
231
+ 'GOOGLE_SERVICE_ACCOUNT',
232
+ 'SERVICE_ACCOUNT',
233
+ ]),
234
+ val: z.record(z.unknown()),
235
+ }),
236
+ })
237
+ .optional()
238
+ .describe('Credential fields to update. Only provided fields are changed — omitted fields are preserved. Set a field to null to remove it.'),
239
});
240
export type UpdateConnectedAccountParams = z.infer<typeof UpdateConnectedAccountParamsSchema>;
241