> ## 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.

# Gmail Integration

> Send an email via Gmail using the Integrations API

This example demonstrates connecting Gmail (OAuth 2.0) and sending an email using the `gmail_send_email` feature.

### 1) Connect (OAuth)

Start the OAuth flow. You’ll receive a `redirect_url` to send the user to Google.

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

Expected response:

```json
{
  "redirect_url": "https://accounts.google.com/o/oauth2/auth?...",
  "instructions": "Please visit the redirect URL to complete authentication"
}
```

Complete the browser flow. After your `callback_url` receives the redirect, the connection is established for `user_id`.

### 2) Execute feature (send email)

```bash
curl -X POST "https://api.incredible.one/v1/integrations/gmail/execute" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "user_123",
    "feature_name": "gmail_send_email",
    "inputs": {
      "recipient_email": "recipient@example.com",
      "subject": "Hello from Incredible",
      "body": "This email was sent via the Gmail integration."
    }
  }'
```

Example success response:

```json
{
  "success": true,
  "result": {"message_id": "abc123", "status": "sent"},
  "integration_id": "gmail",
  "feature_name": "gmail_send_email",
  "user_id": "user_123"
}
```

Notes:

* Ensure the user completed OAuth before executing features.
* Some fields (e.g., attachments) may be required depending on your feature configuration.

<Note>
  View source on GitHub → [6\_gmail\_integration.py](https://github.com/Norditech-AB/Incredible-API-Cookbook/blob/main/01-getting-started/6_gmail_integration.py)
</Note>
