> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/dsx-air/llms.txt.

# Expose several node ports as services

POST https://api.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/
Content-Type: application/json

Creates every service in `services`, or none: one refused entry refuses the request, and the error names the entries by position. At most 100 services per request, all in one simulation.

The rules of `POST /api/v3/simulations/nodes/interfaces/services/` apply to each entry: an `outbound` interface with no link, and at most 252 services per interface. A simulation with Teleport on can hold at most 5000 services and VNC-enabled nodes combined.

**Required scope:** Simulation Edit (roles: Air Org Administrator, Air User)

Reference: https://docs.nvidia.com/dsx-air/api-reference/services/api-v-3-simulations-nodes-interfaces-services-bulk-create-create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/json)

This endpoint expects a ServiceBulkCreateRequest.

- `services` (list of ServiceRequest, required) — Services to create. Every interface must belong to the same simulation. At most 100 services may be created per request.

## Response

### 201

- `list of Service`

## Errors

### 400 Bad Request Error

- `detail` (string, required) — Description of an error.
- `request_id` (string, required, nullable) — ID assigned to the request which encountered the error. Should be provided when opening a support case.
- `type` (enum, required) — Specific type of a 400 error. * `PROTECTED` - Instance may not be deleted as it is being referenced by other instances. * `VALIDATION` - Validation errors encountered during payload processing.
  - Allowed values: `PROTECTED`, `VALIDATION`
- `protected_instances` (list of ProtectedErrorInstance, optional) — Instances which bar the current instance from being deleted. Only defined when `type` is set to `PROTECTED`.
- `validation_errors` (BadRequestValidationErrors, optional) — Validation errors encountered during payload processing. Only defined when `type` is set to `VALIDATION`.

### 403 Forbidden Error

- `detail` (string, required) — Description of an error.
- `request_id` (string, required, nullable) — ID assigned to the request which encountered the error. Should be provided when opening a support case.

### 500 Internal Server Error

- `request_id` (string, required, nullable) — ID assigned to the request which encountered the error. Should be provided when opening a support case.
- `code` (string, required) — Error code which identifies the error. Should be provided when opening a support case.
- `detail` (string, optional, default: An unexpected error has occurred. Please contact NVIDIA Air support for further assistance.) — Description of an error.

## Types

### ServiceRequest

Serializer for the ServiceViewSet.

- `node_port` (integer, required) — The port number associated with the service within the allowable range for an IP port (UINT16).
- `interface` (string, required) — The outbound interface the service forwards to.
- `name` (string, optional) — The name of the service.
- `service_type` (enum, optional, default: OTHER) — The type of service exposed (e.g. SSH or HTTP). * `SSH` - SSH * `HTTPS` - HTTPS * `HTTP` - HTTP * `OTHER` - Other
  - Allowed values: `SSH`, `HTTPS`, `HTTP`, `OTHER`
- `teleport_access_port` (integer, optional, nullable) — The port that reaches this service over Teleport. Can only be set when the simulation's organization is allowed to use Teleport. When omitted, Air assigns one if Teleport is enabled on the simulation, and otherwise when Teleport is turned on.

### Service

Serializer for the ServiceViewSet.

- `id` (string, required)
- `created` (datetime, required)
- `modified` (datetime, required)
- `node_port` (integer, required) — The port number associated with the service within the allowable range for an IP port (UINT16).
- `worker_port` (integer, required, nullable) — The port exposed by the worker.
- `worker_fqdn` (string, required, nullable) — The FQDN of the worker machine this service is running on. When the associated node is not active, this will be null.
- `interface` (string, required) — The outbound interface the service forwards to.
- `name` (string, optional) — The name of the service.
- `service_type` (enum, optional, default: OTHER) — The type of service exposed (e.g. SSH or HTTP). * `SSH` - SSH * `HTTPS` - HTTPS * `HTTP` - HTTP * `OTHER` - Other
  - Allowed values: `SSH`, `HTTPS`, `HTTP`, `OTHER`
- `teleport_access_port` (integer, optional, nullable) — The port that reaches this service over Teleport. Can only be set when the simulation's organization is allowed to use Teleport. When omitted, Air assigns one if Teleport is enabled on the simulation, and otherwise when Teleport is turned on.

### ProtectedErrorInstance

Identifier of a protected instance.

- `id` (string, required) — ID of the instance.
- `type` (string, required) — Type of the instance.

### BadRequestValidationErrors

Validation errors encountered during payload processing. Only defined when `type` is set to `VALIDATION`.

- map from string to BadRequestValidationErrorsOneOf0
- list of BadRequestValidationErrorsOneOf1Items

### BadRequestValidationErrorsOneOf0

- list of BadRequestValidationErrorsOneOf0OneOf0Items
- BadRequestValidationErrorsOneOf01
- map from string to any

### BadRequestValidationErrorsOneOf1Items

A single validation error.

- `message` (string, required) — Human-readable description of the error.
- `code` (string, required) — Machine-readable identifier for the error, for branching in client code. DRF supplies the default (e.g. `invalid`, `required`, `unique`); Air sets its own where a generic code would hide the cause, such as `protected` when a delete is refused because another instance still references this one.

### BadRequestValidationErrorsOneOf0OneOf0Items

A single validation error.

- `message` (string, required) — Human-readable description of the error.
- `code` (string, required) — Machine-readable identifier for the error, for branching in client code. DRF supplies the default (e.g. `invalid`, `required`, `unique`); Air sets its own where a generic code would hide the cause, such as `protected` when a delete is refused because another instance still references this one.

### BadRequestValidationErrorsOneOf01

A single validation error.

- `message` (string, required) — Human-readable description of the error.
- `code` (string, required) — Machine-readable identifier for the error, for branching in client code. DRF supplies the default (e.g. `invalid`, `required`, `unique`); Air sets its own where a generic code would hide the cause, such as `protected` when a delete is refused because another instance still references this one.

## Examples

**Request**

```json
{
  "services": [
    {
      "node_port": 1,
      "interface": "string"
    }
  ]
}
```

**Response**

```json
[
  {
    "id": "string",
    "created": "2024-01-15T09:30:00Z",
    "modified": "2024-01-15T09:30:00Z",
    "node_port": 1,
    "worker_port": 1,
    "worker_fqdn": "string",
    "interface": "string",
    "name": "string",
    "service_type": "SSH",
    "teleport_access_port": 1
  }
]
```

**SDK Code**

```python
import requests

url = "https://api.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/"

payload = { "services": [
        {
            "node_port": 1,
            "interface": "string"
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"services":[{"node_port":1,"interface":"string"}]}'
};

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.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/"

	payload := strings.NewReader("{\n  \"services\": [\n    {\n      \"node_port\": 1,\n      \"interface\": \"string\"\n    }\n  ]\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
require 'uri'
require 'net/http'

url = URI("https://api.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/")

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  \"services\": [\n    {\n      \"node_port\": 1,\n      \"interface\": \"string\"\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.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"services\": [\n    {\n      \"node_port\": 1,\n      \"interface\": \"string\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/', [
  'body' => '{
  "services": [
    {
      "node_port": 1,
      "interface": "string"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"services\": [\n    {\n      \"node_port\": 1,\n      \"interface\": \"string\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["services": [
    [
      "node_port": 1,
      "interface": "string"
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.dsx-air.nvidia.com/api/v3/simulations/nodes/interfaces/services/bulk-create/")! 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()
```