# Get Campaigns

GET https://services.leadconnectorhq.com/emails/schedule

Get Campaigns

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `emails/schedule.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location ID to fetch campaigns from |
| `limit` | number | No | Maximum number of campaigns to return. Defaults to 10, maximum is 100 |
| `offset` | number | No | Number of campaigns to skip for pagination |
| `status` | string | No | Filter by schedule status |
| `emailStatus` | string | No | Filter by email delivery status |
| `name` | string | No | Filter campaigns by name |
| `parentId` | string | No | Filter campaigns by parent folder ID |
| `limitedFields` | boolean | No | When true, returns only essential campaign fields like id, templateDataDownloadUrl, updatedAt, type, templateType, templateId, downloadUrl and isPlainText. When false, returns complete campaign data including meta information, bulkRequestStatusInfo, ABTestInfo, resendScheduleInfo and all other campaign properties |
| `archived` | boolean | No | Filter archived campaigns |
| `campaignsOnly` | boolean | No | Return only campaigns, excluding folders |
| `showStats` | boolean | No | When true, returns campaign statistics including delivered count, opened count, clicked count and revenue if available for the campaign. When false, returns campaign data without statistics. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-04-15"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/emails/schedule": {
      "get": {
        "summary": "Get Campaigns",
        "operationId": "getCampaigns",
        "description": "Get Campaigns",
        "parameters": [
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location ID to fetch campaigns from",
            "schema": {
              "example": "ohjiah0wdg3bzmzacvd6",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Maximum number of campaigns to return. Defaults to 10, maximum is 100",
            "schema": {
              "example": "7",
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Number of campaigns to skip for pagination",
            "schema": {
              "example": "0",
              "type": "number"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Filter by schedule status",
            "schema": {
              "default": "active",
              "enum": [
                "active",
                "pause",
                "complete",
                "cancelled",
                "retry",
                "draft",
                "resend-scheduled",
                "processing"
              ],
              "type": "string"
            }
          },
          {
            "name": "emailStatus",
            "required": false,
            "in": "query",
            "description": "Filter by email delivery status",
            "schema": {
              "default": "complete",
              "enum": [
                "all",
                "not-started",
                "paused",
                "cancelled",
                "processing",
                "resumed",
                "next-drip",
                "complete",
                "success",
                "error",
                "waiting",
                "queued",
                "queueing",
                "reading",
                "scheduled"
              ],
              "type": "string"
            }
          },
          {
            "name": "name",
            "required": false,
            "in": "query",
            "description": "Filter campaigns by name",
            "schema": {
              "example": "Black Friday Campaign",
              "type": "string"
            }
          },
          {
            "name": "parentId",
            "required": false,
            "in": "query",
            "description": "Filter campaigns by parent folder ID",
            "schema": {
              "example": "folder123",
              "type": "string"
            }
          },
          {
            "name": "limitedFields",
            "required": false,
            "in": "query",
            "description": "When true, returns only essential campaign fields like id, templateDataDownloadUrl, updatedAt, type, templateType, templateId, downloadUrl and isPlainText. When false, returns complete campaign data including meta information, bulkRequestStatusInfo, ABTestInfo, resendScheduleInfo and all other campaign properties",
            "schema": {
              "default": false,
              "example": "false",
              "type": "boolean"
            }
          },
          {
            "name": "archived",
            "required": false,
            "in": "query",
            "description": "Filter archived campaigns",
            "schema": {
              "example": "false",
              "type": "boolean"
            }
          },
          {
            "name": "campaignsOnly",
            "required": false,
            "in": "query",
            "description": "Return only campaigns, excluding folders",
            "schema": {
              "default": false,
              "example": "false",
              "type": "boolean"
            }
          },
          {
            "name": "showStats",
            "required": false,
            "in": "query",
            "description": "When true, returns campaign statistics including delivered count, opened count, clicked count and revenue if available for the campaign. When false, returns campaign data without statistics.",
            "schema": {
              "default": true,
              "example": "true",
              "type": "boolean"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScheduleFetchSuccessfulDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "403": {
            "description": "The token does not have access to this location",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvalidLocationDTO"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "emails/schedule.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "ScheduleFetchSuccessfulDTO": {
        "type": "object",
        "properties": {
          "schedules": {
            "description": "The list of campaigns",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "example": "Untitled new campaign"
                },
                "repeatAfter": {
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "parentId": {
                  "type": "string"
                },
                "childCount": {
                  "type": "number"
                },
                "campaignType": {
                  "type": "string"
                },
                "bulkActionVersion": {
                  "type": "string"
                },
                "_id": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "sendDays": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "deleted": {
                  "type": "boolean"
                },
                "migrated": {
                  "type": "boolean"
                },
                "archived": {
                  "type": "boolean"
                },
                "hasTracking": {
                  "type": "boolean"
                },
                "isPlainText": {
                  "type": "boolean"
                },
                "hasUtmTracking": {
                  "type": "boolean"
                },
                "enableResendToUnopened": {
                  "type": "boolean"
                },
                "locationId": {
                  "type": "string"
                },
                "templateId": {
                  "type": "string"
                },
                "templateType": {
                  "type": "string"
                },
                "createdAt": {
                  "type": "string"
                },
                "updatedAt": {
                  "type": "string"
                },
                "__v": {
                  "type": "number"
                },
                "documentId": {
                  "type": "string"
                },
                "downloadUrl": {
                  "type": "string"
                },
                "templateDataDownloadUrl": {
                  "type": "string"
                },
                "child": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "required": [
                "name",
                "repeatAfter",
                "id",
                "parentId",
                "childCount",
                "campaignType",
                "bulkActionVersion",
                "_id",
                "status",
                "sendDays",
                "deleted",
                "migrated",
                "archived",
                "hasTracking",
                "isPlainText",
                "hasUtmTracking",
                "enableResendToUnopened",
                "locationId",
                "templateId",
                "templateType",
                "createdAt",
                "updatedAt",
                "__v",
                "documentId",
                "downloadUrl",
                "templateDataDownloadUrl",
                "child"
              ],
              "title": "ScheduleDto"
            }
          },
          "total": {
            "description": "The total number of campaigns",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "traceId": {
            "type": "string",
            "description": "Trace Id"
          }
        },
        "required": [
          "schedules",
          "total",
          "traceId"
        ],
        "title": "ScheduleFetchSuccessfulDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "InvalidLocationDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for invalid location access",
            "example": 403
          },
          "message": {
            "type": "string",
            "description": "Error message describing the location access failure",
            "example": "The token does not have access to this location"
          }
        },
        "title": "InvalidLocationDTO"
      },
      "NotFoundDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for not found",
            "example": 404
          },
          "message": {
            "type": "string",
            "description": "Error message describing the not found failure",
            "example": "Not Found"
          },
          "error": {
            "type": "string",
            "description": "Error type identifier",
            "example": "The requested resource was not found"
          }
        },
        "title": "NotFoundDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const response = await ghl.emails.getCampaigns({ locationId: '<LOCATIONID>' });
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

response = await client.emails.get_campaigns(locationId='<LOCATIONID>')
print(response)
```

**PHP** (`gohighlevel/api-client`)

```php
<?php
require_once 'vendor/autoload.php';

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$response = $ghl->emails->getCampaigns(['locationId' => '<LOCATIONID>']);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/emails/schedule?locationId=<LOCATIONID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/emails/schedule?locationId=<LOCATIONID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/emails/schedule"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-04-15"
}

params = {
    "locationId": "<LOCATIONID>"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/emails/schedule?locationId=<LOCATIONID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/emails/schedule?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/emails/schedule?locationId=<LOCATIONID>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-04-15")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/emails/schedule?locationId=<LOCATIONID>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-04-15"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/emails/schedule?locationId=<LOCATIONID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
