# Get SaaS Locations

GET https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/{companyId}

Fetch all SaaS-activated locations for a company with pagination

## Authentication

Send `Authorization: Bearer <token>` using:

- **Agency token: OAuth access token or Private Integration Token.** No scopes required.

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `companyId` | string | Yes | Company ID to get SaaS locations for |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `page` | number | No | Page number for pagination |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2023-02-21"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/saas-api/public-api/saas-locations/{companyId}": {
      "get": {
        "summary": "Get SaaS Locations",
        "operationId": "getSaasLocations",
        "description": "Fetch all SaaS-activated locations for a company with pagination",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2023-02-21"
              ]
            }
          },
          {
            "name": "companyId",
            "required": true,
            "in": "path",
            "description": "Company ID to get SaaS locations for",
            "example": "5DP4iH6HLkQsiKESj6rh",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number for pagination",
            "example": 1,
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SaaS locations retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetSaasLocationsResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResourceNotFoundDTO"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InternalServerErrorDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Agency-Access": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "token-id",
        "in": "header",
        "description": "Use the Access Token generated by exchanging API Key for token id",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Location",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Company",
        "type": "http"
      }
    },
    "schemas": {
      "GetSaasLocationsResponseDto": {
        "type": "object",
        "properties": {
          "locations": {
            "description": "Array of SaaS locations",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "locationId": {
                  "type": "string",
                  "description": "Location ID",
                  "example": "locationId1"
                },
                "companyId": {
                  "type": "string",
                  "description": "Company ID",
                  "example": "companyId1"
                },
                "saasMode": {
                  "type": "string",
                  "description": "SaaS mode",
                  "example": "saasV2"
                },
                "subscriptionId": {
                  "type": "string",
                  "description": "Subscription ID",
                  "example": "subscriptionId1"
                },
                "customerId": {
                  "type": "string",
                  "description": "Customer ID",
                  "example": "customerId1"
                },
                "name": {
                  "type": "string",
                  "description": "Name",
                  "example": "John Doe"
                },
                "email": {
                  "type": "string",
                  "description": "Email",
                  "example": "john.doe@example.com"
                },
                "providerLocationId": {
                  "type": "string",
                  "description": "Provider location ID",
                  "example": "r06mdj4OrrERzYDvsOdh"
                },
                "isSaaSV2": {
                  "type": "boolean",
                  "description": "Indicates if the SaaS is V2",
                  "example": true
                },
                "subscriptionInfo": {
                  "type": "object",
                  "description": "Subscription information",
                  "example": {
                    "priceId": "price_1QDPY5FpU9DlKp7RQ8BXfywx",
                    "saasPlanId": "66c4d36534f21f900dc2a265",
                    "stripeProductId": "prod_1QDPY5FpU9DlKp7RQ8BXfywx",
                    "subscriptionStatus": "active"
                  }
                }
              },
              "required": [
                "locationId",
                "companyId",
                "saasMode",
                "subscriptionId"
              ],
              "title": "SaasLocationDto"
            }
          },
          "pagination": {
            "type": "object",
            "properties": {
              "page": {
                "type": "number",
                "example": 1,
                "description": "Page number"
              },
              "limit": {
                "type": "number",
                "example": 10,
                "description": "Number of items per page"
              },
              "total": {
                "type": "number",
                "example": 100,
                "description": "Total number of items"
              },
              "totalPages": {
                "type": "number",
                "example": 10,
                "description": "Total number of pages"
              },
              "hasNext": {
                "type": "boolean",
                "example": true,
                "description": "Indicates if there is a next page"
              },
              "hasPrev": {
                "type": "boolean",
                "example": true,
                "description": "Indicates if there is a previous page"
              }
            }
          }
        },
        "required": [
          "locations",
          "pagination"
        ],
        "title": "GetSaasLocationsResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400,
            "description": "Status code"
          },
          "message": {
            "type": "string",
            "example": "Bad Request",
            "description": "Error message"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401,
            "description": "Status code"
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid",
            "description": "Error message"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized",
            "description": "Error message"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "ResourceNotFoundDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 404,
            "description": "Status code"
          },
          "message": {
            "type": "string",
            "example": [
              "Contact not found",
              "User not found",
              "Group not found",
              "Channel not found"
            ],
            "description": "Error message"
          }
        },
        "title": "ResourceNotFoundDTO"
      },
      "InternalServerErrorDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 500,
            "description": "Status code"
          },
          "message": {
            "type": "string",
            "example": "Internal Server Error",
            "description": "Error message"
          }
        },
        "title": "InternalServerErrorDTO"
      }
    }
  }
}
```

## 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.saasApi.getSaasLocations('<COMPANYID>');
console.log(response);
```

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

```python
from highlevel import HighLevel

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

response = await client.saasApi.get_saas_locations('<COMPANYID>')
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->saasApi->getSaasLocations('<COMPANYID>');
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/<companyId>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2023-02-21'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2023-02-21'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/<companyId>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/{companyId}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2023-02-21"
}

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

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/<companyId>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2023-02-21',
  ],
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/<companyId>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2023-02-21")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/<companyId>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2023-02-21")

  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/saas-api/public-api/saas-locations/<companyId>")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2023-02-21"

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2023-02-21"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/saas-api/public-api/saas-locations/<companyId>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
