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

# Create multiple cities in bulk

POST https://api.etera.dev/context/cities/bulk
Content-Type: application/json


          Create multiple cities at once. This endpoint attempts to create all provided
          cities and returns a summary of successful and failed creations. If some cities
          fail, the operation continues for the remaining cities.
          
          **Returns:**
          - List of successfully created cities
          - Count of successes and failures
          - Error details for any failed city creations
          
          **Use Case:** Useful for initial data seeding or migrating city data.
        

Reference: https://docs.etera.dev/platform/context/context-api/cities/post-cities-bulk

## Servers

- `https://api.etera.dev/context` (Production, default)
- `https://api-stage.etera.dev/context` (Staging)
- `https://api-dev.etera.dev/context` (Development)

## Request

### Body (application/json)

This endpoint expects an object.

- `cities` (list of CitiesBulkPostRequestBodyContentApplicationJsonSchemaCitiesItems, required) — Array of cities to create

## Response

### 200

- `cities_postCitiesBulk_Response_200`
  - CitiesPostCitiesBulkResponse2000
  - CitiesPostCitiesBulkResponse2001

## Types

### CitiesBulkPostRequestBodyContentApplicationJsonSchemaCitiesItems

- `id` (string, required) — Unique city identifier (lowercase with hyphens)
- `name` (string, required) — City name
- `scope` (list of CitiesBulkPostRequestBodyContentApplicationJsonSchemaCitiesItemsScopeItems, required) — Supported verticals for this city
- `cityCode` (string, required) — City code (uppercase with underscores)
- `iataCode` (string, required) — Airport IATA code (3 uppercase letters)
- `country` (string, required) — Country name
- `media` (string, optional, nullable)
- `isActive` (boolean, optional, default: true) — Whether the city is active

### CitiesPostCitiesBulkResponse2000

- `success` (boolean, required)
- `message` (string, required)
- `data` (CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0Data, optional)

### CitiesPostCitiesBulkResponse2001

- `error` (string, required)
- `message` (string, required)

### CitiesBulkPostRequestBodyContentApplicationJsonSchemaCitiesItemsScopeItems

- "RESTAURANT"
- "EXPERIENCE"
- "HOTEL"

### CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0Data

- `created` (double, required) — Number of cities successfully created
- `failed` (double, required) — Number of cities that failed to create
- `cities` (list of CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0DataCitiesItems, required)
- `errors` (list of CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0DataErrorsItems, optional)

### CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0DataCitiesItems

- `id` (string, required)
- `name` (string, required)
- `scope` (list of CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0DataCitiesItemsScopeItems, required)
- `cityCode` (string, required)
- `iataCode` (string, required)
- `country` (string, required)
- `media` (string, required, nullable)

### CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0DataErrorsItems

- `cityId` (string, required)
- `error` (string, required)

### CitiesBulkPostResponsesContentApplicationJsonSchemaOneOf0DataCitiesItemsScopeItems

- "RESTAURANT"
- "EXPERIENCE"
- "HOTEL"

## Examples

**Request**

```json
{
  "cities": [
    {
      "id": "singapore",
      "name": "Singapore",
      "scope": [
        "RESTAURANT"
      ],
      "cityCode": "SINGAPORE",
      "iataCode": "SIN",
      "country": "Singapore"
    }
  ]
}
```

**Response**

```json
{
  "success": true,
  "message": "string",
  "data": {
    "created": 1.1,
    "failed": 1.1,
    "cities": [
      {
        "id": "string",
        "name": "string",
        "scope": [
          "RESTAURANT"
        ],
        "cityCode": "string",
        "iataCode": "string",
        "country": "string",
        "media": "string"
      }
    ],
    "errors": [
      {
        "cityId": "string",
        "error": "string"
      }
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.etera.dev/context/cities/bulk"

payload = { "cities": [
        {
            "id": "singapore",
            "name": "Singapore",
            "scope": ["RESTAURANT"],
            "cityCode": "SINGAPORE",
            "iataCode": "SIN",
            "country": "Singapore"
        }
    ] }
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://api.etera.dev/context/cities/bulk';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"cities":[{"id":"singapore","name":"Singapore","scope":["RESTAURANT"],"cityCode":"SINGAPORE","iataCode":"SIN","country":"Singapore"}]}'
};

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.etera.dev/context/cities/bulk"

	payload := strings.NewReader("{\n  \"cities\": [\n    {\n      \"id\": \"singapore\",\n      \"name\": \"Singapore\",\n      \"scope\": [\n        \"RESTAURANT\"\n      ],\n      \"cityCode\": \"SINGAPORE\",\n      \"iataCode\": \"SIN\",\n      \"country\": \"Singapore\"\n    }\n  ]\n}")

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

	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.etera.dev/context/cities/bulk")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"cities\": [\n    {\n      \"id\": \"singapore\",\n      \"name\": \"Singapore\",\n      \"scope\": [\n        \"RESTAURANT\"\n      ],\n      \"cityCode\": \"SINGAPORE\",\n      \"iataCode\": \"SIN\",\n      \"country\": \"Singapore\"\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.post("https://api.etera.dev/context/cities/bulk")
  .header("Content-Type", "application/json")
  .body("{\n  \"cities\": [\n    {\n      \"id\": \"singapore\",\n      \"name\": \"Singapore\",\n      \"scope\": [\n        \"RESTAURANT\"\n      ],\n      \"cityCode\": \"SINGAPORE\",\n      \"iataCode\": \"SIN\",\n      \"country\": \"Singapore\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.etera.dev/context/cities/bulk', [
  'body' => '{
  "cities": [
    {
      "id": "singapore",
      "name": "Singapore",
      "scope": [
        "RESTAURANT"
      ],
      "cityCode": "SINGAPORE",
      "iataCode": "SIN",
      "country": "Singapore"
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.etera.dev/context/cities/bulk");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"cities\": [\n    {\n      \"id\": \"singapore\",\n      \"name\": \"Singapore\",\n      \"scope\": [\n        \"RESTAURANT\"\n      ],\n      \"cityCode\": \"SINGAPORE\",\n      \"iataCode\": \"SIN\",\n      \"country\": \"Singapore\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["cities": [
    [
      "id": "singapore",
      "name": "Singapore",
      "scope": ["RESTAURANT"],
      "cityCode": "SINGAPORE",
      "iataCode": "SIN",
      "country": "Singapore"
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.etera.dev/context/cities/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()
```