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

# Switch Patch & Protect

POST https://api.modulards.com/api/public/v1/patchstack-services/bulk
Content-Type: application/json

Switch Patch & Protect on or off over an explicit selection of websites: `sites` (exact ids, 1 to 200) and `status` (`enabled` or `disabled`).

**Every protected website is billed.** The add-on is metered per website and per month, with no websites included in the plan, so enabling it here adds to the organization's invoice. Without the add-on subscribed the call answers 403 and the user enables it from the Modular DS dashboard: an integration never buys it.

Switching on installs the security plugin on WordPress; switching off removes it and leaves the website unprotected. Both are pipelines, so the answer is **202** with one `site-actions` document per website, which you follow through `/site-actions`, and `meta.skipped` for the rest.

A website is skipped when it is not connected (`SITE_UNREACHABLE`), when it is being restored or already has a switch running (`CONFLICT`), or when it is already in the state you asked for (`ALREADY_APPLIED`). Ids outside your reach come back as `PERMISSION_DENIED` instead of being dropped in silence.

Reference: https://api.docs.modulards.com/modular-ds-public-api/patch-protect/switch-patch-protect

## Authentication

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

## Request

### Body (application/json)

This endpoint expects an object.

- `sites` (list of double, optional)
- `status` (string, optional)

## Response

### 202

202 - One website switched on, one skipped

- `data` (list of ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaDataItems, optional)
- `jsonapi` (ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaJsonapi, optional)
- `meta` (ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaMeta, optional)

## Types

### ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaDataItems

- `attributes` (ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaDataItemsAttributes, optional)
- `id` (string, optional)
- `links` (ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaDataItemsLinks, optional)
- `type` (string, optional)

### ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaJsonapi

- `version` (string, optional)

### ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaMeta

- `skipped` (list of ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaMetaSkippedItems, optional)

### ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaDataItemsAttributes

- `completed_at` (any, optional, nullable)
- `created_at` (string, optional)
- `created_by` (double, optional)
- `origin` (string, optional)
- `site_id` (double, optional)
- `started_at` (any, optional, nullable)
- `status` (string, optional)
- `type` (string, optional)
- `updated_at` (string, optional)

### ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaDataItemsLinks

- `self` (string, optional)

### ApiPublicV1PatchstackServicesBulkPostResponsesContentApplicationJsonSchemaMetaSkippedItems

- `message` (string, optional)
- `reason_code` (string, optional)
- `site_action_id` (any, optional, nullable)
- `site_id` (double, optional)
- `site_name` (string, optional)

## Examples

### 202 - One website switched on, one skipped

**Request**

```json
undefined
```

**Response**

```json
{
  "data": [
    {
      "attributes": {
        "completed_at": null,
        "created_at": "2026-09-24T15:00:58.000000Z",
        "created_by": 1,
        "origin": "agent",
        "site_id": 2,
        "started_at": null,
        "status": "pending",
        "type": "security.patchstack.create",
        "updated_at": "2026-09-24T15:00:58.000000Z"
      },
      "id": "1",
      "links": {
        "self": "https://api.modulards.local/api/public/v1/site-actions/1"
      },
      "type": "site-actions"
    }
  ],
  "jsonapi": {
    "version": "1.1"
  },
  "meta": {
    "skipped": [
      {
        "message": "This website is not connected; connect it first.",
        "reason_code": "SITE_UNREACHABLE",
        "site_action_id": null,
        "site_id": 3,
        "site_name": "old.example.com"
      }
    ]
  }
}
```

**SDK Code**

```python 202 - One website switched on, one skipped
import requests

url = "https://api.modulards.com/api/public/v1/patchstack-services/bulk"

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

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

print(response.json())
```

```javascript 202 - One website switched on, one skipped
const url = 'https://api.modulards.com/api/public/v1/patchstack-services/bulk';
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 202 - One website switched on, one skipped
package main

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

func main() {

	url := "https://api.modulards.com/api/public/v1/patchstack-services/bulk"

	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 202 - One website switched on, one skipped
require 'uri'
require 'net/http'

url = URI("https://api.modulards.com/api/public/v1/patchstack-services/bulk")

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 202 - One website switched on, 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/patchstack-services/bulk")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php 202 - One website switched on, one skipped
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

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

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

```csharp 202 - One website switched on, one skipped
using RestSharp;

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

```swift 202 - One website switched on, one skipped
import Foundation

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

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

### Switch Patch & Protect

**Request**

```json
{
  "sites": [
    2,
    3
  ],
  "status": "enabled"
}
```

**Response**

```json
{
  "data": [
    {
      "attributes": {
        "completed_at": null,
        "created_at": "2026-09-24T15:00:58.000000Z",
        "created_by": 1,
        "origin": "agent",
        "site_id": 2,
        "started_at": null,
        "status": "pending",
        "type": "security.patchstack.create",
        "updated_at": "2026-09-24T15:00:58.000000Z"
      },
      "id": "1",
      "links": {
        "self": "https://api.modulards.local/api/public/v1/site-actions/1"
      },
      "type": "site-actions"
    }
  ],
  "jsonapi": {
    "version": "1.1"
  },
  "meta": {
    "skipped": [
      {
        "message": "This website is not connected; connect it first.",
        "reason_code": "SITE_UNREACHABLE",
        "site_action_id": null,
        "site_id": 3,
        "site_name": "old.example.com"
      }
    ]
  }
}
```

**SDK Code**

```python Switch Patch & Protect
import requests

url = "https://api.modulards.com/api/public/v1/patchstack-services/bulk"

payload = {
    "sites": [2, 3],
    "status": "enabled"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Switch Patch & Protect
const url = 'https://api.modulards.com/api/public/v1/patchstack-services/bulk';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"sites":[2,3],"status":"enabled"}'
};

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

```go Switch Patch & Protect
package main

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

func main() {

	url := "https://api.modulards.com/api/public/v1/patchstack-services/bulk"

	payload := strings.NewReader("{\n  \"sites\": [\n    2,\n    3\n  ],\n  \"status\": \"enabled\"\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 Switch Patch & Protect
require 'uri'
require 'net/http'

url = URI("https://api.modulards.com/api/public/v1/patchstack-services/bulk")

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    2,\n    3\n  ],\n  \"status\": \"enabled\"\n}"

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

```java Switch Patch & Protect
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.modulards.com/api/public/v1/patchstack-services/bulk")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"sites\": [\n    2,\n    3\n  ],\n  \"status\": \"enabled\"\n}")
  .asString();
```

```php Switch Patch & Protect
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.modulards.com/api/public/v1/patchstack-services/bulk', [
  'body' => '{
  "sites": [
    2,
    3
  ],
  "status": "enabled"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Switch Patch & Protect
using RestSharp;

var client = new RestClient("https://api.modulards.com/api/public/v1/patchstack-services/bulk");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"sites\": [\n    2,\n    3\n  ],\n  \"status\": \"enabled\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Switch Patch & Protect
import Foundation

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

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

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