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

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

Create an Allocation for the org.

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

Tenant management of Allocation is not supported in MVP.

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

## OpenAPI Specification

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


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


        Tenant management of Allocation is not supported in MVP.
      tags:
        - subpackage_allocation
      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/Allocation'
        '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/AllocationCreateRequest'
servers:
  - url: https://carbide-rest-api.carbide.svc.cluster.local
components:
  schemas:
    AllocationConstraintCreateRequestResourceType:
      type: string
      enum:
        - InstanceType
        - IPBlock
      description: Type of the Resource that the Allocation Constraint applies to
      title: AllocationConstraintCreateRequestResourceType
    AllocationConstraintCreateRequestConstraintType:
      type: string
      enum:
        - Reserved
        - OnDemand
        - Preemptible
      description: >-
        Type of the Allocation Constraint. Please note that OnDemand and
        Preemptible are not supported by current implementation.
      title: AllocationConstraintCreateRequestConstraintType
    AllocationConstraintCreateRequest:
      type: object
      properties:
        resourceType:
          $ref: '#/components/schemas/AllocationConstraintCreateRequestResourceType'
          description: Type of the Resource that the Allocation Constraint applies to
        resourceTypeId:
          type: string
          format: uuid
          description: >-
            ID of the Resource Type that the Allocation Constraint applies to.
            For InstanceType, this is the ID of the Instance Type. For IPBlock,
            this is the ID of the IP Block.
        constraintType:
          $ref: '#/components/schemas/AllocationConstraintCreateRequestConstraintType'
          description: >-
            Type of the Allocation Constraint. Please note that OnDemand and
            Preemptible are not supported by current implementation.
        constraintValue:
          type: integer
          description: >-
            Value of the Allocation Constraint. For InstanceType, this value
            represents number of Machines allocated for Tenant. For IPBlock,
            this value represents the prefix Length of the IP Block.
      required:
        - resourceType
        - resourceTypeId
        - constraintType
        - constraintValue
      description: Request data to create an AllocationConstraint
      title: AllocationConstraintCreateRequest
    AllocationCreateRequest:
      type: object
      properties:
        name:
          type: string
          description: Concise and descriptive name for the Allocation
        description:
          type: string
          description: Detailed description for the Allocation
        tenantId:
          type: string
          format: uuid
          description: ID of the Tenant that should receive the Allocation
        siteId:
          type: string
          format: uuid
          description: ID of the Site where resources should be allocated
        allocationConstraints:
          type: array
          items:
            $ref: '#/components/schemas/AllocationConstraintCreateRequest'
      required:
        - name
        - tenantId
        - siteId
      description: Request data to create an Allocation
      title: AllocationCreateRequest
    AllocationStatus:
      type: string
      enum:
        - Pending
        - Registered
        - Deleting
        - Error
      description: Status values for Allocation objects
      title: AllocationStatus
    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
    AllocationConstraintResourceType:
      type: string
      enum:
        - InstanceType
        - IPBlock
      description: Type of the Resource that the Allocation Constraint applies to
      title: AllocationConstraintResourceType
    AllocationConstraintConstraintType:
      type: string
      enum:
        - Reserved
        - OnDemand
        - Preemptible
      description: >-
        Type of the Allocation Constraint. Please note that OnDemand and
        Preemptible are not supported by current implementation.
      title: AllocationConstraintConstraintType
    InstanceTypeStatus:
      type: string
      enum:
        - Pending
        - Registering
        - Ready
        - Deleting
        - Error
      description: Status values for Instance Type objects
      title: InstanceTypeStatus
    InstanceTypeSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        infrastructureProviderId:
          type: string
          format: uuid
        siteId:
          type: string
          format: uuid
        status:
          $ref: '#/components/schemas/InstanceTypeStatus'
      description: Describes a subset of core attributes of an Instance Type
      title: InstanceTypeSummary
    IpBlockSummaryRoutingType:
      type: string
      enum:
        - Public
        - DatacenterOnly
      title: IpBlockSummaryRoutingType
    IpBlockStatus:
      type: string
      enum:
        - Pending
        - Provisioning
        - Ready
        - Deleting
        - Error
      description: Status values for IP Block objects
      title: IpBlockStatus
    IpBlockSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        routingType:
          $ref: '#/components/schemas/IpBlockSummaryRoutingType'
        prefix:
          type: string
          description: Either IPv4 or IPv6 address
        prefixLength:
          type: integer
          description: 'Min: 1, Max: 32 for ipv4, 128 for ipv6'
        status:
          $ref: '#/components/schemas/IpBlockStatus'
      description: Describes a subset of core attributes of an IP block
      title: IpBlockSummary
    AllocationConstraint:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ID of the Allocation Constraint
        allocationId:
          type: string
          format: uuid
          description: ID of the Allocation that contains the Allocation Constraint
        resourceType:
          $ref: '#/components/schemas/AllocationConstraintResourceType'
          description: Type of the Resource that the Allocation Constraint applies to
        resourceTypeId:
          type: string
          format: uuid
          description: >-
            ID of the Resource Type that the Allocation Constraint applies to.
            For InstanceType, this is the ID of the Instance Type. For IPBlock,
            this is the ID of the IP Block.
        constraintType:
          $ref: '#/components/schemas/AllocationConstraintConstraintType'
          description: >-
            Type of the Allocation Constraint. Please note that OnDemand and
            Preemptible are not supported by current implementation.
        constraintValue:
          type: integer
          description: >-
            Value of the Allocation Constraint. For InstanceType, this value
            represents number of Machines allocated for Tenant. For IPBlock,
            this value represents the prefix Length of the IP Block.
        derivedResourceId:
          type:
            - string
            - 'null'
          description: ID of the allocated Tenant IP Block when resource type is IPBlock
        instanceType:
          $ref: '#/components/schemas/InstanceTypeSummary'
        ipBlock:
          $ref: '#/components/schemas/IpBlockSummary'
        created:
          type: string
          format: date-time
          description: Date/time when the Allocation Constraint was created
        updated:
          type: string
          format: date-time
          description: Date/time when the Allocation Constraint was last updated
      description: >-
        Constraints on an Allocation that specify limits for different resource
        types
      title: AllocationConstraint
    Allocation:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: ID of the Allocation
        name:
          type: string
          description: Concise and descriptive name of the Allocation
        description:
          type: string
          description: Detailed description of the Allocation
        infrastructureProviderId:
          type: string
          format: uuid
          description: ID of the Infrastructure Provider that created the Allocation
        tenantId:
          type: string
          format: uuid
          description: ID of the Tenant that received the Allocation
        siteId:
          type: string
          format: uuid
          description: ID of the Site where resources are allocated
        status:
          $ref: '#/components/schemas/AllocationStatus'
        statusHistory:
          type: array
          items:
            $ref: '#/components/schemas/StatusDetail'
        allocationConstraints:
          type: array
          items:
            $ref: '#/components/schemas/AllocationConstraint'
        created:
          type: string
          format: date-time
          description: Date/time when the Allocation was created
        updated:
          type: string
          format: date-time
          description: Date/time when the Allocation was last updated
      description: >-
        Specifies a group of resources on a Site that has been allocated to a
        Tenant
      title: Allocation
    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 example-1
import requests

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

payload = {
    "name": "Echo Studios",
    "tenantId": "f97df110-f4de-492e-8849-4a6af68026b0",
    "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
    "description": "Echo Studios resource allocation in SJC4",
    "allocationConstraints": [
        {
            "resourceType": "InstanceType",
            "resourceTypeId": "bd5a0240-eb62-4bff-91f7-335e6bb86459",
            "constraintType": "Reserved",
            "constraintValue": 10
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript example-1
const url = 'https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/allocation';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Echo Studios","tenantId":"f97df110-f4de-492e-8849-4a6af68026b0","siteId":"60189e9c-7d12-438c-b9ca-6998d9c364b1","description":"Echo Studios resource allocation in SJC4","allocationConstraints":[{"resourceType":"InstanceType","resourceTypeId":"bd5a0240-eb62-4bff-91f7-335e6bb86459","constraintType":"Reserved","constraintValue":10}]}'
};

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

```go example-1
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"name\": \"Echo Studios\",\n  \"tenantId\": \"f97df110-f4de-492e-8849-4a6af68026b0\",\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"description\": \"Echo Studios resource allocation in SJC4\",\n  \"allocationConstraints\": [\n    {\n      \"resourceType\": \"InstanceType\",\n      \"resourceTypeId\": \"bd5a0240-eb62-4bff-91f7-335e6bb86459\",\n      \"constraintType\": \"Reserved\",\n      \"constraintValue\": 10\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 example-1
require 'uri'
require 'net/http'

url = URI("https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/allocation")

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\": \"Echo Studios\",\n  \"tenantId\": \"f97df110-f4de-492e-8849-4a6af68026b0\",\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"description\": \"Echo Studios resource allocation in SJC4\",\n  \"allocationConstraints\": [\n    {\n      \"resourceType\": \"InstanceType\",\n      \"resourceTypeId\": \"bd5a0240-eb62-4bff-91f7-335e6bb86459\",\n      \"constraintType\": \"Reserved\",\n      \"constraintValue\": 10\n    }\n  ]\n}"

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

```java example-1
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/allocation")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Echo Studios\",\n  \"tenantId\": \"f97df110-f4de-492e-8849-4a6af68026b0\",\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"description\": \"Echo Studios resource allocation in SJC4\",\n  \"allocationConstraints\": [\n    {\n      \"resourceType\": \"InstanceType\",\n      \"resourceTypeId\": \"bd5a0240-eb62-4bff-91f7-335e6bb86459\",\n      \"constraintType\": \"Reserved\",\n      \"constraintValue\": 10\n    }\n  ]\n}")
  .asString();
```

```php example-1
<?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/allocation', [
  'body' => '{
  "name": "Echo Studios",
  "tenantId": "f97df110-f4de-492e-8849-4a6af68026b0",
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "description": "Echo Studios resource allocation in SJC4",
  "allocationConstraints": [
    {
      "resourceType": "InstanceType",
      "resourceTypeId": "bd5a0240-eb62-4bff-91f7-335e6bb86459",
      "constraintType": "Reserved",
      "constraintValue": 10
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp example-1
using RestSharp;

var client = new RestClient("https://carbide-rest-api.carbide.svc.cluster.local/v2/org/org/carbide/allocation");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Echo Studios\",\n  \"tenantId\": \"f97df110-f4de-492e-8849-4a6af68026b0\",\n  \"siteId\": \"60189e9c-7d12-438c-b9ca-6998d9c364b1\",\n  \"description\": \"Echo Studios resource allocation in SJC4\",\n  \"allocationConstraints\": [\n    {\n      \"resourceType\": \"InstanceType\",\n      \"resourceTypeId\": \"bd5a0240-eb62-4bff-91f7-335e6bb86459\",\n      \"constraintType\": \"Reserved\",\n      \"constraintValue\": 10\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift example-1
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Echo Studios",
  "tenantId": "f97df110-f4de-492e-8849-4a6af68026b0",
  "siteId": "60189e9c-7d12-438c-b9ca-6998d9c364b1",
  "description": "Echo Studios resource allocation in SJC4",
  "allocationConstraints": [
    [
      "resourceType": "InstanceType",
      "resourceTypeId": "bd5a0240-eb62-4bff-91f7-335e6bb86459",
      "constraintType": "Reserved",
      "constraintValue": 10
    ]
  ]
] 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/allocation")! 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()
```