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

# Create Site

POST https://carbide-rest-api.carbide.svc.cluster.local/v2/org/{org}/carbide/site
Content-Type: application/json

Create a Site for the org.

Org must have an Infrastructure Provider entity. User must have `FORGE_PROVIDER_ADMIN` authorization role.

Tenants cannot create Sites.

Reference: https://docs.nvidia.com/infra-controller/infra-controller/rest-api-reference/api-reference/site/create-site

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: NCX Infra Controller REST API
  version: 1.0.0
paths:
  /v2/org/{org}/carbide/site:
    post:
      operationId: create-site
      summary: Create Site
      description: >-
        Create a Site for the org.


        Org must have an Infrastructure Provider entity. User must have
        `FORGE_PROVIDER_ADMIN` authorization role.


        Tenants cannot create Sites.
      tags:
        - subpackage_site
      parameters:
        - name: org
          in: path
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: >-
            ```

            export JWT_BEARER_TOKEN="<jwt-bearer-token>"


            # Example org name: "acme-inc

            export ORG_NAME=<org-name>


            # Use the JWT bearer token in your API request auth header:

            curl -v -X GET -H "Content-Type: application/json" -H
            "Authorization: Bearer $JWT_BEARER_TOKEN"
            https://carbide-rest-api.carbide.svc.cluster.local/v2/org/$ORG_NAME/carbide/user/current

            ```
          required: true
          schema:
            type: string
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Site'
        '400':
          description: Error response when request data cannot be validated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CarbideAPIError'
        '403':
          description: >-
            Error response when user is not authorized to call an endpoint or
            retrieve/modify objects
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CarbideAPIError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteCreateRequest'
servers:
  - url: https://carbide-rest-api.carbide.svc.cluster.local
components:
  schemas:
    SiteLocation:
      type: object
      properties:
        city:
          type: string
          description: City where the site is located
        state:
          type: string
          description: State where the site is located
        country:
          type: string
          description: Country where the site is located
      description: Location of the Site
      title: SiteLocation
    SiteContact:
      type: object
      properties:
        email:
          type: string
          description: Email address of the Site contact
      description: Contact for the Site
      title: SiteContact
    SiteCreateRequest:
      type: object
      properties:
        name:
          type: string
          description: Name for the Site
        description:
          type: string
          description: Description for the Site
        serialConsoleHostname:
          type: string
          format: hostname
          description: Hostname to reach Serial Console for the Site
        location:
          $ref: '#/components/schemas/SiteLocation'
        contact:
          $ref: '#/components/schemas/SiteContact'
      required:
        - name
      description: Request data to create a Site
      title: SiteCreateRequest
    SiteStatus:
      type: string
      enum:
        - Pending
        - Registered
        - Error
      description: Status values for Site objects
      title: SiteStatus
    StatusDetail:
      type: object
      properties:
        status:
          type: string
        message:
          type: string
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
      description: Describes the details of a status transition for a resource
      title: StatusDetail
    SiteCapabilities:
      type: object
      properties:
        nativeNetworking:
          type: boolean
        networkSecurityGroup:
          type: boolean
        nvLinkPartition:
          type: boolean
        rackLevelAdministration:
          type: boolean
        imageBasedOperatingSystem:
          type: boolean
      description: Boolean flags to indicate features supported by a Site
      title: SiteCapabilities
    SiteMachineStatsByStatus:
      type: object
      properties:
        Decommissioned:
          type: integer
        Error:
          type: integer
        Initializing:
          type: integer
        InUse:
          type: integer
        Maintenance:
          type: integer
        Ready:
          type: integer
        Reset:
          type: integer
        Unknown:
          type: integer
      description: Machine stats for a Site by status
      title: SiteMachineStatsByStatus
    SiteMachineStatsByHealth:
      type: object
      properties:
        healthy:
          type: integer
        unhealthy:
          type: integer
      description: Machine stats for a Site by health
      title: SiteMachineStatsByHealth
    SiteMachineStatsByStatusAndHealth:
      type: object
      properties:
        Decommissioned:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        Error:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        Initializing:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        InUse:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        Maintenance:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        Ready:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        Reset:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        Unknown:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
      description: Machine stats for a Site by status and health
      title: SiteMachineStatsByStatusAndHealth
    SiteMachineStatsByAllocation:
      type: object
      properties:
        allocatedInUse:
          type: integer
        allocatedNotInUse:
          type: integer
        unallocated:
          type: integer
      description: Machine stats for a Site by allocation
      title: SiteMachineStatsByAllocation
    SiteMachineStats:
      type: object
      properties:
        total:
          type: integer
        totalByStatus:
          $ref: '#/components/schemas/SiteMachineStatsByStatus'
        totalByHealth:
          $ref: '#/components/schemas/SiteMachineStatsByHealth'
        totalByStatusAndHealth:
          $ref: '#/components/schemas/SiteMachineStatsByStatusAndHealth'
        totalByAllocation:
          $ref: '#/components/schemas/SiteMachineStatsByAllocation'
      description: Machine stats for a Site
      title: SiteMachineStats
    Site:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          description: Name of the Site
        description:
          type: string
          description: Optional description for the Site
        org:
          type: string
        infrastructureProviderId:
          type: string
          format: uuid
        siteControllerVersion:
          type: string
          description: Version of the Site Controller software
        siteAgentVersion:
          type: string
          description: Version of the Site Agent software
        registrationToken:
          type: string
          description: >-
            Token that can be used to register a Site. Value only exposed to
            Provider
        registrationTokenExpiration:
          type: string
          format: date-time
          description: >-
            Date/time when registration token  expires. Value only exposed to
            Provider
        serialConsoleHostname:
          type: string
          format: hostname
        isSerialConsoleEnabled:
          type: boolean
          description: Indicates if Serial Console is enabled for the Site by the Provider
        serialConsoleIdleTimeout:
          type:
            - integer
            - 'null'
          description: Maximum idle time in seconds before Serial Console is disconnected
        serialConsoleMaxSessionLength:
          type:
            - integer
            - 'null'
          description: Maximum length of Serial Console session in seconds
        isSerialConsoleSSHKeysEnabled:
          type: boolean
          description: >-
            Only visible to Tenant retrieving the Site. Indicates if Serial
            Console access using SSH Keys is enabled by Tenant
        isOnline:
          type: boolean
          description: Indicates if the Site is currently reachable from Cloud
        status:
          $ref: '#/components/schemas/SiteStatus'
        statusHistory:
          type: array
          items:
            $ref: '#/components/schemas/StatusDetail'
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
        location:
          $ref: '#/components/schemas/SiteLocation'
        contact:
          $ref: '#/components/schemas/SiteContact'
        capabilities:
          $ref: '#/components/schemas/SiteCapabilities'
        machineStats:
          $ref: '#/components/schemas/SiteMachineStats'
      description: Site is a datacenter that is running NCX Infra Controller services
      title: Site
    CarbideApiErrorSource:
      type: string
      enum:
        - carbide
      description: Source of the error. Only 'carbide' is supported
      title: CarbideApiErrorSource
    CarbideApiErrorData:
      type: object
      properties: {}
      description: Additional data about the error
      title: CarbideApiErrorData
    CarbideAPIError:
      type: object
      properties:
        source:
          $ref: '#/components/schemas/CarbideApiErrorSource'
          description: Source of the error. Only 'carbide' is supported
        message:
          type: string
          description: Message describing the error
        data:
          oneOf:
            - $ref: '#/components/schemas/CarbideApiErrorData'
            - type: 'null'
          description: Additional data about the error
      description: Describes the error response from NCX Infra Controller REST API
      title: CarbideAPIError
  securitySchemes:
    JWTBearerToken:
      type: http
      scheme: bearer
      description: >-
        ```

        export JWT_BEARER_TOKEN="<jwt-bearer-token>"


        # Example org name: "acme-inc

        export ORG_NAME=<org-name>


        # Use the JWT bearer token in your API request auth header:

        curl -v -X GET -H "Content-Type: application/json" -H "Authorization:
        Bearer $JWT_BEARER_TOKEN"
        https://carbide-rest-api.carbide.svc.cluster.local/v2/org/$ORG_NAME/carbide/user/current

        ```

```

## SDK Code Examples

```python
import requests

url = "https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site"

payload = {
    "name": "San Jose Central 4",
    "description": "Datacenter serving San Jose central region",
    "location": {
        "city": "San Jose",
        "state": "CA",
        "country": "USA"
    },
    "contact": { "email": "johndoe@nvidia.com" }
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"San Jose Central 4","description":"Datacenter serving San Jose central region","location":{"city":"San Jose","state":"CA","country":"USA"},"contact":{"email":"johndoe@nvidia.com"}}'
};

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://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site"

	payload := strings.NewReader("{\n  \"name\": \"San Jose Central 4\",\n  \"description\": \"Datacenter serving San Jose central region\",\n  \"location\": {\n    \"city\": \"San Jose\",\n    \"state\": \"CA\",\n    \"country\": \"USA\"\n  },\n  \"contact\": {\n    \"email\": \"johndoe@nvidia.com\"\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://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site")

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  \"name\": \"San Jose Central 4\",\n  \"description\": \"Datacenter serving San Jose central region\",\n  \"location\": {\n    \"city\": \"San Jose\",\n    \"state\": \"CA\",\n    \"country\": \"USA\"\n  },\n  \"contact\": {\n    \"email\": \"johndoe@nvidia.com\"\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://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"San Jose Central 4\",\n  \"description\": \"Datacenter serving San Jose central region\",\n  \"location\": {\n    \"city\": \"San Jose\",\n    \"state\": \"CA\",\n    \"country\": \"USA\"\n  },\n  \"contact\": {\n    \"email\": \"johndoe@nvidia.com\"\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site', [
  'body' => '{
  "name": "San Jose Central 4",
  "description": "Datacenter serving San Jose central region",
  "location": {
    "city": "San Jose",
    "state": "CA",
    "country": "USA"
  },
  "contact": {
    "email": "johndoe@nvidia.com"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"San Jose Central 4\",\n  \"description\": \"Datacenter serving San Jose central region\",\n  \"location\": {\n    \"city\": \"San Jose\",\n    \"state\": \"CA\",\n    \"country\": \"USA\"\n  },\n  \"contact\": {\n    \"email\": \"johndoe@nvidia.com\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "San Jose Central 4",
  "description": "Datacenter serving San Jose central region",
  "location": [
    "city": "San Jose",
    "state": "CA",
    "country": "USA"
  ],
  "contact": ["email": "johndoe@nvidia.com"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/site")! 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()
```