# List affiliate media

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

Retrieve media files and folders for a location.

## Authentication

Send `Authorization: Bearer <token>` using any one of:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `affiliate-manager.readonly`
- **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 media by name |
| `parentId` | string | No | Filter media by parent folder |
| `campaignId` | string | No | Filter media by campaign |
| `mediaType` | string | No | Filter by media type |
| `skip` | number | No | Number of records to skip |
| `limit` | number | No | Maximum number of records to return. Maximum allowed value is 100. |
| `sortByType` | string | No | Sort order for returned media |
| `showGlobal` | boolean | No | Show image set for global campaign |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/affiliate-manager/{locationId}/media": {
      "get": {
        "summary": "List affiliate media",
        "operationId": "listAffiliateMedia",
        "description": "Retrieve media files and folders for a location.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "path",
            "description": "Location Id",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          },
          {
            "name": "query",
            "required": false,
            "in": "query",
            "description": "Search media by name",
            "schema": {
              "example": "John",
              "type": "string"
            }
          },
          {
            "name": "parentId",
            "required": false,
            "in": "query",
            "description": "Filter media by parent folder",
            "schema": {
              "example": "63d376de11be1d26d38f7369",
              "type": "string"
            }
          },
          {
            "name": "campaignId",
            "required": false,
            "in": "query",
            "description": "Filter media by campaign",
            "schema": {
              "example": "63d376de11be1d26d38f7369",
              "type": "string"
            }
          },
          {
            "name": "mediaType",
            "required": false,
            "in": "query",
            "description": "Filter by media type",
            "schema": {
              "example": "folder",
              "enum": [
                "folder",
                "file"
              ],
              "type": "string"
            }
          },
          {
            "name": "skip",
            "required": false,
            "in": "query",
            "description": "Number of records to skip",
            "schema": {
              "default": 0,
              "example": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Maximum number of records to return. Maximum allowed value is 100.",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 10,
              "example": 10,
              "type": "number"
            }
          },
          {
            "name": "sortByType",
            "required": false,
            "in": "query",
            "description": "Sort order for returned media",
            "schema": {
              "default": "updatedAt-newest",
              "example": "updatedAt-newest",
              "enum": [
                "name-a-to-z",
                "name-z-to-a",
                "updatedAt-newest",
                "updatedAt-oldest"
              ],
              "type": "string"
            }
          },
          {
            "name": "showGlobal",
            "required": false,
            "in": "query",
            "description": "Show image set for global campaign",
            "schema": {
              "default": false,
              "example": false,
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListAffiliateMediaResponseDTO"
                }
              }
            }
          },
          "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": "Forbidden"
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "affiliate-manager.readonly"
            ]
          },
          {
            "Location-Access": [
              "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": {
      "ListAffiliateMediaResponseDTO": {
        "type": "object",
        "properties": {
          "mediaList": {
            "description": "Media files and folders",
            "example": [
              {
                "_id": "63d376de11be1d26d38f7369",
                "name": "brand-logo.png",
                "type": "file"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "_id": {
                  "type": "string",
                  "description": "Media identifier",
                  "example": "63d376de11be1d26d38f7369"
                },
                "locationId": {
                  "type": "string",
                  "description": "Location identifier",
                  "example": "ve9EPM428h8vShlRW1KT"
                },
                "name": {
                  "type": "string",
                  "description": "Media name",
                  "example": "brand-logo.png"
                },
                "type": {
                  "type": "string",
                  "description": "Media type",
                  "example": "file",
                  "enum": [
                    "folder",
                    "file"
                  ]
                },
                "parentId": {
                  "type": "string",
                  "description": "Parent folder identifier",
                  "example": "63d376de11be1d26d38f7369"
                },
                "altId": {
                  "type": "string",
                  "description": "Alternative identifier",
                  "example": "ve9EPM428h8vShlRW1KT"
                },
                "altType": {
                  "type": "string",
                  "description": "Alternative identifier type",
                  "example": "media"
                },
                "contentType": {
                  "type": "string",
                  "description": "Content type",
                  "example": "image/png"
                },
                "url": {
                  "type": "string",
                  "description": "Media URL",
                  "example": "https://example.com/brand-logo.png"
                },
                "size": {
                  "type": "number",
                  "description": "Media size in bytes",
                  "example": 45678
                },
                "campaignIds": {
                  "description": "Campaign identifiers associated with the media",
                  "example": [
                    "63d376de11be1d26d38f7369"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "campaigns": {
                  "description": "Campaigns associated with the media",
                  "example": [
                    {
                      "_id": "63d376de11be1d26d38f7369",
                      "name": "Summer campaign"
                    }
                  ],
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "_id": {
                        "type": "string",
                        "description": "Campaign identifier",
                        "example": "63d376de11be1d26d38f7369"
                      },
                      "name": {
                        "type": "string",
                        "description": "Campaign name",
                        "example": "Summer campaign"
                      }
                    },
                    "required": [
                      "_id",
                      "name"
                    ],
                    "title": "MediaCampaignResponseDTO"
                  }
                },
                "deleted": {
                  "type": "boolean",
                  "description": "Whether the media is deleted",
                  "example": false
                },
                "createdAt": {
                  "format": "date-time",
                  "type": "string",
                  "description": "Creation time",
                  "example": "2024-01-01T00:00:00.000Z"
                },
                "updatedAt": {
                  "format": "date-time",
                  "type": "string",
                  "description": "Last update time",
                  "example": "2024-01-01T00:00:00.000Z"
                }
              },
              "title": "AffiliateMediaResponseDTO"
            }
          },
          "meta": {
            "description": "Pagination metadata",
            "example": {
              "count": 1
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "number",
                    "description": "Number of media records",
                    "example": 1
                  }
                },
                "required": [
                  "count"
                ],
                "title": "MediaListMetaResponseDTO"
              }
            ]
          }
        },
        "required": [
          "mediaList"
        ],
        "title": "ListAffiliateMediaResponseDTO"
      },
      "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>/media' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

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

try {
  const response = await fetch('https://services.leadconnectorhq.com/affiliate-manager/<locationId>/media', 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}/media"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

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>/media',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

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

**Java**

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

**Go**

```go
package main

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

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

  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>/media")

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

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

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

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