> 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 global configuration

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

Assigns the websites you list in `sites` to one Uptime Monitor global configuration. The change is immediate: the answer lists the websites that changed and the ones left out, so there is nothing to follow up.

What happens to each website:
- A website with no configuration starts being monitored with this one. A website that used another one moves to this one.
- Every assigned website is left with monitoring enabled, even if it was paused, and its first check runs right away. To change the configuration of one website and keep it paused, use "Update a website's uptime settings" instead.
- Websites you do not list are never unassigned: a website leaves a configuration by moving to another one.
- A website that already uses this configuration (`ALREADY_APPLIED`), or that your token cannot reach (`PERMISSION_DENIED`, with a null `site_name`), is reported in `meta.skipped` with a `reason_code` and a message instead of failing the call.

Each website in `meta.updated` carries `site_preset_uptime_id`, the id that "Retrieve a website's uptime settings" and "Update a website's uptime settings" take.

**Body**
- `sites` (array of integers, required): ids of the websites to act on, 1 to 50.

**Errors**
- **422**: an id that is not a website.

Reference: https://api.docs.modulards.com/modular-ds-public-api/uptime-monitor/uptime-global-configurations/assign-websites-to-an-uptime-global-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` (ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaJsonapi, optional)
- `meta` (ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaMeta, optional)

## Types

### ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaJsonapi

- `version` (string, optional)

### ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaMeta

- `skipped` (list of ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaMetaSkippedItems, optional)
- `status` (enum, optional) — Outcome of the call: applied when at least one website changed, skipped when none did.
  - Allowed values: `applied`, `skipped`
- `updated` (list of ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaMetaUpdatedItems, optional)

### ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaMetaSkippedItems

- `message` (string, optional) — Human-readable explanation.
- `reason_code` (enum, optional) — Why it was left out: ALREADY_APPLIED or PERMISSION_DENIED.
  - Allowed values: `ALREADY_APPLIED`, `PERMISSION_DENIED`
- `site_id` (integer, optional) — Id of a website left out.
- `site_name` (string, optional, nullable) — Name of that website; null when the id is outside your token's reach.
- `site_preset_uptime_id` (integer, optional, nullable) — The website's settings id when it has one; null otherwise.

### ApiPublicV1PresetUptimesPresetUptimeSitesSyncPostResponsesContentApplicationJsonSchemaMetaUpdatedItems

- `site_id` (integer, optional) — Id of a website that changed.
- `site_name` (string, optional) — Name of that website.
- `site_preset_uptime_id` (integer, optional) — Id of the website's uptime settings, the id "Retrieve a website's uptime settings" takes.

## Examples

### 200 - Websites assigned, one skipped

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