Create a Tenant With a JSON File

To create a tenant with a JSON file, you first display all available tenants then request a new tenant with input parameters. The input parameters are specified in a separate JSON file that you call from the request.

Prerequisites

In addition to the Prerequisites for Creating a Tenant, verify that you have parameter values for the new tenant required for the JSON file input.

Procedure

  1. Use the identity service to display all the available tenants.
    curl --insecure -H "Accept:application/json" -H "Authorization: Bearer $token" https://$vRA/identity/api/tenants
    

    For details regarding input and output of this sample, see Syntax for Displaying Your Current Tenants.

  2. Examine the response to verify that the tenant you plan to create is not listed.
    See the output of the request to display all tenants Create a Tenant With a JSON File.
  3. Create a JSON file for the new tenant request to call.
    The newTenant.json file contains information about the new tenant.
    {
       "@type":"Tenant",
       "id":"rainpole",
       "urlName":"rainpole",
       "name":"rainpoleTenant",
       "description":"New Custom Tenant",
       "contactEmail":"[email protected]",
       "defaultTenant":false
    }
  4. Submit a request for a new tenant that calls the JSON file.
    curl -X PUT --insecure -H "Accept:application/json" -H "Content-Type:application/json" -H "Authorization: Bearer $token" https://$vRA/identity/api/tenants/rainpole --data @C:/Temp/newTenant.json
    

    For details regarding input and output of this sample, see Syntax for Requesting a New Tenant

  5. Use the identity service to display all the available tenants again.
    curl --insecure -H "Accept:application/json" -H "Authorization: Bearer $token" https://$vRA/identity/api/tenants
    
  6. Examine the response to verify that the tenant you requested is listed.
    See the output of the request to verify the new tenant is created Create a Tenant With a JSON File.

Example: Create a Tenant With a JSON File

The following sample output for Step 1 lists three tenants.
curl --insecure -H "Accept:application/json" -H "Authorization: Bearer $token" https://$vRA/identity/api/tenants
{
   "links":[],
   "content"[
      {"@type":"Tenant",
       "id":"vsphere.local",
       "urlName":"vsphere.local",
       "name":"vsphere.local",
       "description":null,
       "contactEmail":null,
       "password":"",
       "defaultTenant":true},
      {"@type":"Tenant",
       "id":"qe",
       ...},
      {"@type":"Tenant",
       "id":"management",
       ...}
   ],
   "metadata":{"size":20,"totalElements":3,"totalPages":1,"number":1,"offset":0}
}
The following sample output for Step 4, shows that the tenant named rainpole has been created.
curl -X PUT --insecure -H "Accept:application/json" -H "Content-Type:application/json" -H "Authorization: Bearer $token" https://$vRA/identity/api/tenants/rainpole --data @C:/Temp/newTenant.json
{
   "id": "rainpole",
   "urlName":"rainpole",
   "name":"rainpoleTenant",
   "description":"New Custom Tenant",
   "contactEmail":"[email protected]",
   "password":"",
   "defaultTenant":false
}
The following sample output for Step 5 lists four tenants including rainpole.
curl --insecure -H "Accept:application/json" -H "Authorization: Bearer $token" https://$vRA/identity/api/tenants                                              
{
   "links":[],
   "content":[
      {"@type":"Tenant",
       "id":"vsphere.local",
       ...},
      {"@type":"Tenant",
       "id":"qe",
       ...},
      {"@type":"Tenant",
       "id":"management",
       ...},
      {"@type":"Tenant",
       "id":"rainpole",
       ...}
   ],
   "metadata":{"size":20,"totalElements":4,"totalPages":1,"number":1,"offset":0}
}