Documentation Index

Fetch the complete documentation index at: https://docs.turbo360.com/llms.txt

Use this file to discover all available pages before exploring further.

Create a new account and run initial import

Prev Next

Overview

This article shows how to use the Turbo360 Partner API to create a new managed child account and optionally configure Cost Analyzer for that account in a single automated sequence. Two code samples are provided: a PowerShell script for pipeline or scheduled execution, and a REST Client file for interactive testing in VS Code.

Business value

Automating child account creation removes the need for manual portal access during customer onboarding. Combining account creation with Cost Analyzer setup in one script means a new account is fully provisioned and ready for cost data import without any follow-up steps.

Prerequisites

Before running either sample, ensure you have:

  • A Turbo360 Parent Account with Partner API access enabled.

  • A Microsoft Entra App Registration configured with the Turbo360 Partner API permission scope (api://3ff33167-ae34-4bb3-b86d-109c22d28fc8/.default).

  • The tenant ID, client ID, and client secret for your App Registration.

  • If configuring Cost Analyzer: the Entra tenant ID, client ID, client secret, and a friendly name for the service principal of the Azure tenant you want to connect.

How it works

The provisioning sequence has three steps:

  1. Authenticate — Acquire a Bearer token from the Microsoft identity platform using the client credentials flow against your App Registration.

  2. Create the account — POST to the create-managed-account endpoint with the new account name. Turbo360 returns the new accountId and copies account owner users and groups from the parent account to the child account.

  3. Set up Cost Analyzer (optional) — POST to the setup-cost-analyzer endpoint with the new accountId and the Azure service principal details. This triggers the initial cost import for the connected tenant.

Steps

Use one of the following code samples to execute the provisioning sequence. Both samples perform the same three steps; choose the format that fits your workflow.

PowerShell example

Use this script for automated provisioning in a pipeline or scheduled task. Set $runStep3 to $false to create the account without configuring Cost Analyzer. This code is written in plain text:

# ==============================================================
# 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
$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

Use this file in VS Code with the REST Client extension to run and inspect each API call individually. This format is useful for understanding the request and response structure before automating. This code is written in plain text:

# ==============================================================
# 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}}"
}

###