# Update Affiliate

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

Replace an affiliate for a location. Fields omitted from the body are cleared, so send the complete affiliate.

## Authentication

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

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

## 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": "2023-02-21"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/affiliate-manager/{locationId}/affiliates/{affiliateId}": {
      "put": {
        "summary": "Update Affiliate",
        "operationId": "updateAffiliate",
        "description": "Replace an affiliate for a location. Fields omitted from the body are cleared, so send the complete affiliate.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2023-02-21"
              ]
            }
          },
          {
            "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"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateRequest"
              }
            }
          }
        },
        "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"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden"
          },
          "404": {
            "description": "Affiliate not found"
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "affiliate-manager.write"
            ]
          },
          {
            "Location-Access": [
              "affiliate-manager.write"
            ]
          }
        ]
      }
    }
  },
  "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": {
      "CreateRequest": {
        "type": "object",
        "properties": {
          "affiliateFirstName": {
            "type": "string",
            "description": "First Name",
            "example": "John"
          },
          "affiliateLastName": {
            "type": "string",
            "description": "Last Name",
            "example": "Deo"
          },
          "affiliateEmail": {
            "type": "string",
            "description": "Email",
            "example": "john@deo.com"
          },
          "phoneNumber": {
            "type": "string",
            "description": "Phone Number",
            "example": "+1 888 888-8888"
          },
          "websiteUrl": {
            "type": "string",
            "description": "Website",
            "example": "https://google.com"
          },
          "campaignId": {
            "type": "string",
            "description": "Campaign to enrol the affiliate into",
            "example": "6385d230f6d19db03eef6fb2"
          },
          "companyName": {
            "type": "string",
            "description": "Company the affiliate represents",
            "example": "Acme Inc"
          },
          "parentAffiliateId": {
            "type": "string",
            "description": "Affiliate this one is a sub affiliate of",
            "example": "63d376de11be1d26d38f7369"
          },
          "tier": {
            "type": "number",
            "description": "Commission tier the affiliate sits on within the campaign",
            "example": 2,
            "minimum": 1
          },
          "companyPhoneNumber": {
            "type": "string",
            "description": "Company Phone Number",
            "example": "+1 888 888-8888"
          },
          "vatId": {
            "type": "string",
            "description": "VAT ID",
            "example": "VAT12345"
          },
          "country": {
            "type": "string",
            "description": "Country",
            "example": "US"
          },
          "address": {
            "type": "string",
            "description": "Address",
            "example": "123 Main St"
          },
          "avatar": {
            "type": "string",
            "description": "Avatar URL",
            "example": "https://example.com/avatar.jpg"
          },
          "facebookUrl": {
            "type": "string",
            "description": "Facebook URL",
            "example": "https://facebook.com/profile"
          },
          "twitterUrl": {
            "type": "string",
            "description": "Twitter URL",
            "example": "https://twitter.com/profile"
          },
          "youtubeUrl": {
            "type": "string",
            "description": "YouTube URL",
            "example": "https://youtube.com/channel"
          },
          "linkedInUrl": {
            "type": "string",
            "description": "LinkedIn URL",
            "example": "https://linkedin.com/in/profile"
          },
          "instagramUrl": {
            "type": "string",
            "description": "Instagram URL",
            "example": "https://instagram.com/profile"
          }
        },
        "required": [
          "affiliateEmail"
        ],
        "title": "CreateRequest"
      },
      "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 PUT 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2023-02-21' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "affiliateFirstName": "John",
  "affiliateLastName": "Deo",
  "affiliateEmail": "john@deo.com",
  "phoneNumber": "+1 888 888-8888",
  "websiteUrl": "https://google.com",
  "campaignId": "6385d230f6d19db03eef6fb2",
  "companyName": "Acme Inc",
  "parentAffiliateId": "63d376de11be1d26d38f7369",
  "tier": 2,
  "companyPhoneNumber": "+1 888 888-8888",
  "vatId": "VAT12345",
  "country": "US",
  "address": "123 Main St",
  "avatar": "https://example.com/avatar.jpg",
  "facebookUrl": "https://facebook.com/profile",
  "twitterUrl": "https://twitter.com/profile",
  "youtubeUrl": "https://youtube.com/channel",
  "linkedInUrl": "https://linkedin.com/in/profile",
  "instagramUrl": "https://instagram.com/profile"
}'
```

**Node.js**

```javascript
const options = {
  method: 'PUT',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2023-02-21',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "affiliateFirstName": "John",
      "affiliateLastName": "Deo",
      "affiliateEmail": "john@deo.com",
      "phoneNumber": "+1 888 888-8888",
      "websiteUrl": "https://google.com",
      "campaignId": "6385d230f6d19db03eef6fb2",
      "companyName": "Acme Inc",
      "parentAffiliateId": "63d376de11be1d26d38f7369",
      "tier": 2,
      "companyPhoneNumber": "+1 888 888-8888",
      "vatId": "VAT12345",
      "country": "US",
      "address": "123 Main St",
      "avatar": "https://example.com/avatar.jpg",
      "facebookUrl": "https://facebook.com/profile",
      "twitterUrl": "https://twitter.com/profile",
      "youtubeUrl": "https://youtube.com/channel",
      "linkedInUrl": "https://linkedin.com/in/profile",
      "instagramUrl": "https://instagram.com/profile"
  })
};

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": "2023-02-21"
}

payload = {
    "affiliateFirstName": "John",
    "affiliateLastName": "Deo",
    "affiliateEmail": "john@deo.com",
    "phoneNumber": "+1 888 888-8888",
    "websiteUrl": "https://google.com",
    "campaignId": "6385d230f6d19db03eef6fb2",
    "companyName": "Acme Inc",
    "parentAffiliateId": "63d376de11be1d26d38f7369",
    "tier": 2,
    "companyPhoneNumber": "+1 888 888-8888",
    "vatId": "VAT12345",
    "country": "US",
    "address": "123 Main St",
    "avatar": "https://example.com/avatar.jpg",
    "facebookUrl": "https://facebook.com/profile",
    "twitterUrl": "https://twitter.com/profile",
    "youtubeUrl": "https://youtube.com/channel",
    "linkedInUrl": "https://linkedin.com/in/profile",
    "instagramUrl": "https://instagram.com/profile"
}

response = requests.put(url, json=payload, 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 => 'PUT',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2023-02-21',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "affiliateFirstName": "John",
  "affiliateLastName": "Deo",
  "affiliateEmail": "john@deo.com",
  "phoneNumber": "+1 888 888-8888",
  "websiteUrl": "https://google.com",
  "campaignId": "6385d230f6d19db03eef6fb2",
  "companyName": "Acme Inc",
  "parentAffiliateId": "63d376de11be1d26d38f7369",
  "tier": 2,
  "companyPhoneNumber": "+1 888 888-8888",
  "vatId": "VAT12345",
  "country": "US",
  "address": "123 Main St",
  "avatar": "https://example.com/avatar.jpg",
  "facebookUrl": "https://facebook.com/profile",
  "twitterUrl": "https://twitter.com/profile",
  "youtubeUrl": "https://youtube.com/channel",
  "linkedInUrl": "https://linkedin.com/in/profile",
  "instagramUrl": "https://instagram.com/profile"
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .put("https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2023-02-21")
  .header("Content-Type", "application/json")
  .body("{\"affiliateFirstName\":\"John\",\"affiliateLastName\":\"Deo\",\"affiliateEmail\":\"john@deo.com\",\"phoneNumber\":\"+1 888 888-8888\",\"websiteUrl\":\"https://google.com\",\"campaignId\":\"6385d230f6d19db03eef6fb2\",\"companyName\":\"Acme Inc\",\"parentAffiliateId\":\"63d376de11be1d26d38f7369\",\"tier\":2,\"companyPhoneNumber\":\"+1 888 888-8888\",\"vatId\":\"VAT12345\",\"country\":\"US\",\"address\":\"123 Main St\",\"avatar\":\"https://example.com/avatar.jpg\",\"facebookUrl\":\"https://facebook.com/profile\",\"twitterUrl\":\"https://twitter.com/profile\",\"youtubeUrl\":\"https://youtube.com/channel\",\"linkedInUrl\":\"https://linkedin.com/in/profile\",\"instagramUrl\":\"https://instagram.com/profile\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>"
  payload := strings.NewReader(`{
  "affiliateFirstName": "John",
  "affiliateLastName": "Deo",
  "affiliateEmail": "john@deo.com",
  "phoneNumber": "+1 888 888-8888",
  "websiteUrl": "https://google.com",
  "campaignId": "6385d230f6d19db03eef6fb2",
  "companyName": "Acme Inc",
  "parentAffiliateId": "63d376de11be1d26d38f7369",
  "tier": 2,
  "companyPhoneNumber": "+1 888 888-8888",
  "vatId": "VAT12345",
  "country": "US",
  "address": "123 Main St",
  "avatar": "https://example.com/avatar.jpg",
  "facebookUrl": "https://facebook.com/profile",
  "twitterUrl": "https://twitter.com/profile",
  "youtubeUrl": "https://youtube.com/channel",
  "linkedInUrl": "https://linkedin.com/in/profile",
  "instagramUrl": "https://instagram.com/profile"
}`)
  req, _ := http.NewRequest("PUT", url, payload)
  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/affiliate-manager/<locationId>/affiliates/<affiliateId>")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2023-02-21"
request["Content-Type"] = "application/json"
request.body = '{
  "affiliateFirstName": "John",
  "affiliateLastName": "Deo",
  "affiliateEmail": "john@deo.com",
  "phoneNumber": "+1 888 888-8888",
  "websiteUrl": "https://google.com",
  "campaignId": "6385d230f6d19db03eef6fb2",
  "companyName": "Acme Inc",
  "parentAffiliateId": "63d376de11be1d26d38f7369",
  "tier": 2,
  "companyPhoneNumber": "+1 888 888-8888",
  "vatId": "VAT12345",
  "country": "US",
  "address": "123 Main St",
  "avatar": "https://example.com/avatar.jpg",
  "facebookUrl": "https://facebook.com/profile",
  "twitterUrl": "https://twitter.com/profile",
  "youtubeUrl": "https://youtube.com/channel",
  "linkedInUrl": "https://linkedin.com/in/profile",
  "instagramUrl": "https://instagram.com/profile"
}'

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

**PowerShell**

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

$body = '{
  "affiliateFirstName": "John",
  "affiliateLastName": "Deo",
  "affiliateEmail": "john@deo.com",
  "phoneNumber": "+1 888 888-8888",
  "websiteUrl": "https://google.com",
  "campaignId": "6385d230f6d19db03eef6fb2",
  "companyName": "Acme Inc",
  "parentAffiliateId": "63d376de11be1d26d38f7369",
  "tier": 2,
  "companyPhoneNumber": "+1 888 888-8888",
  "vatId": "VAT12345",
  "country": "US",
  "address": "123 Main St",
  "avatar": "https://example.com/avatar.jpg",
  "facebookUrl": "https://facebook.com/profile",
  "twitterUrl": "https://twitter.com/profile",
  "youtubeUrl": "https://youtube.com/channel",
  "linkedInUrl": "https://linkedin.com/in/profile",
  "instagramUrl": "https://instagram.com/profile"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/affiliate-manager/<locationId>/affiliates/<affiliateId>' -Method 'PUT' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
