# Get Affiliate

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

Retrieve a single affiliate by id 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 |
| `affiliateId` | string | Yes | Affiliate Id |

## 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/{affiliateId}": {
      "get": {
        "summary": "Get Affiliate",
        "operationId": "getAffiliate",
        "description": "Retrieve a single affiliate by id 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": "affiliateId",
            "required": true,
            "in": "path",
            "description": "Affiliate Id",
            "schema": {
              "example": "6385d230f6d19db03eef6fb2",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetAffiliateResponseDto"
                }
              }
            }
          },
          "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": {
      "GetAffiliateResponseDto": {
        "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
          }
        },
        "required": [
          "_id",
          "locationId",
          "email"
        ],
        "title": "GetAffiliateResponseDto"
      },
      "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/<affiliateId>' \
  -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/<affiliateId>', 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/{affiliateId}"

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/<affiliateId>',
  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/<affiliateId>")
  .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/<affiliateId>"
  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/<affiliateId>")

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/<affiliateId>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
