Azure Lab Services is retiring on June 28, 2027.

Move your labs (opens in a new tab)
Skip to main content

The CloudLabs API accepts Microsoft Entra ID access tokens issued to your API client with the client credentials flow. Your system signs in as itself; no person is involved.

​Request a token

Use the token URL and scope shown when you created the client. The scope is always the application ID URI followed by /.default.

curl -s -X POST "https://login.microsoftonline.com/$TENANT_ID/oauth2/v2.0/token" \
  -d grant_type=client_credentials \
  -d client_id="$CLIENT_ID" \
  -d client_secret="$CLIENT_SECRET" \
  -d scope="api://$API_APP_ID/.default"

The response holds an access_token and its lifetime in expires_in (seconds). Reuse the token until shortly before it expires; don't request one per call.

​Call the API

curl -s "https://vnext-api.cloudlabs.ai/v1/labs/$LAB_ID" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Scopes are set in CloudLabs

You don't ask for labs.read or other CloudLabs scopes in the token request. They belong to the client in CloudLabs, and the API checks them on every call.

​Safe-retry creates

Calls that create something accept an Idempotency-Key header. Send a unique value (a UUID) per intended create; if the network fails, repeat the call with the same key and CloudLabs won't create a second copy.

Keep the client secret on your server. Never put it in a browser, a mobile app or a repository.

Was this page helpful?