# Move Affiliate To Campaign

POST https://services.leadconnectorhq.com/affiliate-manager/affiliate-campaign/affiliate/{affiliateId}/move-campaign

Move an affiliate from its current campaign to another campaign in the same location.

## 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 |
|------|------|----------|-------------|
| `affiliateId` | string | Yes | Affiliate Id |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v4"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/affiliate-manager/affiliate-campaign/affiliate/{affiliateId}/move-campaign": {
      "post": {
        "summary": "Move Affiliate To Campaign",
        "operationId": "moveAffiliateToCampaign",
        "description": "Move an affiliate from its current campaign to another campaign in the same location.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v4"
              ]
            }
          },
          {
            "name": "affiliateId",
            "required": true,
            "in": "path",
            "description": "Affiliate Id",
            "schema": {
              "example": "6385d230f6d19db03eef6fb2",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MoveAffiliateToCampaignV4Dto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AffiliateCampaignActionResponseDto"
                }
              }
            }
          },
          "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.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": {
      "MoveAffiliateToCampaignV4Dto": {
        "type": "object",
        "properties": {
          "sourceCampaignId": {
            "type": "string",
            "description": "Source Campaign Id",
            "example": "6385d230f6d19db03eef6fb2"
          },
          "targetCampaignId": {
            "type": "string",
            "description": "Target Campaign Id",
            "example": "6512c3a1f6d19db03eef7a04"
          },
          "moveMode": {
            "type": "number",
            "description": "Move mode — 1 keeps recurrent commissions in the old campaign, 2 moves all data with the original AM id",
            "example": 1,
            "enum": [
              1,
              2
            ]
          },
          "sendWelcomeEmail": {
            "type": "boolean",
            "description": "Whether to send a welcome email to this affiliate after moving. If the target campaign has welcome emails disabled, no email will be sent even if this is turned on. If the campaign has it enabled, you can disable it here to skip sending for this affiliate.",
            "example": true,
            "default": true
          },
          "locationId": {
            "type": "string",
            "description": "Location Id",
            "example": "ve9EPM428h8vShlRW1KT"
          }
        },
        "required": [
          "sourceCampaignId",
          "targetCampaignId",
          "moveMode",
          "locationId"
        ],
        "title": "MoveAffiliateToCampaignV4Dto"
      },
      "AffiliateCampaignActionResponseDto": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Whether the action completed",
            "example": true
          },
          "message": {
            "type": "string",
            "description": "Human readable outcome",
            "example": "Affiliate suspended successfully"
          }
        },
        "required": [
          "success",
          "message"
        ],
        "title": "AffiliateCampaignActionResponseDto"
      },
      "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 POST 'https://services.leadconnectorhq.com/affiliate-manager/affiliate-campaign/affiliate/<affiliateId>/move-campaign' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v4' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "sourceCampaignId": "6385d230f6d19db03eef6fb2",
  "targetCampaignId": "6512c3a1f6d19db03eef7a04",
  "moveMode": 1,
  "sendWelcomeEmail": true,
  "locationId": "ve9EPM428h8vShlRW1KT"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v4',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "sourceCampaignId": "6385d230f6d19db03eef6fb2",
      "targetCampaignId": "6512c3a1f6d19db03eef7a04",
      "moveMode": 1,
      "sendWelcomeEmail": true,
      "locationId": "ve9EPM428h8vShlRW1KT"
  })
};

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

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

payload = {
    "sourceCampaignId": "6385d230f6d19db03eef6fb2",
    "targetCampaignId": "6512c3a1f6d19db03eef7a04",
    "moveMode": 1,
    "sendWelcomeEmail": true,
    "locationId": "ve9EPM428h8vShlRW1KT"
}

response = requests.post(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/affiliate-campaign/affiliate/<affiliateId>/move-campaign',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v4',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "sourceCampaignId": "6385d230f6d19db03eef6fb2",
  "targetCampaignId": "6512c3a1f6d19db03eef7a04",
  "moveMode": 1,
  "sendWelcomeEmail": true,
  "locationId": "ve9EPM428h8vShlRW1KT"
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/affiliate-manager/affiliate-campaign/affiliate/<affiliateId>/move-campaign")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v4")
  .header("Content-Type", "application/json")
  .body("{\"sourceCampaignId\":\"6385d230f6d19db03eef6fb2\",\"targetCampaignId\":\"6512c3a1f6d19db03eef7a04\",\"moveMode\":1,\"sendWelcomeEmail\":true,\"locationId\":\"ve9EPM428h8vShlRW1KT\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/affiliate-manager/affiliate-campaign/affiliate/<affiliateId>/move-campaign"
  payload := strings.NewReader(`{
  "sourceCampaignId": "6385d230f6d19db03eef6fb2",
  "targetCampaignId": "6512c3a1f6d19db03eef7a04",
  "moveMode": 1,
  "sendWelcomeEmail": true,
  "locationId": "ve9EPM428h8vShlRW1KT"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v4")

  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/affiliate-campaign/affiliate/<affiliateId>/move-campaign")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v4"
request["Content-Type"] = "application/json"
request.body = '{
  "sourceCampaignId": "6385d230f6d19db03eef6fb2",
  "targetCampaignId": "6512c3a1f6d19db03eef7a04",
  "moveMode": 1,
  "sendWelcomeEmail": true,
  "locationId": "ve9EPM428h8vShlRW1KT"
}'

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

**PowerShell**

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

$body = '{
  "sourceCampaignId": "6385d230f6d19db03eef6fb2",
  "targetCampaignId": "6512c3a1f6d19db03eef7a04",
  "moveMode": 1,
  "sendWelcomeEmail": true,
  "locationId": "ve9EPM428h8vShlRW1KT"
}'

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