> ## Documentation Index
> Fetch the complete documentation index at: https://docs.suada.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Integration Callback

> Handle OAuth callback for an integration

Complete the OAuth flow for a third-party integration.

## URL Parameters

<ParamField path="integrationType" type="string" required>
  The type of integration being connected. Valid values:

  * `google-analytics`
  * `notion`
  * `slack`
  * `zoho`
  * `gmail`
</ParamField>

## Request

<ParamField body="code" type="string" required>
  The OAuth authorization code
</ParamField>

<ParamField body="state" type="string" required>
  The state parameter from the OAuth flow
</ParamField>

## Response

The response format varies by integration type:

### Google Analytics

<ResponseField name="success" type="boolean">
  Whether the callback was successful
</ResponseField>

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="properties" type="array">
  List of available Google Analytics properties

  ```ts theme={null}
  {
    id: string
    name: string
    websiteUrl: string
  }[]
  ```
</ResponseField>

<ResponseField name="temporaryAccessToken" type="string">
  Temporary token for property selection
</ResponseField>

<ResponseField name="passthroughRedirectUri" type="string">
  The redirect URI provided during connection
</ResponseField>

### Notion

<ResponseField name="success" type="boolean">
  Whether the callback was successful
</ResponseField>

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="workspace" type="object">
  Connected Notion workspace details

  ```ts theme={null}
  {
    id: string
    name: string
    icon: string
  }
  ```
</ResponseField>

<ResponseField name="passthroughRedirectUri" type="string">
  The redirect URI provided during connection
</ResponseField>

### Slack

<ResponseField name="success" type="boolean">
  Whether the callback was successful
</ResponseField>

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="team" type="object">
  Connected Slack team details

  ```ts theme={null}
  {
    id: string
    name: string
    domain: string
  }
  ```
</ResponseField>

<ResponseField name="passthroughRedirectUri" type="string">
  The redirect URI provided during connection
</ResponseField>

### Zoho

<ResponseField name="success" type="boolean">
  Whether the callback was successful
</ResponseField>

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="organization" type="object">
  Connected Zoho organization details

  ```ts theme={null}
  {
    id: string
    name: string
    modules: string[]
  }
  ```
</ResponseField>

<ResponseField name="passthroughRedirectUri" type="string">
  The redirect URI provided during connection
</ResponseField>

### Gmail

<ResponseField name="success" type="boolean">
  Whether the callback was successful
</ResponseField>

<ResponseField name="message" type="string">
  Success or error message
</ResponseField>

<ResponseField name="passthroughRedirectUri" type="string">
  The redirect URI provided during connection
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://suada.ai/api/public/integrations/notion/callback \
    -H "Content-Type: application/json" \
    -d '{
      "code": "oauth-code-from-provider",
      "state": "oauth-state-from-provider"
    }'
  ```

  ```typescript TypeScript theme={null}
  import { Suada } from '@suada/node';

  const suada = new Suada({
    apiKey: 'your-api-key'
  });

  const result = await suada.handleIntegrationCallback('notion', {
    code: 'oauth-code-from-provider',
    state: 'oauth-state-from-provider'
  });

  // Redirect user back to their application
  window.location.href = result.passthroughRedirectUri;
  ```

  ```python Python theme={null}
  from suada import Suada, SuadaConfig

  suada = Suada(
      config=SuadaConfig(
          api_key="your-api-key"
      )
  )

  result = suada.handle_integration_callback(
      integration_type="notion",
      code="oauth-code-from-provider",
      state="oauth-state-from-provider"
  )

  # Redirect user back to result.passthrough_redirect_uri
  ```
</CodeGroup>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "message": "Notion workspace connected successfully",
    "workspace": {
      "id": "workspace-id",
      "name": "My Workspace",
      "icon": "https://notion.so/icons/workspace.png"
    },
    "passthroughRedirectUri": "https://your-app.com/oauth/callback"
  }
  ```
</ResponseExample>

## Error Codes

<ResponseField name="400" type="object">
  Invalid request

  ```json theme={null}
  {
    "error": "Missing required parameters"
  }
  ```
</ResponseField>

<ResponseField name="401" type="object">
  Invalid OAuth code or state

  ```json theme={null}
  {
    "error": "Invalid OAuth code"
  }
  ```
</ResponseField>

<ResponseField name="500" type="object">
  Server error

  ```json theme={null}
  {
    "error": "Failed to complete OAuth flow"
  }
  ```
</ResponseField>

## Notes

* This endpoint should be called after receiving the OAuth callback from the integration provider
* The `state` parameter is used to verify the OAuth flow and prevent CSRF attacks
* For Google Analytics, you'll need to make an additional call to [select a property](/api-reference/integrations/select-property)
* After successful callback, redirect the user to the `passthroughRedirectUri` provided during connection
* The integration will be automatically enabled for the user after successful callback
