> This page is for NVIDIA Infra Controller.

> 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.

# Decommission a Tray

POST https://nico-rest-api.nico.svc.cluster.local/v2/org/{org}/nico/tray/{id}/decommission
Content-Type: application/json

Start decommissioning a managed Tray in the specified Site's Core inventory.
The component type is derived from its Core ID: `fm100` identifies a
`Compute` Tray (managed host), `sw100` identifies an `NVSwitch`, and
`ps100` identifies a `PowerShelf`. An unsupported ID namespace returns
400; an absent component returns 404.

You must be a Provider Admin in the Org that owns the Site, and the Site
must be Registered. Core requires the component to be `Ready`.
For `Compute`, the host must not be assigned to an Instance, and every attached DPU must
support BFB installation through Redfish. For `NVSwitch` and `PowerShelf`,
no managed host in the component's rack may be assigned to an instance.
`NVSwitch` also requires Core's RMS component-manager backend.
Failed preconditions return 412.

Decommissioning a `Compute` Tray deconfigures the host and attached DPUs,
factory-resets their BMCs, and deletes managed credentials. For `NVSwitch`, it factory-resets NVOS and the BMC and deletes
the managed NVOS and BMC credentials. For `PowerShelf`, it factory-resets
the BMC and deletes its managed BMC credentials.

A 202 response confirms acceptance, not completion. For `Compute`, use
Machine status to observe workflow progress. For `NVSwitch` and
`PowerShelf`, inspect the Core controller state; the terminal success
state is `decommissioning` with substate `decommissioned`. This endpoint
returns no Flow Task or component progress.
Requests are not retried automatically. After a timeout, the result is
unknown; Core can still be processing the request. Repeating the request
after Core leaves `Ready` returns 412.

Reference: https://docs.nvidia.com/infra-controller/rest-api-reference/api-reference/tray/decommission-tray

## Authentication

- `Authorization` header (bearer token, required) — ``` 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://nico-rest-api.nico.svc.cluster.local/v2/org/$ORG_NAME/nico/user/current ```

## Request

### Path parameters

- `org` (string, required) — Name of the Org
- `id` (string, required) — Core inventory component ID of the Tray, not an expected-inventory or Flow component ID.

### Body (application/json)

This endpoint expects a TrayDecommissionRequest.

- `siteId` (string, required) — ID of the Site that owns the Tray. The Site must be in Registered status and owned by the requesting provider org.

## Response

### 202

Tray decommissioning request was accepted.

- `message` (string, required) — Human-readable outcome of the request

## Errors

### 400 Bad Request Error

Error response when request data cannot be validated

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

### 403 Forbidden Error

Error response when user is not authorized to call an endpoint or retrieve/modify objects

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

### 404 Not Found Error

Error response when requested object is not found

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

### 412 Precondition Failed Error

Core rejected the component's state, rack assignments, or backend configuration.

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

### 500 Internal Server Error

Response when the API handler encounters an unexpected error

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

### 501 Not Implemented Error

The Site's Core deployment does not implement this operation.

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

### 503 Service Unavailable Error

Core is unavailable.

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

### 504 Gateway Timeout Error

The Core proxy request timed out; the operation may still be running.

- `source` (string, optional) — Source of the error, taken from `api.name` in the REST API server configuration file (`/app/config.yaml` in the supplied Kubernetes deployment; default API name `nico`). This is a configurable string, for example `nico` or `carbide`
- `message` (string, optional) — Message describing the error
- `data` (NiCoApiErrorData, optional, nullable) — Additional data about the error
- `retryable` (boolean, optional) — True permits bounded retries with backoff, without guaranteeing success. False prohibits automatic retries. Omission means unclassified.

## Types

### NiCoApiErrorData

Additional data about the error

## Examples

**Request**

```json
{
  "siteId": "11111111-1111-4111-8111-111111111111"
}
```

**Response**

```json
{
  "message": "Tray decommissioning request was accepted"
}
```

**SDK Code**

```python Tray_decommission-tray_example
import requests

url = "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/tray/id/decommission"

payload = { "siteId": "11111111-1111-4111-8111-111111111111" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Tray_decommission-tray_example
const url = 'https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/tray/id/decommission';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"siteId":"11111111-1111-4111-8111-111111111111"}'
};

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

```go Tray_decommission-tray_example
package main

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

func main() {

	url := "https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/tray/id/decommission"

	payload := strings.NewReader("{\n  \"siteId\": \"11111111-1111-4111-8111-111111111111\"\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 Tray_decommission-tray_example
require 'uri'
require 'net/http'

url = URI("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/tray/id/decommission")

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  \"siteId\": \"11111111-1111-4111-8111-111111111111\"\n}"

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

```java Tray_decommission-tray_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/tray/id/decommission")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"siteId\": \"11111111-1111-4111-8111-111111111111\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/tray/id/decommission', [
  'body' => '{
  "siteId": "11111111-1111-4111-8111-111111111111"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Tray_decommission-tray_example
using RestSharp;

var client = new RestClient("https://nico-rest-api.nico.svc.cluster.local/v2/org/org/nico/tray/id/decommission");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"siteId\": \"11111111-1111-4111-8111-111111111111\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Tray_decommission-tray_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["siteId": "11111111-1111-4111-8111-111111111111"] as [String : Any]

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

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