# List Affiliates

GET https://services.leadconnectorhq.com/affiliate-manager/{locationId}/affiliates

Retrieve the list of affiliates for a location.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `affiliate-manager.readonly`

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location Id |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `query` | string | No | Search affiliates by name or email |
| `active` | boolean | No | Filter affiliates by active status |
| `campaignId` | string | No | Filter affiliates by campaign ID |
| `skip` | number | No | Number of records to skip for pagination |
| `limit` | number | No | Maximum number of records to return. Maximum allowed value is 100. A value of 0 is treated as the default of 10. |
| `fromDate` | string | No | Filter affiliates created on or after this date (YYYY-MM-DD) |
| `toDate` | string | No | Filter affiliates created on or before this date (YYYY-MM-DD) |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-07-28"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/affiliate-manager/{locationId}/affiliates": {
      "get": {
        "summary": "List Affiliates",
        "operationId": "listAffiliates",
        "description": "Retrieve the list of affiliates for a location.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-07-28"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location Id",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          },
          {
            "name": "query",
            "required": false,
            "in": "query",
            "description": "Search affiliates by name or email",
            "schema": {
              "example": "John",
              "type": "string"
            }
          },
          {
            "name": "active",
            "required": false,
            "in": "query",
            "description": "Filter affiliates by active status",
            "schema": {
              "default": false,
              "example": true,
              "type": "boolean"
            }
          },
          {
            "name": "campaignId",
            "required": false,
            "in": "query",
            "description": "Filter affiliates by campaign ID",
            "schema": {
              "example": "63d376de11be1d26d38f7369",
              "type": "string"
            }
          },
          {
            "name": "skip",
            "required": false,
            "in": "query",
            "description": "Number of records to skip for pagination",
            "schema": {
              "minimum": 0,
              "default": 0,
              "example": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Maximum number of records to return. Maximum allowed value is 100. A value of 0 is treated as the default of 10.",
            "schema": {
              "minimum": 0,
              "maximum": 100,
              "default": 10,
              "example": 10,
              "type": "number"
            }
          },
          {
            "name": "fromDate",
            "required": false,
            "in": "query",
            "description": "Filter affiliates created on or after this date (YYYY-MM-DD)",
            "schema": {
              "example": "2023-10-01",
              "type": "string"
            }
          },
          {
            "name": "toDate",
            "required": false,
            "in": "query",
            "description": "Filter affiliates created on or before this date (YYYY-MM-DD)",
            "schema": {
              "example": "2023-10-01",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListAffiliatesResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "affiliate-manager.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": {
      "ListAffiliatesResponseDto": {
        "type": "object",
        "properties": {
          "affiliates": {
            "description": "Affiliate list",
            "example": [
              {
                "_id": "63d147176c5bbc30e9e091a4",
                "firstName": "John",
                "lastName": "Doe",
                "email": "john.doe@example.com",
                "phone": "+1 888 888-8888",
                "locationId": "ve9EPM428h8vShlRW1KT",
                "active": true,
                "contactId": "ve9EPM428h8vShlRW1KT",
                "createdAt": "2024-06-16T00:00:00.000Z"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "_id": {
                  "type": "string",
                  "description": "Affiliate id",
                  "example": "63d147176c5bbc30e9e091a4"
                },
                "firstName": {
                  "type": "string",
                  "description": "Affiliate first name",
                  "example": "John"
                },
                "lastName": {
                  "type": "string",
                  "description": "Affiliate last name",
                  "example": "Doe"
                },
                "phone": {
                  "type": "string",
                  "description": "Affiliate phone number",
                  "example": "+1 888 888-8888"
                },
                "deleted": {
                  "type": "boolean",
                  "description": "Whether the affiliate is deleted",
                  "example": false
                },
                "locationId": {
                  "type": "string",
                  "description": "Location id",
                  "example": "ve9EPM428h8vShlRW1KT"
                },
                "active": {
                  "type": "boolean",
                  "description": "Whether the affiliate is active",
                  "example": true
                },
                "address": {
                  "type": "string",
                  "description": "Affiliate address",
                  "example": "123 Main St"
                },
                "avatar": {
                  "type": "string",
                  "description": "Affiliate avatar URL",
                  "example": "https://example.com/avatar.png"
                },
                "createdAt": {
                  "type": "string",
                  "description": "Created at timestamp",
                  "example": "2024-06-16T00:00:00.000Z"
                },
                "createdBy": {
                  "description": "Who created the affiliate",
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "source": {
                          "type": "string",
                          "description": "Source of the action",
                          "example": "oauth"
                        },
                        "channel": {
                          "type": "string",
                          "description": "Channel of the action",
                          "example": "oauth"
                        },
                        "sourceId": {
                          "type": "string",
                          "description": "Source id of the actor",
                          "example": "source_123"
                        },
                        "sourceName": {
                          "type": "string",
                          "description": "Source name of the actor",
                          "example": "Marketplace App"
                        },
                        "timestamp": {
                          "type": "string",
                          "description": "Timestamp when the action happened",
                          "example": "2024-06-16T00:00:00.000Z"
                        }
                      },
                      "title": "AffiliateAuditResponseDto"
                    }
                  ]
                },
                "facebookUrl": {
                  "type": "string",
                  "description": "Facebook URL",
                  "example": "https://facebook.com/johndoe"
                },
                "instagramUrl": {
                  "type": "string",
                  "description": "Instagram URL",
                  "example": "https://instagram.com/johndoe"
                },
                "linkedInUrl": {
                  "type": "string",
                  "description": "LinkedIn URL",
                  "example": "https://linkedin.com/in/johndoe"
                },
                "twitterUrl": {
                  "type": "string",
                  "description": "Twitter URL",
                  "example": "https://twitter.com/johndoe"
                },
                "youtubeUrl": {
                  "type": "string",
                  "description": "YouTube URL",
                  "example": "https://youtube.com/channel"
                },
                "websiteUrl": {
                  "type": "string",
                  "description": "Website URL",
                  "example": "https://example.com"
                },
                "contactId": {
                  "type": "string",
                  "description": "Contact id associated with the affiliate",
                  "example": "ve9EPM428h8vShlRW1KT"
                },
                "campaignIds": {
                  "description": "Campaign ids",
                  "example": [
                    "650173614761b33c46d33b19"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "vatId": {
                  "type": "string",
                  "description": "VAT ID",
                  "example": "VAT123"
                },
                "updatedAt": {
                  "type": "string",
                  "description": "Updated at timestamp",
                  "example": "2024-06-16T00:00:00.000Z"
                },
                "w8Form": {
                  "type": "string",
                  "description": "W-8 form URL",
                  "example": "https://example.com/tax-forms/w8.pdf"
                },
                "w9Form": {
                  "type": "string",
                  "description": "W-9 form URL",
                  "example": "https://example.com/tax-forms/w9.pdf"
                },
                "lastUpdatedBy": {
                  "description": "Who last updated the affiliate",
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "source": {
                          "type": "string",
                          "description": "Source of the action",
                          "example": "oauth"
                        },
                        "channel": {
                          "type": "string",
                          "description": "Channel of the action",
                          "example": "oauth"
                        },
                        "sourceId": {
                          "type": "string",
                          "description": "Source id of the actor",
                          "example": "source_123"
                        },
                        "sourceName": {
                          "type": "string",
                          "description": "Source name of the actor",
                          "example": "Marketplace App"
                        },
                        "timestamp": {
                          "type": "string",
                          "description": "Timestamp when the action happened",
                          "example": "2024-06-16T00:00:00.000Z"
                        }
                      },
                      "title": "AffiliateAuditResponseDto"
                    }
                  ]
                },
                "email": {
                  "type": "string",
                  "description": "Affiliate email",
                  "example": "john.doe@example.com"
                },
                "revenue": {
                  "type": "number",
                  "description": "Affiliate revenue",
                  "example": 1250.5
                },
                "companyName": {
                  "type": "string",
                  "description": "Company name",
                  "example": "Doe Media LLC"
                },
                "companyPhoneNumber": {
                  "type": "string",
                  "description": "Company phone number",
                  "example": "+1 888 888-8888"
                },
                "country": {
                  "type": "string",
                  "description": "Country the affiliate was created with",
                  "example": "US"
                },
                "commissionTier": {
                  "type": "number",
                  "description": "Commission tier the affiliate sits in",
                  "example": 1
                },
                "customer": {
                  "type": "number",
                  "description": "Customer count",
                  "example": 15
                },
                "lead": {
                  "type": "number",
                  "description": "Lead count",
                  "example": 5
                },
                "droppedCustomer": {
                  "type": "number",
                  "description": "Dropped customer count",
                  "example": 2
                },
                "clickCount": {
                  "type": "number",
                  "description": "Click count",
                  "example": 100
                },
                "paid": {
                  "type": "number",
                  "description": "Commission already paid out",
                  "example": 500
                },
                "currency": {
                  "type": "string",
                  "description": "Currency of revenue, paid and owned",
                  "example": "USD"
                },
                "owned": {
                  "type": "number",
                  "description": "Commission owed but not yet paid — approved and pending commission combined",
                  "example": 750
                }
              },
              "required": [
                "_id",
                "locationId",
                "email"
              ],
              "title": "OAuthAffiliateListItemResponseDto"
            }
          },
          "meta": {
            "description": "Pagination metadata",
            "example": {
              "count": 10
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "number",
                    "description": "Total affiliates matching the applied filters",
                    "example": 42
                  }
                },
                "required": [
                  "count"
                ],
                "title": "AffiliateListMetaResponseDto"
              }
            ]
          }
        },
        "required": [
          "affiliates",
          "meta"
        ],
        "title": "ListAffiliatesResponseDto"
      },
      "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"
      },
      "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"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-07-28'
```

**Node.js**

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

try {
  const response = await fetch('https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/affiliate-manager/{locationId}/affiliates"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-07-28"
}

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/affiliate-manager/<locationId>/affiliates',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-07-28',
  ],
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-07-28")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-07-28")

  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/affiliate-manager/<locationId>/affiliates")

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-07-28"

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

**PowerShell**

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

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
