Akshay Sura - Partner
6 Oct 2025
In this blog, let's work on how to set yourself up to start working with the Sitecore XM Cloud Management API. This also applies to the authoring api, I believe. I had issues piecing together instructions to get going on this. I am hoping
To interact with the Management API, we need:
First, navigate to your XM Cloud Deploy portal and add a new variable called Sitecore_GraphQL_ExposePlayground, setting the value to true.
Once you are done, you need to run a deployment for the variable to take effect.
Once the deployment is successful, you need to determine the instance URL. I went to the content editor. The URL of the content editor is your instance URL.
Once you get your instance URL, navigate to <your instance URL>/sitecore/api/authoring/graphql/ide/, which should open your GraphQL IDE.
Return to your XM Cloud Deploy and navigate to the credentials section. Here, you should create an Automation Client credential for your specific project and environment. Store these values safely, as you will not be able to retrieve them.
Next, let's get the Bearer token. Here is a sample PowerShell script to generate the token.
1$clientId = "YOUR CLIENT ID"
2$clientSecret = "YOUR CLIENT SECRET"
3
4Write-Host "Getting access token..." -ForegroundColor Cyan
5
6$tokenUrl = "https://auth.sitecorecloud.io/oauth/token"
7$tokenBody = @{
8 grant_type = "client_credentials"
9 client_id = $clientId
10 client_secret = $clientSecret
11 audience = "https://api.sitecorecloud.io"
12}
13
14$tokenResponse = Invoke-RestMethod -Uri $tokenUrl `
15 -Method Post `
16 -ContentType "application/x-www-form-urlencoded" `
17 -Body $tokenBody
18
19$accessToken = $tokenResponse.access_token
20Write-Host "Access token obtained $accessToken" -ForegroundColor Green
Here is a simple C # script to generate the token:
1using System.Text;
2using System.Text.Json;
3
4public class SitecoreTokenExample
5{
6 public static async Task Main(string[] args)
7 {
8 var clientId = "YOUR CLIENT ID";
9 var clientSecret = "YOUR CLIENT SECRET";
10
11 // Get the token
12 var token = await GetSitecoreToken(clientId, clientSecret);
13
14 Console.WriteLine($"Access Token: {token}");
15 }
16
17 public static async Task<string> GetSitecoreToken(string clientId, string clientSecret)
18 {
19 using var client = new HttpClient();
20
21 var requestBody = new
22 {
23
grant_type = "client_credentials",
24
client_id = clientId,
25
client_secret = clientSecret,
26
audience = "https://api.sitecorecloud.io"
27 };
28
29 var content = new StringContent(
30
JsonSerializer.Serialize(requestBody),
31
Encoding.UTF8,
32
"application/json"
33 );
34
35 var response = await client.PostAsync(
36
"https://auth.sitecorecloud.io/oauth/token",
37
content
38 );
39
40 var result = await response.Content.ReadAsStringAsync();
41 var tokenData = JsonSerializer.Deserialize<JsonElement>(result);
42
43 return tokenData.GetProperty("access_token").GetString();
44 }
45}
Get back to your GraphQL IDE: <your instance url>/sitecore/api/authoring/graphql/ide/, click on the HTTP Headers tab on the bottom left, and add your bearer token { "Authorization": "Bearer GENERATEDTOKEN"}
You can now run any query you like.
Try this sample one:
1mutation {
2 createItem(
3 input: {
4 name: "Sitecore Authoring and Management API"
5 templateId: "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"
6 parent: "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"
7 language: "en"
8 fields: [
9 { name: "title", value: "Welcome to Sitecore" }
10 { name: "text", value: "Welcome to Sitecore" }
11 ]
12 }
13 ) {
14 item {
15 itemId
16 name
17 path
18 fields(ownFields: true, excludeStandardFields: true) {
19 nodes {
20 name
21 value
22 }
23 }
24 }
25 }
26}
This will create a sample item under Home using the sample item template.
This shows that the token is functioning properly, and you can run queries.
My friends Lukasz and Kamruz helped navigate the challenges while exploring this.
Ready to bring your XM Cloud implementation to life? Get in touch to learn more about how Konabos can help you implement XM Cloud.
Akshay is a nine-time Sitecore MVP and a two-time Kontent.ai. In addition to his work as a solution architect, Akshay is also one of the founders of SUGCON North America 2015, SUGCON India 2018 & 2019, Unofficial Sitecore Training, and Sitecore Slack.
Akshay founded and continues to run the Sitecore Hackathon. As one of the founding partners of Konabos Consulting, Akshay will continue to work with clients to lead projects and mentor their existing teams.
Share on social media