pub struct ComposioClient { /* private fields */ }Expand description
Main client for interacting with Composio API
The client manages HTTP connections and configuration for all API requests. It includes automatic retry logic for transient failures and proper error handling.
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;Implementations§
Source§impl ComposioClient
impl ComposioClient
Sourcepub fn builder() -> ComposioClientBuilder
pub fn builder() -> ComposioClientBuilder
Create a new client builder
Returns a ComposioClientBuilder that can be used to configure and build
a ComposioClient instance.
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Get a reference to the HTTP client
This is useful for advanced use cases where you need direct access to the underlying reqwest client.
Sourcepub fn config(&self) -> &ComposioConfig
pub fn config(&self) -> &ComposioConfig
Get a reference to the configuration
Returns the configuration used by this client.
Sourcepub fn create_session(&self, user_id: impl Into<String>) -> SessionBuilder<'_>
pub fn create_session(&self, user_id: impl Into<String>) -> SessionBuilder<'_>
Create a new session for a user
Returns a SessionBuilder that can be used to configure and create
a Tool Router session for the specified user.
§Arguments
user_id- User identifier for session isolation
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let session = client
.create_session("user_123")
.toolkits(vec!["github", "gmail"])
.send()
.await?;Sourcepub async fn get_session(
&self,
session_id: impl Into<String>,
) -> Result<Session, ComposioError>
pub async fn get_session( &self, session_id: impl Into<String>, ) -> Result<Session, ComposioError>
Get an existing session by ID
Retrieves session details for a previously created Tool Router session. This is useful for inspecting session configuration and available tools.
§Arguments
session_id- The session ID to retrieve
§Errors
Returns an error if:
- Session not found (404)
- Network error occurs
- API returns an error response
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let session = client.get_session("sess_abc123").await?;
println!("Session ID: {}", session.session_id());Sourcepub async fn create_mcp_server(
&self,
params: MCPCreateParams,
) -> Result<MCPCreateResponse, ComposioError>
pub async fn create_mcp_server( &self, params: MCPCreateParams, ) -> Result<MCPCreateResponse, ComposioError>
Create an MCP server
Sourcepub async fn get_mcp_server(
&self,
id: impl Into<String>,
) -> Result<MCPItem, ComposioError>
pub async fn get_mcp_server( &self, id: impl Into<String>, ) -> Result<MCPItem, ComposioError>
Retrieve an MCP server by ID
Sourcepub async fn update_mcp_server(
&self,
id: impl Into<String>,
params: MCPUpdateParams,
) -> Result<MCPUpdateResponse, ComposioError>
pub async fn update_mcp_server( &self, id: impl Into<String>, params: MCPUpdateParams, ) -> Result<MCPUpdateResponse, ComposioError>
Update an MCP server
Sourcepub async fn delete_mcp_server(
&self,
id: impl Into<String>,
) -> Result<MCPDeleteResponse, ComposioError>
pub async fn delete_mcp_server( &self, id: impl Into<String>, ) -> Result<MCPDeleteResponse, ComposioError>
Delete an MCP server by ID
Sourcepub async fn list_mcp_servers(
&self,
params: MCPListParams,
) -> Result<MCPListResponse, ComposioError>
pub async fn list_mcp_servers( &self, params: MCPListParams, ) -> Result<MCPListResponse, ComposioError>
List MCP servers
Sourcepub async fn list_mcp_servers_for_app(
&self,
params: MCPRetrieveAppParams,
) -> Result<MCPRetrieveAppResponse, ComposioError>
pub async fn list_mcp_servers_for_app( &self, params: MCPRetrieveAppParams, ) -> Result<MCPRetrieveAppResponse, ComposioError>
List MCP servers for app-scoped retrieval endpoint
Sourcepub async fn generate_mcp_server(
&self,
params: MCPGenerateUrlParams,
) -> Result<MCPGenerateUrlResponse, ComposioError>
pub async fn generate_mcp_server( &self, params: MCPGenerateUrlParams, ) -> Result<MCPGenerateUrlResponse, ComposioError>
Generate MCP URLs for users and/or connected accounts
Sourcepub async fn create_custom_mcp_server(
&self,
params: MCPCustomCreateParams,
) -> Result<MCPCustomCreateResponse, ComposioError>
pub async fn create_custom_mcp_server( &self, params: MCPCustomCreateParams, ) -> Result<MCPCustomCreateResponse, ComposioError>
Create a custom MCP server
Sourcepub async fn get_migration_nanoid(
&self,
params: MigrationGetNanoIdParams,
) -> Result<MigrationGetNanoIdResponse, ComposioError>
pub async fn get_migration_nanoid( &self, params: MigrationGetNanoIdParams, ) -> Result<MigrationGetNanoIdResponse, ComposioError>
Convert a legacy UUID to NanoId for a supported resource type.
Sourcepub async fn create_cli_session(
&self,
) -> Result<CliCreateSessionResponse, ComposioError>
pub async fn create_cli_session( &self, ) -> Result<CliCreateSessionResponse, ComposioError>
Create a new CLI session.
Sourcepub async fn get_cli_session(
&self,
params: CliGetSessionParams,
) -> Result<CliGetSessionResponse, ComposioError>
pub async fn get_cli_session( &self, params: CliGetSessionParams, ) -> Result<CliGetSessionResponse, ComposioError>
Retrieve a CLI session using UUID or code.
Sourcepub async fn get_project_config(
&self,
) -> Result<ProjectConfigResponse, ComposioError>
pub async fn get_project_config( &self, ) -> Result<ProjectConfigResponse, ComposioError>
Retrieve project configuration.
Sourcepub async fn update_project_config(
&self,
params: ProjectConfigUpdateParams,
) -> Result<ProjectConfigResponse, ComposioError>
pub async fn update_project_config( &self, params: ProjectConfigUpdateParams, ) -> Result<ProjectConfigResponse, ComposioError>
Update project configuration.
Sourcepub async fn list_connected_accounts(
&self,
params: ConnectedAccountListParams,
) -> Result<ConnectedAccountListResponse, ComposioError>
pub async fn list_connected_accounts( &self, params: ConnectedAccountListParams, ) -> Result<ConnectedAccountListResponse, ComposioError>
List connected accounts
Retrieves a list of connected accounts based on the provided filters.
§Arguments
params- Filter parameters for the query
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::connected_accounts::ConnectedAccountListParams;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let params = ConnectedAccountListParams {
user_ids: Some(vec!["user_123".to_string()]),
toolkit_slugs: Some(vec!["github".to_string()]),
..Default::default()
};
let accounts = client.list_connected_accounts(params).await?;Sourcepub async fn get_connected_account(
&self,
account_id: impl Into<String>,
) -> Result<ConnectedAccountInfo, ComposioError>
pub async fn get_connected_account( &self, account_id: impl Into<String>, ) -> Result<ConnectedAccountInfo, ComposioError>
Sourcepub async fn create_connected_account_link(
&self,
params: ConnectedAccountLinkCreateParams,
) -> Result<ConnectedAccountLinkCreateResponse, ComposioError>
pub async fn create_connected_account_link( &self, params: ConnectedAccountLinkCreateParams, ) -> Result<ConnectedAccountLinkCreateResponse, ComposioError>
Create a direct connected-account auth link.
Sourcepub async fn refresh_connected_account(
&self,
account_id: impl Into<String>,
params: ConnectedAccountRefreshParams,
) -> Result<ConnectedAccountRefreshResponse, ComposioError>
pub async fn refresh_connected_account( &self, account_id: impl Into<String>, params: ConnectedAccountRefreshParams, ) -> Result<ConnectedAccountRefreshResponse, ComposioError>
Refresh a connected account’s authentication state.
Sourcepub async fn update_connected_account_status(
&self,
account_id: impl Into<String>,
params: ConnectedAccountUpdateStatusParams,
) -> Result<ConnectedAccountUpdateStatusResponse, ComposioError>
pub async fn update_connected_account_status( &self, account_id: impl Into<String>, params: ConnectedAccountUpdateStatusParams, ) -> Result<ConnectedAccountUpdateStatusResponse, ComposioError>
Enable or disable a connected account.
Sourcepub async fn delete_connected_account(
&self,
account_id: impl Into<String>,
) -> Result<ConnectedAccountDeleteResponse, ComposioError>
pub async fn delete_connected_account( &self, account_id: impl Into<String>, ) -> Result<ConnectedAccountDeleteResponse, ComposioError>
Delete a connected account.
Sourcepub async fn list_files(
&self,
params: FileListParams,
) -> Result<FileListResponse, ComposioError>
pub async fn list_files( &self, params: FileListParams, ) -> Result<FileListResponse, ComposioError>
List files available in the project.
Sourcepub async fn create_file_upload_request(
&self,
params: FileCreatePresignedUrlParams,
) -> Result<FileCreatePresignedUrlResponse, ComposioError>
pub async fn create_file_upload_request( &self, params: FileCreatePresignedUrlParams, ) -> Result<FileCreatePresignedUrlResponse, ComposioError>
Request a presigned upload URL for a file.
Sourcepub async fn list_toolkits(
&self,
params: ToolkitListParams,
) -> Result<ToolkitListResponse, ComposioError>
pub async fn list_toolkits( &self, params: ToolkitListParams, ) -> Result<ToolkitListResponse, ComposioError>
List all toolkits
Retrieves a list of available toolkits based on the provided filters. Toolkits are collections of tools that can be used to perform various tasks.
§Arguments
params- Filter parameters for the query
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::toolkits::ToolkitListParams;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let params = ToolkitListParams {
category: Some("communication".to_string()),
limit: Some(20),
..Default::default()
};
let toolkits = client.list_toolkits(params).await?;
for toolkit in toolkits.items {
println!("Toolkit: {} ({})", toolkit.name, toolkit.slug);
}Sourcepub async fn get_toolkit(
&self,
slug: impl Into<String>,
) -> Result<ToolkitRetrieveResponse, ComposioError>
pub async fn get_toolkit( &self, slug: impl Into<String>, ) -> Result<ToolkitRetrieveResponse, ComposioError>
Get a specific toolkit by slug
Retrieves detailed information about a specific toolkit including authentication schemes, available tools, and configuration details.
§Arguments
slug- The toolkit slug (e.g., “github”, “gmail”, “slack”)
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let toolkit = client.get_toolkit("github").await?;
println!("Toolkit: {}", toolkit.name);
println!("Auth schemes: {:?}", toolkit.auth_schemes);Sourcepub async fn get_toolkit_with_params(
&self,
slug: impl Into<String>,
params: ToolkitRetrieveParams,
) -> Result<ToolkitRetrieveResponse, ComposioError>
pub async fn get_toolkit_with_params( &self, slug: impl Into<String>, params: ToolkitRetrieveParams, ) -> Result<ToolkitRetrieveResponse, ComposioError>
Get a specific toolkit by slug with optional query parameters.
Sourcepub async fn list_toolkit_categories(
&self,
) -> Result<ToolkitCategoriesResponse, ComposioError>
pub async fn list_toolkit_categories( &self, ) -> Result<ToolkitCategoriesResponse, ComposioError>
List all toolkit categories
Retrieves a list of all available toolkit categories. Categories help organize toolkits by functionality or industry.
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let categories = client.list_toolkit_categories().await?;
for category in categories.items {
println!("Category: {}", category.name);
}Authorize a user to a toolkit
Creates an authentication link for a user to connect to a specific toolkit. If an auth config is not found, it will be created using Composio managed auth.
This is a convenience method that:
- Gets or creates an auth config for the toolkit
- Initiates a connection for the user
- Returns the connection request with redirect URL
§Arguments
user_id- The ID of the user to authorizetoolkit- The slug of the toolkit to authorize (e.g., “github”, “gmail”)
§Returns
Returns a connection request with a redirect_url that the user should visit
to complete the authentication flow.
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let connection = client.authorize_toolkit("user_123", "github").await?;
println!("Visit this URL to authenticate: {}", connection.redirect_url.unwrap());Sourcepub async fn get_auth_config(
&self,
auth_config_id: impl Into<String>,
) -> Result<AuthConfigRetrieveResponse, ComposioError>
pub async fn get_auth_config( &self, auth_config_id: impl Into<String>, ) -> Result<AuthConfigRetrieveResponse, ComposioError>
Retrieve an auth config by ID.
Sourcepub async fn update_auth_config(
&self,
auth_config_id: impl Into<String>,
params: AuthConfigUpdateParams,
) -> Result<AuthConfigUpdateResponse, ComposioError>
pub async fn update_auth_config( &self, auth_config_id: impl Into<String>, params: AuthConfigUpdateParams, ) -> Result<AuthConfigUpdateResponse, ComposioError>
Update an auth config by ID.
Sourcepub async fn delete_auth_config(
&self,
auth_config_id: impl Into<String>,
) -> Result<AuthConfigDeleteResponse, ComposioError>
pub async fn delete_auth_config( &self, auth_config_id: impl Into<String>, ) -> Result<AuthConfigDeleteResponse, ComposioError>
Delete an auth config by ID.
Sourcepub async fn update_auth_config_status(
&self,
auth_config_id: impl Into<String>,
status: AuthConfigStatus,
) -> Result<AuthConfigStatusUpdateResponse, ComposioError>
pub async fn update_auth_config_status( &self, auth_config_id: impl Into<String>, status: AuthConfigStatus, ) -> Result<AuthConfigStatusUpdateResponse, ComposioError>
Update auth config status to ENABLED or DISABLED.
Sourcepub async fn get_connected_account_initiation_fields(
&self,
toolkit: impl Into<String>,
auth_scheme: impl Into<String>,
required_only: bool,
) -> Result<Vec<AuthField>, ComposioError>
pub async fn get_connected_account_initiation_fields( &self, toolkit: impl Into<String>, auth_scheme: impl Into<String>, required_only: bool, ) -> Result<Vec<AuthField>, ComposioError>
Get connected account initiation fields for a toolkit
Retrieves the required and optional fields needed to initiate a connection for a specific toolkit and authentication scheme.
§Arguments
toolkit- The toolkit slug (e.g., “github”, “gmail”)auth_scheme- The authentication scheme (e.g., “OAUTH2”, “API_KEY”)required_only- If true, returns only required fields; if false, returns both required and optional
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let fields = client.get_connected_account_initiation_fields(
"github",
"OAUTH2",
false
).await?;
for field in fields {
println!("Field: {} (required: {})", field.name, field.required);
}Sourcepub async fn get_auth_config_creation_fields(
&self,
toolkit: impl Into<String>,
auth_scheme: impl Into<String>,
required_only: bool,
) -> Result<Vec<AuthField>, ComposioError>
pub async fn get_auth_config_creation_fields( &self, toolkit: impl Into<String>, auth_scheme: impl Into<String>, required_only: bool, ) -> Result<Vec<AuthField>, ComposioError>
Get auth config creation fields for a toolkit
Retrieves the required and optional fields needed to create an auth config for a specific toolkit and authentication scheme.
§Arguments
toolkit- The toolkit slug (e.g., “github”, “gmail”)auth_scheme- The authentication scheme (e.g., “OAUTH2”, “API_KEY”)required_only- If true, returns only required fields; if false, returns both required and optional
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let fields = client.get_auth_config_creation_fields(
"github",
"OAUTH2",
true
).await?;
for field in fields {
println!("Required field: {}", field.name);
}Sourcepub async fn list_tools(
&self,
params: ToolListParams,
) -> Result<ToolListResponse, ComposioError>
pub async fn list_tools( &self, params: ToolListParams, ) -> Result<ToolListResponse, ComposioError>
List tools with filtering options
Retrieves a list of available tools based on the provided filters. Tools are individual actions that can be performed on external services.
§Arguments
params- Filter parameters for the query
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::tools::ToolListParams;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let params = ToolListParams {
toolkit_slug: Some("github".to_string()),
limit: Some(20),
..Default::default()
};
let tools = client.list_tools(params).await?;
for tool in tools.items {
println!("Tool: {} ({})", tool.name, tool.slug);
}Sourcepub async fn retrieve_tool_enum(
&self,
) -> Result<ToolRetrieveEnumResponse, ComposioError>
pub async fn retrieve_tool_enum( &self, ) -> Result<ToolRetrieveEnumResponse, ComposioError>
Retrieve all tool slug enumeration values.
Sourcepub async fn get_tool(
&self,
slug: impl Into<String>,
) -> Result<ToolInfo, ComposioError>
pub async fn get_tool( &self, slug: impl Into<String>, ) -> Result<ToolInfo, ComposioError>
Get a specific tool by slug
Retrieves detailed information about a specific tool including input/output schemas, scopes, and version information.
§Arguments
slug- The tool slug (e.g., “GITHUB_CREATE_ISSUE”, “GMAIL_SEND_EMAIL”)
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let tool = client.get_tool("GITHUB_CREATE_ISSUE").await?;
println!("Tool: {}", tool.name);
println!("Description: {}", tool.description);
println!("Version: {}", tool.version);Sourcepub async fn execute_tool(
&self,
params: ToolExecuteParams,
) -> Result<ToolExecutionResponse, ComposioError>
pub async fn execute_tool( &self, params: ToolExecuteParams, ) -> Result<ToolExecutionResponse, ComposioError>
Execute a tool
Executes a specific tool with the provided arguments. The tool must be available and the user must have appropriate authentication.
§Arguments
params- Tool execution parameters including slug, arguments, and auth info
§Returns
Returns a ToolExecutionResponse containing:
data: The tool’s output dataerror: Optional error message if execution failedsuccessful: Whether the execution was successfullog_id: Unique identifier for this execution (for debugging)
§Errors
Returns an error if:
- The tool is not found
- The user doesn’t have a connected account for the toolkit
- The arguments are invalid or missing required fields
- Network error occurs
- API returns an error response
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::tools::ToolExecuteParams;
use std::collections::HashMap;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let mut arguments = HashMap::new();
arguments.insert("owner".to_string(), serde_json::json!("composio"));
arguments.insert("repo".to_string(), serde_json::json!("composio"));
arguments.insert("title".to_string(), serde_json::json!("Test issue"));
let params = ToolExecuteParams {
slug: "GITHUB_CREATE_ISSUE".to_string(),
arguments,
user_id: Some("user_123".to_string()),
version: Some("1.0.0".to_string()),
..Default::default()
};
let result = client.execute_tool(params).await?;
println!("Result: {:?}", result.data);Sourcepub async fn proxy_tool(
&self,
params: ToolProxyParams,
) -> Result<ToolProxyResponse, ComposioError>
pub async fn proxy_tool( &self, params: ToolProxyParams, ) -> Result<ToolProxyResponse, ComposioError>
Execute a proxy request to a third-party API
Makes an authenticated HTTP request to a third-party API using a connected account’s credentials. This is useful for calling endpoints that don’t have predefined tools.
§Arguments
params- Proxy request parameters including endpoint, method, and auth
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::tools::{ToolProxyParams, HttpMethod};
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let params = ToolProxyParams {
endpoint: "/repos/composio/composio".to_string(),
method: HttpMethod::Get,
connected_account_id: Some("ca_123".to_string()),
body: None,
parameters: None,
custom_connection_data: None,
};
let result = client.proxy_tool(params).await?;
println!("Status: {}", result.status);
println!("Data: {:?}", result.data);Sourcepub async fn generate_tool_inputs(
&self,
params: ToolInputGenerationParams,
) -> Result<ToolInputGenerationResponse, ComposioError>
pub async fn generate_tool_inputs( &self, params: ToolInputGenerationParams, ) -> Result<ToolInputGenerationResponse, ComposioError>
Generate tool inputs from natural language
Uses AI to convert a natural language description into structured tool arguments. This is useful for allowing users to describe what they want to do in plain language.
§Arguments
params- Input generation parameters including tool slug and text
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::tools::ToolInputGenerationParams;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let params = ToolInputGenerationParams {
tool_slug: "GITHUB_CREATE_ISSUE".to_string(),
text: "Create an issue about fixing the login bug in the composio repo".to_string(),
custom_tool_description: None,
custom_system_prompt: None,
};
let result = client.generate_tool_inputs(params).await?;
if let Some(arguments) = result.arguments {
println!("Generated arguments: {:?}", arguments);
}Sourcepub async fn list_trigger_types(
&self,
params: TriggerTypeListParams,
) -> Result<TriggerTypeListResponse, ComposioError>
pub async fn list_trigger_types( &self, params: TriggerTypeListParams, ) -> Result<TriggerTypeListResponse, ComposioError>
List trigger types
Retrieves a list of available trigger types (templates) based on filters. Trigger types define what events can be listened for.
§Arguments
params- Filter parameters for the query
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::triggers::TriggerTypeListParams;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let params = TriggerTypeListParams {
toolkit_slugs: Some(vec!["github".to_string()]),
limit: Some(20),
..Default::default()
};
let triggers = client.list_trigger_types(params).await?;
for trigger in triggers.items {
println!("Trigger: {} ({})", trigger.name, trigger.slug);
}Sourcepub async fn retrieve_trigger_type_enum(
&self,
) -> Result<TriggerTypeRetrieveEnumResponse, ComposioError>
pub async fn retrieve_trigger_type_enum( &self, ) -> Result<TriggerTypeRetrieveEnumResponse, ComposioError>
Retrieve all trigger type slug enumeration values.
Sourcepub async fn get_trigger_type(
&self,
slug: impl Into<String>,
) -> Result<TriggerType, ComposioError>
pub async fn get_trigger_type( &self, slug: impl Into<String>, ) -> Result<TriggerType, ComposioError>
Get a specific trigger type by slug
Retrieves detailed information about a trigger type including configuration schema and payload schema.
§Arguments
slug- The trigger type slug (e.g., “GITHUB_COMMIT_EVENT”)
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let trigger = client.get_trigger_type("GITHUB_COMMIT_EVENT").await?;
println!("Trigger: {}", trigger.name);
println!("Type: {}", trigger.trigger_type);
println!("Config schema: {}", trigger.config);Sourcepub async fn get_trigger_type_with_params(
&self,
slug: impl Into<String>,
params: TriggerTypeRetrieveParams,
) -> Result<TriggerType, ComposioError>
pub async fn get_trigger_type_with_params( &self, slug: impl Into<String>, params: TriggerTypeRetrieveParams, ) -> Result<TriggerType, ComposioError>
Get a specific trigger type by slug with optional query parameters.
Sourcepub async fn list_active_triggers(
&self,
params: TriggerInstanceListParams,
) -> Result<TriggerInstanceListResponse, ComposioError>
pub async fn list_active_triggers( &self, params: TriggerInstanceListParams, ) -> Result<TriggerInstanceListResponse, ComposioError>
List active trigger instances
Retrieves a list of active trigger instances (listeners) based on filters. Trigger instances are active event listeners for specific users.
§Arguments
params- Filter parameters for the query
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::triggers::TriggerInstanceListParams;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let params = TriggerInstanceListParams {
trigger_names: Some(vec!["GITHUB_COMMIT_EVENT".to_string()]),
show_disabled: Some(false),
..Default::default()
};
let instances = client.list_active_triggers(params).await?;
for instance in instances.items {
println!("Instance: {} for user {}", instance.trigger_name, instance.user_id.unwrap_or_default());
}Sourcepub async fn create_trigger(
&self,
params: TriggerCreateParams,
) -> Result<TriggerCreateResponse, ComposioError>
pub async fn create_trigger( &self, params: TriggerCreateParams, ) -> Result<TriggerCreateResponse, ComposioError>
Create a trigger instance
Creates a new trigger instance (event listener) for a user.
Either connected_account_id or user_id must be provided.
If user_id is provided, the most recent connected account will be used.
§Arguments
params- Trigger creation parameters
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::triggers::TriggerCreateParams;
use std::collections::HashMap;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
let mut config = HashMap::new();
config.insert("repo".to_string(), serde_json::json!("composio"));
config.insert("owner".to_string(), serde_json::json!("composio"));
let params = TriggerCreateParams {
slug: "GITHUB_COMMIT_EVENT".to_string(),
user_id: Some("user_123".to_string()),
connected_account_id: None,
trigger_config: Some(config),
toolkit_versions: None,
};
let trigger = client.create_trigger(params).await?;
println!("Created trigger: {}", trigger.id);Sourcepub async fn delete_trigger(
&self,
trigger_id: impl Into<String>,
) -> Result<(), ComposioError>
pub async fn delete_trigger( &self, trigger_id: impl Into<String>, ) -> Result<(), ComposioError>
Delete a trigger instance
Permanently deletes a trigger instance. This cannot be undone.
§Arguments
trigger_id- The trigger instance ID to delete
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
client.delete_trigger("ti_abc123").await?;
println!("Trigger deleted");Sourcepub async fn enable_trigger(
&self,
trigger_id: impl Into<String>,
) -> Result<(), ComposioError>
pub async fn enable_trigger( &self, trigger_id: impl Into<String>, ) -> Result<(), ComposioError>
Enable a trigger instance
Enables a previously disabled trigger instance.
§Arguments
trigger_id- The trigger instance ID to enable
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
client.enable_trigger("ti_abc123").await?;
println!("Trigger enabled");Sourcepub async fn disable_trigger(
&self,
trigger_id: impl Into<String>,
) -> Result<(), ComposioError>
pub async fn disable_trigger( &self, trigger_id: impl Into<String>, ) -> Result<(), ComposioError>
Disable a trigger instance
Temporarily disables a trigger instance without deleting it.
§Arguments
trigger_id- The trigger instance ID to disable
§Example
use composio_sdk::client::ComposioClient;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
client.disable_trigger("ti_abc123").await?;
println!("Trigger disabled");Sourcepub fn verify_webhook(
&self,
params: WebhookVerifyParams,
) -> Result<VerifyWebhookResult, ComposioError>
pub fn verify_webhook( &self, params: WebhookVerifyParams, ) -> Result<VerifyWebhookResult, ComposioError>
Verify an incoming webhook payload and signature
This method validates that the webhook request is authentic by:
- Validating the webhook timestamp is within the tolerance window
- Verifying the HMAC-SHA256 signature using the correct algorithm
- Parsing the payload and detecting the webhook version (V1, V2, or V3)
§Arguments
params- Webhook verification parameters including id, payload, signature, timestamp, and secret
§Returns
Returns a VerifyWebhookResult containing:
version: Detected webhook version (V1, V2, or V3)payload: Normalized trigger eventraw_payload: Original parsed payload
§Errors
Returns an error if:
- Signature verification fails
- Timestamp is outside tolerance window
- Payload cannot be parsed
- Required headers are missing
§Example
use composio_sdk::client::ComposioClient;
use composio_sdk::models::triggers::WebhookVerifyParams;
let client = ComposioClient::builder()
.api_key("your_api_key")
.build()?;
// In a webhook handler (e.g., Actix-web, Axum, etc.)
let params = WebhookVerifyParams {
id: "msg_abc123".to_string(),
payload: r#"{"type":"composio.trigger.message","data":{}}"#.to_string(),
signature: "v1,base64signature".to_string(),
timestamp: "1234567890".to_string(),
secret: "whsec_abc123".to_string(),
tolerance: Some(300),
};
let result = client.verify_webhook(params)?;
println!("Webhook version: {:?}", result.version);
println!("Trigger slug: {}", result.payload.trigger_slug);Trait Implementations§
Source§impl Clone for ComposioClient
impl Clone for ComposioClient
Source§fn clone(&self) -> ComposioClient
fn clone(&self) -> ComposioClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more