> 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.

# Sync websites

POST https://api.modulards.com/api/public/v1/alerts/{alert_id}/sites/sync

Associates an explicit selection of websites with the configuration; unlike the dashboard's website replacement, this adds to the existing selection and never removes one. Answers **200** at once with `meta.status` (`applied` when at least one website changed, `skipped` when none did), `meta.updated` and `meta.skipped` - there is nothing to poll.\n\n**Body** (JSON):\n- `sites` (array of website ids, required, 1 to 50), validated for existence only.\n\n`meta.updated` entries carry `site_id`, `site_name` and `alert_id`. A website already associated, or outside the token's reach, is answered in `meta.skipped` with a `reason_code` (`ALREADY_APPLIED`, `PERMISSION_DENIED`) and a message instead of failing the call.\n\nRequires a full-access token (read-only tokens answer 403). Body validation runs before authorization: a foreign configuration with an invalid body (e.g. missing `sites`) answers 422; only a foreign configuration with a valid body answers 404.

Reference: https://api.docs.modulards.com/modular-ds-public-api/notification-configurations/sync-websites

## 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

- `alert_id` (string, required)

## Response

### 200

200 - Websites added, one skipped

- `jsonapi` (ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaJsonapi, optional)
- `meta` (ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaMeta, optional)

## Errors

### 422 Unprocessable Entity Error

422 - Sites over the 50 limit

- `errors` (list of ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaErrorsItems, optional)
- `jsonapi` (ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaJsonapi, optional)

## Types

### ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaJsonapi

- `version` (string, optional)

### ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaMeta

- `skipped` (list of ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaMetaSkippedItems, optional)
- `status` (string, optional)
- `updated` (list of ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaMetaUpdatedItems, optional)

### ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaErrorsItems

- `detail` (string, optional)
- `source` (ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaErrorsItemsSource, optional)
- `status` (string, optional)
- `title` (string, optional)

### ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaMetaSkippedItems

- `alert_id` (double, optional)
- `message` (string, optional)
- `reason_code` (string, optional)
- `site_id` (double, optional)
- `site_name` (string, optional)

### ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaMetaUpdatedItems

- `alert_id` (double, optional)
- `site_id` (double, optional)
- `site_name` (string, optional)

### ApiPublicV1AlertsAlertIdSitesSyncPostResponsesContentApplicationJsonSchemaErrorsItemsSource

- `parameter` (string, optional)

## Examples

**Response**

```json
{
  "jsonapi": {
    "version": "1.1"
  },
  "meta": {
    "skipped": [
      {
        "alert_id": 12,
        "message": "This website already uses this notification configuration.",
        "reason_code": "ALREADY_APPLIED",
        "site_id": 12,
        "site_name": "Already there"
      }
    ],
    "status": "applied",
    "updated": [
      {
        "alert_id": 12,
        "site_id": 34,
        "site_name": "New shop"
      }
    ]
  }
}
```

**SDK Code**

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

url = "https://api.modulards.com/api/public/v1/alerts/alert_id/sites/sync"

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

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

print(response.json())
```

```javascript 200 - Websites added, one skipped
const url = 'https://api.modulards.com/api/public/v1/alerts/alert_id/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 added, one skipped
package main

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

func main() {

	url := "https://api.modulards.com/api/public/v1/alerts/alert_id/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 added, one skipped
require 'uri'
require 'net/http'

url = URI("https://api.modulards.com/api/public/v1/alerts/alert_id/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 added, 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/alerts/alert_id/sites/sync")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

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

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

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

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

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