> 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 an uptime configuration

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

Assigns an explicit selection of websites to one Uptime Monitor 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 starts being monitored on this one. A website that used another one is moved to this one.
- Either way the website ends switched on - a paused website is monitored again - and its first check runs right away: tell the user before assigning paused websites.
- Websites left out of the selection keep their configuration: a website leaves a configuration by being moved to another one.
- A website that already uses this configuration, or that the token cannot reach, is answered in `meta.skipped` with a `reason_code` (`ALREADY_APPLIED`, `PERMISSION_DENIED`) and a message instead of failing the call.

`meta.updated` entries carry `site_id`, `site_name` and `site_preset_uptime_id`, the id "Show uptime service" and "Update uptime 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/uptime-configurations/assign-websites-to-an-uptime-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_uptime` (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_uptime_id` (double, optional)
  - `status` (string, optional)
  - `updated` (list of object, optional)
    - `site_id` (double, optional)
    - `site_name` (string, optional)
    - `site_preset_uptime_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 Uptime Monitor global configuration.",
        "reason_code": "ALREADY_APPLIED",
        "site_id": 102,
        "site_name": "Attached",
        "site_preset_uptime_id": 731
      }
    ],
    "status": "applied",
    "updated": [
      {
        "site_id": 101,
        "site_name": "Fresh",
        "site_preset_uptime_id": 553
      }
    ]
  }
}
```

**SDK Code**

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

url = "https://api.modulards.com/api/public/v1/preset-uptimes/preset_uptime/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-uptimes/preset_uptime/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-uptimes/preset_uptime/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-uptimes/preset_uptime/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-uptimes/preset_uptime/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-uptimes/preset_uptime/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-uptimes/preset_uptime/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-uptimes/preset_uptime/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 an uptime configuration

**Request**

```json
{
  "sites": [
    101,
    102
  ]
}
```

**Response**

```json
{
  "jsonapi": {
    "version": "1.1"
  },
  "meta": {
    "skipped": [
      {
        "message": "This website already uses this Uptime Monitor global configuration.",
        "reason_code": "ALREADY_APPLIED",
        "site_id": 102,
        "site_name": "Attached",
        "site_preset_uptime_id": 731
      }
    ],
    "status": "applied",
    "updated": [
      {
        "site_id": 101,
        "site_name": "Fresh",
        "site_preset_uptime_id": 553
      }
    ]
  }
}
```

**SDK Code**

```python Assign websites to an uptime configuration
import requests

url = "https://api.modulards.com/api/public/v1/preset-uptimes/preset_uptime/sites/sync"

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

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

print(response.json())
```

```javascript Assign websites to an uptime configuration
const url = 'https://api.modulards.com/api/public/v1/preset-uptimes/preset_uptime/sites/sync';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"sites":[101,102]}'
};

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

```go Assign websites to an uptime configuration
package main

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

func main() {

	url := "https://api.modulards.com/api/public/v1/preset-uptimes/preset_uptime/sites/sync"

	payload := strings.NewReader("{\n  \"sites\": [\n    101,\n    102\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 an uptime configuration
require 'uri'
require 'net/http'

url = URI("https://api.modulards.com/api/public/v1/preset-uptimes/preset_uptime/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    101,\n    102\n  ]\n}"

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

```java Assign websites to an uptime 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-uptimes/preset_uptime/sites/sync")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"sites\": [\n    101,\n    102\n  ]\n}")
  .asString();
```

```php Assign websites to an uptime configuration
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp Assign websites to an uptime configuration
using RestSharp;

var client = new RestClient("https://api.modulards.com/api/public/v1/preset-uptimes/preset_uptime/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    101,\n    102\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Assign websites to an uptime configuration
import Foundation

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

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.modulards.com/api/public/v1/preset-uptimes/preset_uptime/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()
```