> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.heyreach.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.heyreach.io/_mcp/server.

# UpdateAccounts

POST https://api//api/public/campaign/UpdateAccounts
Content-Type: application/json

## Replaces the entire list of LinkedIn sender accounts assigned to a campaign.

This is a **full replacement**, not a merge. Any account not in the new list will be removed. On a PAUSED campaign, leads assigned to a removed account will be stopped and cannot be resumed.

Allowed statuses: DRAFT, SCHEDULED, PAUSED. Returns 400 for any other status (e.g. IN_PROGRESS, FINISHED). For SCHEDULED campaigns the campaign reverts to DRAFT.

### Body Parameters

- **campaignId** _(long, required)_: The campaign to update.
    
- **linkedInAccountIds** _(int[], required)_: Full replacement list of sender account IDs. 1-100 items. All accounts must exist and have valid auth.

Reference: https://docs.heyreach.io/hey-reach-api/campaigns/update-accounts

## Request

### Headers

- `X-API-KEY` (string, optional) — API key header using this scheme. Example: "X-API-KEY: \{API\_KEY}"

### Body (application/json)

This endpoint expects an object.

- `campaignId` (integer, required)
- `linkedInAccountIds` (list of integer, required)

## Examples

**Request**

```json
{
  "campaignId": 12345,
  "linkedInAccountIds": [
    11111,
    22222
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api//api/public/campaign/UpdateAccounts"

payload = {
    "campaignId": 12345,
    "linkedInAccountIds": [11111, 22222]
}
headers = {
    "X-API-KEY": "{{HR_API_KEY}}",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api//api/public/campaign/UpdateAccounts';
const options = {
  method: 'POST',
  headers: {'X-API-KEY': '{{HR_API_KEY}}', 'Content-Type': 'application/json'},
  body: '{"campaignId":12345,"linkedInAccountIds":[11111,22222]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api//api/public/campaign/UpdateAccounts"

	payload := strings.NewReader("{\n  \"campaignId\": 12345,\n  \"linkedInAccountIds\": [\n    11111,\n    22222\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-KEY", "{{HR_API_KEY}}")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api//api/public/campaign/UpdateAccounts")

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

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '{{HR_API_KEY}}'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"campaignId\": 12345,\n  \"linkedInAccountIds\": [\n    11111,\n    22222\n  ]\n}"

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api//api/public/campaign/UpdateAccounts")
  .header("X-API-KEY", "{{HR_API_KEY}}")
  .header("Content-Type", "application/json")
  .body("{\n  \"campaignId\": 12345,\n  \"linkedInAccountIds\": [\n    11111,\n    22222\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api//api/public/campaign/UpdateAccounts', [
  'body' => '{
  "campaignId": 12345,
  "linkedInAccountIds": [
    11111,
    22222
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '{{HR_API_KEY}}',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api//api/public/campaign/UpdateAccounts");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "{{HR_API_KEY}}");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"campaignId\": 12345,\n  \"linkedInAccountIds\": [\n    11111,\n    22222\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-API-KEY": "{{HR_API_KEY}}",
  "Content-Type": "application/json"
]
let parameters = [
  "campaignId": 12345,
  "linkedInAccountIds": [11111, 22222]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api//api/public/campaign/UpdateAccounts")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```