# Gmail Integration via LowCodeAPI
## Overview
Gmail API provides programmatic access to Gmail accounts, allowing you to read, send, search, and manage emails. Build email automation, client integrations, and email management tools with 69+ available endpoints.
## Base Endpoint
```
https://api.lowcodeapi.com/gmail/
```
## Authentication
LowCodeAPI handles authentication automatically. You only need to:
1. **Sign up** at [Google Cloud Console](https://console.cloud.google.com/apis/credentials)
2. **Create OAuth2.0 credentials** for Gmail API
3. **Configure scopes** based on needed permissions
4. **Connect your account** in LowCodeAPI dashboard
5. **Use your `api_token`** in all requests
The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your Gmail OAuth credentials from the database
- Handle OAuth flow and token refresh
- Apply authentication to each request
**Auth Type**: OAuth2.0
**Available Scopes**:
- `https://www.googleapis.com/auth/gmail.modify` - Read, compose, and send emails
- `https://www.googleapis.com/auth/gmail.send` - Send email only
- `https://www.googleapis.com/auth/gmail.readonly` - View emails only
- `https://www.googleapis.com/auth/gmail.metadata` - View metadata only
- `https://mail.google.com/` - Full access to all Gmail features
## API Categories
- **Google Other** - Google service integrations
## Common Endpoints
### Category: Messages
#### List Messages
**Method**: `GET` | **LowCodeAPI Path**: `/gmail/v1/users/userId/messages`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages?userId={userId}&api_token={api_token}
```
**Description**: Lists the messages in the user's mailbox
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' for authenticated user |
| `pageToken` | string | No | Page token for pagination |
| `maxResults` | number | No | Maximum number of messages to return |
| `q` | string | No | Search query string |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages?userId=me&maxResults=10&api_token=YOUR_API_TOKEN"
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/messages/list](https://developers.google.com/gmail/api/v1/reference/users/messages/list)
---
#### Get Message
**Method**: `GET` | **LowCodeAPI Path**: `/gmail/v1/users/userId/messages/id`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/id?userId={userId}&id={id}&api_token={api_token}
```
**Description**: Gets the specified message
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `id` | string | Yes | The ID of the message to retrieve |
| `format` | string | No | Format of message (full, metadata, minimal, raw) |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/id?userId=me&id=MESSAGE_ID&format=full&api_token=YOUR_API_TOKEN"
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/messages/get](https://developers.google.com/gmail/api/v1/reference/users/messages/get)
---
#### Send Message
**Method**: `POST` | **LowCodeAPI Path**: `/gmail/v1/users/userId/messages/send`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/send?userId={userId}&api_token={api_token}
```
**Description**: Sends the specified message
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Body Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `raw` | string | Yes | Base64-encoded email content |
| `threadId` | string | No | Thread ID to associate with message |
**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/send?userId=me&api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"raw": "Base64-encoded-email-content"
}'
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/messages/send](https://developers.google.com/gmail/api/v1/reference/users/messages/send)
---
#### Delete Message
**Method**: `DELETE` | **LowCodeAPI Path**: `/gmail/v1/users/userId/messages/id`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/id?userId={userId}&id={id}&api_token={api_token}
```
**Description**: Deletes the specified message
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `id` | string | Yes | The ID of the message to delete |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Example Request**:
```bash
curl -X DELETE "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/id?userId=me&id=MESSAGE_ID&api_token=YOUR_API_TOKEN"
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/messages/delete](https://developers.google.com/gmail/api/v1/reference/users/messages/delete)
---
### Category: Threads
#### List Threads
**Method**: `GET` | **LowCodeAPI Path**: `/gmail/v1/users/userId/threads`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/threads?userId={userId}&api_token={api_token}
```
**Description**: Lists all threads in the user's mailbox
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `pageToken` | string | No | Page token for pagination |
| `maxResults` | number | No | Maximum number of threads to return |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/threads?userId=me&maxResults=10&api_token=YOUR_API_TOKEN"
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/threads/list](https://developers.google.com/gmail/api/v1/reference/users/threads/list)
---
#### Get Thread
**Method**: `GET` | **LowCodeAPI Path**: `/gmail/v1/users/userId/threads/id`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/threads/id?userId={userId}&id={id}&api_token={api_token}
```
**Description**: Gets the specified thread
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `id` | string | Yes | The ID of the thread to retrieve |
| `format` | string | No | Format of messages (full, metadata, minimal) |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/threads/id?userId=me&id=THREAD_ID&format=full&api_token=YOUR_API_TOKEN"
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/threads/get](https://developers.google.com/gmail/api/v1/reference/users/threads/get)
---
### Category: Labels
#### List Labels
**Method**: `GET` | **LowCodeAPI Path**: `/gmail/v1/users/userId/labels`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/labels?userId={userId}&api_token={api_token}
```
**Description**: Lists all labels in the user's mailbox
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/labels?userId=me&api_token=YOUR_API_TOKEN"
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/labels/list](https://developers.google.com/gmail/api/v1/reference/users/labels/list)
---
#### Create Label
**Method**: `POST` | **LowCodeAPI Path**: `/gmail/v1/users/userId/labels`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/labels?userId={userId}&api_token={api_token}
```
**Description**: Creates a new label
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Body Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `name` | string | Yes | The display name of the label |
| `messageListVisibility` | string | No | Visibility in message list |
| `labelListVisibility` | string | No | Visibility in label list |
**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/labels?userId=me&api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Important Clients",
"messageListVisibility": "show",
"labelListVisibility": "labelShow"
}'
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/labels/create](https://developers.google.com/gmail/api/v1/reference/users/labels/create)
---
### Category: Drafts
#### List Drafts
**Method**: `GET` | **LowCodeAPI Path**: `/gmail/v1/users/userId/drafts`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/drafts?userId={userId}&api_token={api_token}
```
**Description**: Lists the drafts in the user's mailbox
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `pageToken` | string | No | Page token for pagination |
| `maxResults` | number | No | Maximum number of drafts to return |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/drafts?userId=me&maxResults=10&api_token=YOUR_API_TOKEN"
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/drafts/list](https://developers.google.com/gmail/api/v1/reference/users/drafts/list)
---
#### Create Draft
**Method**: `POST` | **LowCodeAPI Path**: `/gmail/v1/users/userId/drafts`
**Full URL**:
```
https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/drafts?userId={userId}&api_token={api_token}
```
**Description**: Creates a new draft
**Query Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `userId` | string | Yes | User's email address or 'me' |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
**Body Parameters**:
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `message` | object | Yes | The message content of the draft |
**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/drafts?userId=me&api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": {
"raw": "Base64-encoded-draft-content"
}
}'
```
**Official Documentation**: [https://developers.google.com/gmail/api/v1/reference/users/drafts/create](https://developers.google.com/gmail/api/v1/reference/users/drafts/create)
---
## Usage Examples
### Example 1: Read and Search Emails
This example demonstrates reading and searching emails:
```bash
# Step 1: List recent messages
# Use 'me' for the authenticated user (no email ID needed)
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages?userId=me&maxResults=10&api_token=YOUR_API_TOKEN"
# Step 2: Search for specific emails
# Use 'me' with a search query
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages?userId=me&q=from:[email protected]&api_token=YOUR_API_TOKEN"
# Step 3: Get full message content
# Replace MESSAGE_ID with an ID from previous steps
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/id?userId=me&id=MESSAGE_ID&format=full&api_token=YOUR_API_TOKEN"
# Step 4: List messages in a thread
# Replace THREAD_ID with an ID from the thread list
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/threads/id?userId=me&id=THREAD_ID&format=full&api_token=YOUR_API_TOKEN"
```
### Example 2: Send and Manage Emails
This example shows sending and managing emails:
```bash
# Step 1: Create a draft
# No ID required - creates a new draft
curl -X POST "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/drafts?userId=me&api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": {
"raw": "Base64-encoded-email-with-headers-and-body"
}
}'
# Step 2: List all drafts
# Use 'me' for the authenticated user
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/drafts?userId=me&api_token=YOUR_API_TOKEN"
# Step 3: Send an email directly
# No ID required - sends a new message
curl -X POST "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/send?userId=me&api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"raw": "Base64-encoded-complete-email"
}'
# Step 4: Delete a message
# Replace MESSAGE_ID with the actual message ID
curl -X DELETE "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/id?userId=me&id=MESSAGE_ID&api_token=YOUR_API_TOKEN"
```
### Example 3: Label Management
```bash
# Step 1: List all labels
# Use 'me' for the authenticated user
curl -X GET "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/labels?userId=me&api_token=YOUR_API_TOKEN"
# Step 2: Create a custom label
# No ID required - creates a new label
curl -X POST "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/labels?userId=me&api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Work Projects",
"messageListVisibility": "show",
"labelListVisibility": "labelShow"
}'
# Step 3: Modify message labels (add/remove labels)
# Replace MESSAGE_ID with the actual message ID
curl -X POST "https://api.lowcodeapi.com/gmail/gmail/v1/users/userId/messages/id/modify?userId=me&id=MESSAGE_ID&api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"addLabelIds": ["LABEL_ID"],
"removeLabelIds": ["INBOX"]
}'
```
## Complete Endpoint Reference
For a complete list of all endpoints and their parameters, refer to:
- **OpenAPI Definition**: `https://backend.lowcodeapi.com/gmail/definition`
- **Official Provider Documentation**: [https://developers.google.com/gmail](https://developers.google.com/gmail)
## Rate Limits & Best Practices
- **Rate limits**: Based on Google Cloud project quota
- **Best practice**: Use pagination for large mailboxes
- **Best practice**: Use search queries to filter results
- **Best practice**: Use `format=metadata` when you don't need full content
- **Best practice**: Batch operations when possible
- **Best practice**: Handle webhook notifications for real-time updates
## Error Handling
Standard HTTP status codes apply:
- **200** - Success
- **400** - Bad request
- **401** - Authentication failed
- **403** - Insufficient permissions
- **404** - Resource not found
- **429** - Rate limit exceeded