> This page is for Developer.

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

# Update Region

PATCH https://api.makeswift.com/v1/regions/{id}
Content-Type: application/json

This feature is in beta and may change. Requests return `403` until the feature flag is enabled for your site or workspace.

Replaces a region's element tree in one locale. The element tree's root component `type` becomes the region's `type`. Updating the default locale also updates the localized regions that inherit from it. Pass `version` to update the region only if it has not changed since you read it.

Reference: https://docs.makeswift.com/developer/api-reference/rest/regions/update-region

## Authentication

- `x-api-key` header (required) — API key authentication. Accepts either: - App API key (e.g. sk_eczMHVBY9fV6GYFhvs53qcnxq7yptlXL3ABKOZtn6dQ) - Site API key (UUID format, e.g. 550e8400-e29b-41d4-a716-446655440000)

## Request

### Path parameters

- `id` (string, required) — The region ID. URL-encode it if it contains reserved characters such as `/`.

### Query parameters

- `siteId` (string, required) — The site ID the region belongs to.
- `locale` (string, optional) — The locale to update the region in. Accepts either a locale code (e.g. `en-US`) or a `site_locale` UUID. Defaults to the site's default locale.

### Body (application/json)

This endpoint expects an UpdateRegionV1BodyDto.

- `elements` (UpdateRegionV1BodyDtoElements, required) — The root of the region's element tree. Replaces the tree in full. Its component type becomes the region's `type`.
- `version` (integer, optional) — The region `version` the update is based on, as returned by an earlier request. If the region has changed since, the update fails with `409` and changes nothing. Omit it to update the region regardless.

## Response

### 200

- `object` (enum, required)
  - Allowed values: `region`
- `id` (string, required) — The region ID. Assigned by the host, not generated by Makeswift.
- `name` (string, required) — The region name.
- `type` (string, required) — The component type at the root of the region's element tree.
- `locale` (string, required) — The locale of this region.
- `updatedAt` (datetime, required) — The region last update date and time.
- `version` (integer, required) — The version of the region's element tree. It increases with every change to the tree. Pass it to Update Region to update the region only if it has not changed since.
- `elements` (any, required) — Always `null` here. Get Region returns the region's element tree with `include=elements`.

## Errors

### 400 Bad Request Error

- `object` (enum, required)
  - Allowed values: `error`
- `code` (enum, required)
  - Allowed values: `bad_request`
- `message` (string, required)

### 403 Forbidden Error

- `object` (enum, required)
  - Allowed values: `error`
- `code` (enum, required)
  - Allowed values: `forbidden`
- `message` (string, required)

### 404 Not Found Error

- `object` (enum, required)
  - Allowed values: `error`
- `code` (enum, required)
  - Allowed values: `not_found`
- `message` (string, required)

### 409 Conflict Error

- `object` (enum, required)
  - Allowed values: `error`
- `code` (enum, required)
  - Allowed values: `conflict`
- `message` (string, required)

## Types

### UpdateRegionV1BodyDtoElements

The root of the region's element tree. Replaces the tree in full. Its component type becomes the region's `type`.

- `type` (string, required) — The component type, e.g. './components/Box/index.js'.
- `key` (string, required) — A UUID, unique within this tree.
- `props` (map from string to any, required) — Control-defined values, keyed by prop name. Nested elements appear here too, as a \{ elements, columns } value that may sit under any prop name and at any depth - there is no reserved prop name for children.

## Examples

**Request**

```json
{
  "elements": {
    "type": "makeswift::components::slot::v1",
    "key": "0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21",
    "props": {
      "children": {
        "columns": [
          {
            "deviceId": "desktop",
            "value": {
              "count": 12,
              "spans": [
                [
                  12
                ]
              ]
            }
          }
        ],
        "elements": [
          {
            "key": "7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d",
            "props": {
              "alt": {
                "@@makeswift/type": "text-input::v1",
                "value": "Acme"
              }
            },
            "type": "Logo"
          }
        ]
      }
    }
  }
}
```

**Response**

```json
{
  "object": "region",
  "id": "site-header",
  "name": "Site Header",
  "type": "makeswift::components::slot::v1",
  "locale": "en-US",
  "updatedAt": {},
  "version": 3,
  "elements": null
}
```

**SDK Code**

```python
import requests

url = "https://api.makeswift.com/v1/regions/site-header"

querystring = {"locale":"en-US","siteId":"123e4567-e89b-12d3-a456-426614174000"}

payload = { "elements": {
        "type": "makeswift::components::slot::v1",
        "key": "0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21",
        "props": { "children": {
                "columns": [
                    {
                        "deviceId": "desktop",
                        "value": {
                            "count": 12,
                            "spans": [[12]]
                        }
                    }
                ],
                "elements": [
                    {
                        "key": "7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d",
                        "props": { "alt": {
                                "@@makeswift/type": "text-input::v1",
                                "value": "Acme"
                            } },
                        "type": "Logo"
                    }
                ]
            } }
    } }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.makeswift.com/v1/regions/site-header?locale=en-US&siteId=123e4567-e89b-12d3-a456-426614174000';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"elements":{"type":"makeswift::components::slot::v1","key":"0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21","props":{"children":{"columns":[{"deviceId":"desktop","value":{"count":12,"spans":[[12]]}}],"elements":[{"key":"7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d","props":{"alt":{"@@makeswift/type":"text-input::v1","value":"Acme"}},"type":"Logo"}]}}}}'
};

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

```go
package main

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

func main() {

	url := "https://api.makeswift.com/v1/regions/site-header?locale=en-US&siteId=123e4567-e89b-12d3-a456-426614174000"

	payload := strings.NewReader("{\n  \"elements\": {\n    \"type\": \"makeswift::components::slot::v1\",\n    \"key\": \"0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21\",\n    \"props\": {\n      \"children\": {\n        \"columns\": [\n          {\n            \"deviceId\": \"desktop\",\n            \"value\": {\n              \"count\": 12,\n              \"spans\": [\n                [\n                  12\n                ]\n              ]\n            }\n          }\n        ],\n        \"elements\": [\n          {\n            \"key\": \"7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d\",\n            \"props\": {\n              \"alt\": {\n                \"@@makeswift/type\": \"text-input::v1\",\n                \"value\": \"Acme\"\n              }\n            },\n            \"type\": \"Logo\"\n          }\n        ]\n      }\n    }\n  }\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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
require 'uri'
require 'net/http'

url = URI("https://api.makeswift.com/v1/regions/site-header?locale=en-US&siteId=123e4567-e89b-12d3-a456-426614174000")

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

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"elements\": {\n    \"type\": \"makeswift::components::slot::v1\",\n    \"key\": \"0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21\",\n    \"props\": {\n      \"children\": {\n        \"columns\": [\n          {\n            \"deviceId\": \"desktop\",\n            \"value\": {\n              \"count\": 12,\n              \"spans\": [\n                [\n                  12\n                ]\n              ]\n            }\n          }\n        ],\n        \"elements\": [\n          {\n            \"key\": \"7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d\",\n            \"props\": {\n              \"alt\": {\n                \"@@makeswift/type\": \"text-input::v1\",\n                \"value\": \"Acme\"\n              }\n            },\n            \"type\": \"Logo\"\n          }\n        ]\n      }\n    }\n  }\n}"

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

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.makeswift.com/v1/regions/site-header?locale=en-US&siteId=123e4567-e89b-12d3-a456-426614174000")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"elements\": {\n    \"type\": \"makeswift::components::slot::v1\",\n    \"key\": \"0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21\",\n    \"props\": {\n      \"children\": {\n        \"columns\": [\n          {\n            \"deviceId\": \"desktop\",\n            \"value\": {\n              \"count\": 12,\n              \"spans\": [\n                [\n                  12\n                ]\n              ]\n            }\n          }\n        ],\n        \"elements\": [\n          {\n            \"key\": \"7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d\",\n            \"props\": {\n              \"alt\": {\n                \"@@makeswift/type\": \"text-input::v1\",\n                \"value\": \"Acme\"\n              }\n            },\n            \"type\": \"Logo\"\n          }\n        ]\n      }\n    }\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.makeswift.com/v1/regions/site-header?locale=en-US&siteId=123e4567-e89b-12d3-a456-426614174000', [
  'body' => '{
  "elements": {
    "type": "makeswift::components::slot::v1",
    "key": "0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21",
    "props": {
      "children": {
        "columns": [
          {
            "deviceId": "desktop",
            "value": {
              "count": 12,
              "spans": [
                [
                  12
                ]
              ]
            }
          }
        ],
        "elements": [
          {
            "key": "7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d",
            "props": {
              "alt": {
                "@@makeswift/type": "text-input::v1",
                "value": "Acme"
              }
            },
            "type": "Logo"
          }
        ]
      }
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.makeswift.com/v1/regions/site-header?locale=en-US&siteId=123e4567-e89b-12d3-a456-426614174000");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"elements\": {\n    \"type\": \"makeswift::components::slot::v1\",\n    \"key\": \"0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21\",\n    \"props\": {\n      \"children\": {\n        \"columns\": [\n          {\n            \"deviceId\": \"desktop\",\n            \"value\": {\n              \"count\": 12,\n              \"spans\": [\n                [\n                  12\n                ]\n              ]\n            }\n          }\n        ],\n        \"elements\": [\n          {\n            \"key\": \"7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d\",\n            \"props\": {\n              \"alt\": {\n                \"@@makeswift/type\": \"text-input::v1\",\n                \"value\": \"Acme\"\n              }\n            },\n            \"type\": \"Logo\"\n          }\n        ]\n      }\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["elements": [
    "type": "makeswift::components::slot::v1",
    "key": "0b8f2f4e-3c1d-4e7a-9f2b-8a6c5d4e3f21",
    "props": ["children": [
        "columns": [
          [
            "deviceId": "desktop",
            "value": [
              "count": 12,
              "spans": [[12]]
            ]
          ]
        ],
        "elements": [
          [
            "key": "7d3e9a1b-5c2f-4b8e-a6d4-2f1e0c9b8a7d",
            "props": ["alt": [
                "@@makeswift/type": "text-input::v1",
                "value": "Acme"
              ]],
            "type": "Logo"
          ]
        ]
      ]]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.makeswift.com/v1/regions/site-header?locale=en-US&siteId=123e4567-e89b-12d3-a456-426614174000")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```