> ## Documentation Index
> Fetch the complete documentation index at: https://incredible-42686482-cursor-create-detailed-ai-agent-cookboo.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to Integration

> Connect a user’s account so your app can use that integration’s features. Supports API key and OAuth flows and is required before executing features.

<ParamField header="integration_id" type="string" required>
  The unique identifier of the integration to connect to
</ParamField>

## API Key Authentication

For integrations that use API key authentication (like Perplexity):

<CodeGroup>
  ```bash
  curl -X POST "https://api.incredible.one/v1/integrations/{integration_id}/connect" \
    -H "Content-Type: application/json" \
    -d '{"user_id":"user_123","api_key":"YOUR_API_KEY"}'
  ```

  ```python
  import requests

  resp = requests.post(
      "https://api.incredible.one/v1/integrations/{integration_id}/connect",
      json={"user_id": "user_123", "api_key": "YOUR_API_KEY"},
  )
  print(resp.json())
  ```

  ```javascript
  const res = await fetch("https://api.incredible.one/v1/integrations/{integration_id}/connect", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ user_id: "user_123", api_key: "YOUR_API_KEY" })
  });
  console.log(await res.json());
  ```
</CodeGroup>

<RequestExample>
  ```json
  {
    "user_id": "user_123",
    "api_key": "your_api_key_here"
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response
  {
    "success": true,
    "message": "Successfully connected to Perplexity",
    "integration_id": "perplexity",
    "user_id": "user_123"
  }
  ```
</ResponseExample>

## OAuth Authentication

For integrations that use OAuth authentication (like Gmail):

<CodeGroup>
  ```bash
  curl -X POST "https://api.incredible.one/v1/integrations/{integration_id}/connect" \
    -H "Content-Type: application/json" \
    -d '{"user_id":"user_123","callback_url":"https://your.app/oauth/callback"}'
  ```

  ```python
  import requests

  resp = requests.post(
      "https://api.incredible.one/v1/integrations/{integration_id}/connect",
      json={"user_id": "user_123", "callback_url": "https://your.app/oauth/callback"},
  )
  print(resp.json())
  ```

  ```javascript
  const res = await fetch("https://api.incredible.one/v1/integrations/{integration_id}/connect", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ user_id: "user_123", callback_url: "https://your.app/oauth/callback" })
  });
  console.log(await res.json());
  ```
</CodeGroup>

<RequestExample>
  ```json
  {
    "user_id": "user_123",
    "callback_url": "https://backend.viss.ai/app-auth/oauth2-callback"
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response
  {
    "redirect_url": "https://auth.composio.com/oauth/authorize?client_id=...",
    "instructions": "Please visit the redirect URL to complete OAuth authentication"
  }
  ```
</ResponseExample>

## Error Responses

<ResponseExample>
  ```json Response
  {
    "error": "User ID required",
    "instructions": "Please provide user_id in request body"
  }
  ```
</ResponseExample>

<ResponseExample>
  ```json Response
  {
    "error": "API key required",
    "instructions": "Please provide your Gmail API key in the request body"
  }
  ```
</ResponseExample>
