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

# Assign websites to a Broken Links configuration

POST https://api.modulards.com/api/public/v1/preset-broken-links/{preset_broken_link}/sites/sync
Content-Type: application/json

Assigns an explicit selection of websites to one Broken Links Checker global configuration. Answers **200** with `meta.status` (`applied` when at least one website changed, `skipped` when none did), `meta.updated` and `meta.skipped`; the change is immediate, there is nothing to poll.

**Body** (JSON):
- `sites` (array of website ids, required, 1 to 200).

What happens to each website:
- A website with no configuration gets this one. A website that used another one moves to this one and takes its schedule.
- Every assigned website is left with automatic scans enabled and its next scan scheduled, even if it was paused. To change the configuration of one website and keep it paused, use "Update Broken Links service" instead.
- Websites left out of the selection are never unassigned: a website leaves a configuration by moving to another one.
- A website that already uses this configuration is answered in `meta.skipped` with `reason_code` `ALREADY_APPLIED`. A website the token cannot reach is answered in `meta.skipped` with `reason_code` `PERMISSION_DENIED` and a null `site_name`.

`meta.updated` entries carry `site_id`, `site_name` and `site_preset_broken_link_id`, the id "Show Broken Links service" and "Update Broken Links service" take.

Requires a full-access token (read-only tokens answer 403). An id that is not a website answers 422.

Reference: https://api.docs.modulards.com/modular-ds-public-api/broken-links-configurations/assign-websites-to-a-broken-links-configuration

## Authentication

- `Authorization` header (bearer token, required) — Personal access token created in the Modular DS dashboard; read-only tokens can only call GET endpoints.

## Request

### Path parameters

- `preset_broken_link` (string, required)

### Body (application/json)

This endpoint expects an object.

- `sites` (list of double, optional)

## Response

### 200

200 - Websites assigned, one skipped

- `jsonapi` (object, optional)
  - `version` (string, optional)
- `meta` (object, optional)
  - `skipped` (list of object, optional)
    - `message` (string, optional)
    - `reason_code` (string, optional)
    - `site_id` (double, optional)
    - `site_name` (string, optional)
    - `site_preset_broken_link_id` (double, optional)
  - `status` (string, optional)
  - `updated` (list of object, optional)
    - `site_id` (double, optional)
    - `site_name` (string, optional)
    - `site_preset_broken_link_id` (double, optional)

## Examples

### 200 - Websites assigned, one skipped

**Request**

```json
undefined
```

**Response**

```json
{
  "jsonapi": {
    "version": "1.1"
  },
  "meta": {
    "skipped": [
      {
        "message": "This website already uses this Broken Links Checker global configuration.",
        "reason_code": "ALREADY_APPLIED",
        "site_id": 12,
        "site_name": "Already there",
        "site_preset_broken_link_id": 880
      }
    ],
    "status": "applied",
    "updated": [
      {
        "site_id": 34,
        "site_name": "New shop",
        "site_preset_broken_link_id": 901
      }
    ]
  }
}
```

**SDK Code**

```python 200 - Websites assigned, one skipped
import requests

url = "https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript 200 - Websites assigned, one skipped
const url = 'https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

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

```go 200 - Websites assigned, one skipped
package main

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

func main() {

	url := "https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync"

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

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

```ruby 200 - Websites assigned, one skipped
require 'uri'
require 'net/http'

url = URI("https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

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

```java 200 - Websites assigned, one skipped
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php 200 - Websites assigned, one skipped
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp 200 - Websites assigned, one skipped
using RestSharp;

var client = new RestClient("https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift 200 - Websites assigned, one skipped
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### Assign websites to a Broken Links configuration

**Request**

```json
{
  "sites": [
    12,
    34
  ]
}
```

**Response**

```json
{
  "jsonapi": {
    "version": "1.1"
  },
  "meta": {
    "skipped": [
      {
        "message": "This website already uses this Broken Links Checker global configuration.",
        "reason_code": "ALREADY_APPLIED",
        "site_id": 12,
        "site_name": "Already there",
        "site_preset_broken_link_id": 880
      }
    ],
    "status": "applied",
    "updated": [
      {
        "site_id": 34,
        "site_name": "New shop",
        "site_preset_broken_link_id": 901
      }
    ]
  }
}
```

**SDK Code**

```python Assign websites to a Broken Links configuration
import requests

url = "https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync"

payload = { "sites": [12, 34] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Assign websites to a Broken Links configuration
const url = 'https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"sites":[12,34]}'
};

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

```go Assign websites to a Broken Links configuration
package main

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

func main() {

	url := "https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync"

	payload := strings.NewReader("{\n  \"sites\": [\n    12,\n    34\n  ]\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Assign websites to a Broken Links configuration
require 'uri'
require 'net/http'

url = URI("https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"sites\": [\n    12,\n    34\n  ]\n}"

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

```java Assign websites to a Broken Links configuration
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"sites\": [\n    12,\n    34\n  ]\n}")
  .asString();
```

```php Assign websites to a Broken Links configuration
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync', [
  'body' => '{
  "sites": [
    12,
    34
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Assign websites to a Broken Links configuration
using RestSharp;

var client = new RestClient("https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"sites\": [\n    12,\n    34\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Assign websites to a Broken Links configuration
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["sites": [12, 34]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.modulards.com/api/public/v1/preset-broken-links/preset_broken_link/sites/sync")! 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()
```