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

# Save instances

POST http://localhost:3000/service_management/saveInstances
Content-Type: application/json

Creates a new service instance or update an existing service instance.

Reference: https://docs.itential.com/itential-platform/2023-2/api-reference/service-management/service-cog-save-instances

## Authentication

- `Authorization` header (basic auth, required) — Basic authentication of the form `Basic <base64(username:password)>`.

## Request

### Body (application/json)

This endpoint expects an object.

- `instance` (object, optional)
  - `servicePath` (list of object, optional) — The servicePath key is a service model's XPATH. The value is an array of objects. Each array element represents an instance of a service model.
- `options` (object or object, optional)
  - Service Instance Options
    - `skip-validation` (any, optional) — Required to enable commit flag support.
    - `dryrun` (object, optional) — Use dryrun commit flag. If not dryrun is not set when running testInstances, it will be added with outformat defaulting to native.
      - `outformat` (enum, optional)
        - Allowed values: `cli`, `native`, `xml`
      - `reverse` (any, optional) — Used with native outformat, this flag displays device commands for getting back to current running state in the network if the commit succeeds.
    - `commit-queue` (object, optional)
      - `tag` (string, optional) — User defined opaque tag which is present in all notifications and events sent referencing the specific queue item. This property must be placed first inside the commit-queue property if being used.
      - `sync` (object or object, optional) — Uses sync mode for commit queue. Cannot be used with async or bypass mode.
        - object
          - `timeout` (integer, optional) — Maximum number of seconds to wait for transaction to be committed.
        - object
          - `infinity` (any, optional) — Use this format for infinite wait time.
      - `async` (any, optional) — Uses async mode for commit queue. Cannot be used with sync or bypass mode.
      - `bypass` (any, optional) — Uses bypass mode for commit queue. Cannot be used with sync or async mode.
      - `block-others` (any, optional) — The commit-queue-block-others flag will block subsequent queue items, which use any of the devices in this queue item, from being queued.
      - `lock` (any, optional) — The commit-queue-lock flag will place a lock on the resulting queue item.
      - `atomic` (boolean, optional) — The commit-queue-atomic sets atomic behavior of resulting queue item.
      - `error-option` (enum, optional) — The commit-queue-error-option flag determines behavior on error.
        - Allowed values: `continue-on-error`, `rollback-on-error`, `stop-on-error`
    - `no-deploy` (any, optional) — The no-deploy flag makes a commit without invoking the service create method.
    - `no-revision-drop` (any, optional) — Uses no-revision-drop flag. Forces NSO to not silently drop data set operations.
    - `no-networking` (any, optional) — The no-networking flag does not send data to the devices.
    - `no-out-of-sync-check` (any, optional) — The no-out-of-sync-check flag continues with a transaction even when NSO detect an out of sync device. Can't be used with no-overwrite flag.
    - `no-overwrite` (any, optional) — The no-overwrite flag checks that the data that should be modified has not changed on the device compared to NSO's view of the data. Can't be used with no-out-of-sync-check.
    - `use-lsa` (any, optional) — The use-lsa flag forces handling of LSA nodes as such. Propogates the following flags, if used, to LSA nodes but not upper NSO node: dry-run, no-networking, no-out-of-sync-check, no-overwrite, no-revision-drop.
    - `no-lsa` (any, optional) — The no-lsa flag will not handle LSA nodes as such.
  - Save Instance Options (old)
    - `sync` (boolean, optional) — Set to false to use commit-queue async mode if global Commit Queue property is set to true (default).
    - `commit-sync` (boolean, optional) — Use commit-queue sync mode.
    - `no_overwrite` (boolean, optional) — Use no-overwrite commit flag.
    - `staging` (boolean, optional) — Use no-networking commit flag.
    - `force` (boolean, optional) — Use no-out-of-sync-check commit flag.

## Response

### 200

Result of saving the service instances.

- `list of object`
  - `action` (string, optional)
  - `target` (list of any, optional)
  - `xpath` (list of any, optional)
  - `success` (boolean, optional)
  - `error` (string, optional)

## Errors

### 500 Internal Server Error

Error response from API

- `any`

## Examples

**Request**

```json
{}
```

**Response**

```json
[
  {
    "action": "update",
    "target": [
      "string"
    ],
    "xpath": [
      "string"
    ],
    "success": true,
    "error": "model data not found"
  }
]
```

**SDK Code**

```python
import requests

url = "http://localhost:3000/service_management/saveInstances"

payload = {}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'http://localhost:3000/service_management/saveInstances';
const options = {method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{}'};

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 := "http://localhost:3000/service_management/saveInstances"

	payload := strings.NewReader("{}")

	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("http://localhost:3000/service_management/saveInstances")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

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("http://localhost:3000/service_management/saveInstances")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:3000/service_management/saveInstances', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("http://localhost:3000/service_management/saveInstances");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:3000/service_management/saveInstances")! 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()
```