Create a new Account
  • 01 Jun 2026
  • 3 Minutes to read
  • Dark
    Light
  • Download PDF

Create a new Account

  • Dark
    Light
  • Download PDF

Article summary

The below script will allow you to provide some details to connect to the Turbo360 API for partner accounts and create a child account via an API call.

It also has a boolean switch which allows you to trigger the cost imports for connecting to an Azure tenant if you want to automate that additional part too.  The steps taken in this scenario are:

  1. Authenticate with Entra for the App Reg configured for authentication with the Turbo360 API

  2. Call Turbo360 API to create a child account

    1. Note this will copy the account owner users and groups from the parent account to the child account

  3. Call Turbo360 API to start the cost imports

Powershell Example

The below

# ==============================================================
# Authentication Variables
# ==============================================================
$tenantId     = "[Your tenant id for API]"
$clientId     = "[Your client ID for API]"
$clientSecret = "[Your client secret for API]"
$apiHost         = "portal.turbo360.com" 

# ==============================================================
# Cost Analyzer Account Variables - Required for Step 2
# ==============================================================
$newAccountName              = "[Name for your new account]"

# ==============================================================
# Cost Analyzer Account Variables - Required for Step 3
# ==============================================================
$runStep3                    = $true # Set to $true to run Step 3 (Cost Analyzer setup), $false to skip
$costAnalyzerEntraId         = "[Tenant ID for your Azure tenant that you want to connect to cost analyzer]"
$costAnalyzerClientId        = "[Client ID for your Azure tenant that you want to connect to cost analyzer]"
$costAnalyzerClientSecret    = "[Client Secret for your Azure tenant that you want to connect to cost analyzer]"
$costAnalyzerSpFriendlyName  = "[Friendly name for the service principal]"

# ==============================================================
# Step 1 - Get Authentication Token
# ==============================================================
Write-Host "Step 1: Getting authentication token..." -ForegroundColor Cyan

$tokenResponse = Invoke-RestMethod `
    -Method Post `
    -Uri "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" `
    -ContentType "application/x-www-form-urlencoded" `
    -Body @{
        grant_type    = "client_credentials"
        client_id     = $clientId
        client_secret = $clientSecret
        scope         = "api://3ff33167-ae34-4bb3-b86d-109c22d28fc8/.default"
    }

$accessToken = $tokenResponse.access_token
Write-Host "Token acquired." -ForegroundColor Green

# ==============================================================
# Step 2 - Create a new Managed Account (Child Account)
# ==============================================================
Write-Host "`nStep 2: Creating managed account '$newAccountName'..." -ForegroundColor Cyan

$createAccountResponse = Invoke-RestMethod `
    -Method Post `
    -Uri "https://$apiHost/partner/api/account-management/create-managed-account" `
    -ContentType "application/json-patch+json" `
    -Headers @{ Authorization = "Bearer $accessToken" } `
    -Body (@{ accountName = $newAccountName } | ConvertTo-Json)

$newAccountId = $createAccountResponse.accountId
Write-Host "Account created. Account ID: $newAccountId" -ForegroundColor Green

# ==============================================================
# Step 3 - Setup the Cost Analyzer Module
# ==============================================================
if ($runStep3) {
    Write-Host "`nStep 3: Setting up Cost Analyzer for account '$newAccountId'..." -ForegroundColor Cyan

    $setupBody = @{
        accountId                    = $newAccountId
        entraId                      = $costAnalyzerEntraId
        clientId                     = $costAnalyzerClientId
        clientSecret                 = $costAnalyzerClientSecret
        servicePrincipalFriendlyName = $costAnalyzerSpFriendlyName
    } | ConvertTo-Json

    Invoke-RestMethod `
        -Method Post `
        -Uri "https://$apiHost/partner/api/account-management/setup-cost-analyzer" `
        -ContentType "application/json-patch+json" `
        -Headers @{ Authorization = "Bearer $accessToken" } `
        -Body $setupBody

    Write-Host "Cost Analyzer setup complete." -ForegroundColor Green
} else {
    Write-Host "`nStep 3 skipped." -ForegroundColor Yellow
}

Rest Client Example

If you want to understand the API calls better, the below script can be used in VS Code with the REST Client extension to test the API calls used to setup an account.

# ==============================================================
# Authentication Variables
# ==============================================================
@tenantId = [API Authentication - Tenant ID]
@clientId = [API Authentication - Client ID]
@clientSecret = [API Authentication - Client Secret]
@host = portal.turbo360.com

# ==============================================================
# Cost Analyzer Account Variables
# ==============================================================
@newAccountName = [Name for the new Account]
@costAnalyzerEntraId = [Tenant ID for cost analyser import]
@costAnalyzerClientId = [Client ID for cost analyser import]
@costAnalyzerClientSecret = [Client Secret for cost analyser import]
@costAnalyzerSpFriendlyName = [Friendly name for app reg for cost analyser import]



# ==============================================================
# Step 1 - Get Authentication Token
# ==============================================================

# @name getToken
POST https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id={{clientId}}
&client_secret={{clientSecret}}
&scope=api://3ff33167-ae34-4bb3-b86d-109c22d28fc8/.default


###

# ==============================================================
# Step 2 - Create a new Managed Account (Child Account)
# ==============================================================

# @name createAccount
POST https://{{host}}/partner/api/account-management/create-managed-account
Accept: */*
Content-Type: application/json-patch+json
Authorization: Bearer {{getToken.response.body.access_token}}

{
  "accountName": "{{newAccountName}}"
}


###

# ==============================================================
# Step 3 - Setup the Cost Analyzer Module
# ==============================================================

POST https://{{host}}/partner/api/account-management/setup-cost-analyzer
Accept: */*
Content-Type: application/json-patch+json
Authorization: Bearer {{getToken.response.body.access_token}}

{
  "accountId": "{{createAccount.response.body.accountId}}",
  "entraId": "{{costAnalyzerEntraId}}",
  "clientId": "{{costAnalyzerClientId}}",
  "clientSecret": "{{costAnalyzerClientSecret}}",
  "servicePrincipalFriendlyName": "{{costAnalyzerSpFriendlyName}}"
}

###


Was this article helpful?