Skip to main content

Sitecore Stream - Manage brand kits and brand documents and ingest using REST API


Hello Sitecore Enthusiastic,

Today i will be sharing one of the recent rollouts from Sitecore Stream which is the developer APIs using which one can directly manage their brand kit, upload documents to it and also start ingestion process and that all using APIs.

As recent as June, Sitecore announced REST APIs for Sitecore Partners using which Sitecore partners can now use Stream REST APIs to integrate with their existing systems and support brand governance.

List of APIs for Sitecore Stream

https://api-docs.sitecore.com/?product=AI+capabilities

1) Brand Management API

    As we know Brand kit is the major building block of how Stream gets its brand awareness from, So using this brand management API, You can create new brand kit, you can get specific brand kit or list of brand kits and also can get specific section of brand kit like brand context, tone of voice etc and also can update them.



2) Document Management API

    Each brand document can represent brand's history, context, tone of voice or what not, So once the brand kit is created, One can now use this document management API to create brand document and upload it to brand kit from where it can be ingested, Use case could be a healthcare client want to have approval workflow before AI starts grounding it, so you can hook this API after certain workflow or approved file is dropped to certain location and use this API to then upload it to brand kit, so the process can be automated before AI starts grounding it, it will be one more additional intelligent step to from compliance or governance point of view.



3) Pipeline API

    During the brand ingestion process, the system analyzes each uploaded document page by page, extracts brand information, and breaks it down into smaller pieces called knowledge chunks. These chunks are then organized, vectorized, and stored as your brand knowledge.

The AI uses this brand knowledge to generate content for each section of the brand kit. After the sections are populated, both the comprehensive brand knowledge and the completed brand kit sections are ready for use by Sitecore copilots and other AI tools.



Prerequisites

Before even using the APIs, you will need to generate JWT token, and to generate the token you will first need to create the Brand kit keys (formerly known as "partner keys") which is typically a client id and secret so that using which you can generate the token and use that token to make subsequent calls.

Sitecore has amazing postman like functionality available right into Sitecore Stream documentation which you can find here Try Now

  curl -X POST 'https://auth.sitecorecloud.io/oauth/token' \

  --header 'Content-Type: application/x-www-form-urlencoded' \

  --data-urlencode 'client_id={YOUR_API_KEY}' \

  --data-urlencode 'client_secret={YOUR_API_SECRET}' \

  --data-urlencode 'grant_type=client_credentials' \

  --data-urlencode 'audience=https://api.sitecorecloud.io'

If you copy above and just import into postman as a raw text and then just given client id and secret, and you can generate the partner client id and client secret using partner keys.


NOTE: Make sure to copy generated ClientId and Secret and keep it somewhere safe, As once generated and dialog box is closed, You can not get those same things back (Though you can generate new)

HINT : Do you know what is the difference between xp/xm keys and brand kit keys? Both have different scopes, XP/XM keys does not give you access to brand kit APIs, so if you want to play around with brand kit APIs, Make sure you generate brand kit keys.

I have my sample created and imported into postman and it generated token like below 


Now, subsequent calls you can try out from Sitecore portal itself, Some of the calls are below, where i am trying to get list of brand kits i have 


Similarly you can try other calls and make an application of your own which could communicate with Sitecore Stream and get the things done, I have defined use cases which you can do.

It is important to know which region your stream app is operating because while making a call you will need to determine the server url or endpoint which will be validated against your actual region, If not done correctly you might get into errors (Explained below)

Errors

When playing around with APIs, you might get below exceptions 

1) 'str' object has no attribute 'HTTP_400_BAD_REQUEST'

This happens typically when server URL is wrong against which you are making a request, Your stream app will be hosted on SaaS and it will have its region, As of now there four types of server avaialble

a) Production West Europe Server which has "https://ai-brands-api-euw.sitecorecloud.io" URL.

b) Production East US API Server which has "https://ai-brands-api-use.sitecorecloud.io" URL

c) Production Australia East API Server which has "https://ai-brands-api-aue.sitecorecloud.io" URL

d) Production Japan East API Server which has "https://ai-brands-api-jpe.sitecorecloud.io" URL

2) The request failed with status code: 403 - Invalid organizationId

This happens where organizationId is wrong, Typically when you are using Sitecore's UI or "Try now" button, it gives you sample data for region specific env variables, you will need to change those variables to match with your org id etc. else this error will come. 

Use Cases

1) Brand Governance - Where organization wants to have control over which document or information should go to brand guidelines, With this APIs you can automate your item workflows and call these APIs when someone approves the items etc. or in general an automation can be placed to as and when brand guideline updates quarterly or annually, these automation can keep updating brand kits as per updated guidelines.

2) Marketing Automation - Where a company with global brand and regional brands would like to set up tone of voice or campaign specific to region and they would like automate the process of updating the section or sub section of brand kits with regional tone or localize campaigns.

3) External Integration - When scenarios like you would like to read a tone of voice of the brand and use that tone of voice to send email with that tone or generate and email from some system by passing tone of voice so brand feels the same, at that time these APIs can also be used.

4) Ease of brand management - It becomes difficult for a company with so many brand to keep updating the brand specific document or sections as and when brand refreshes or rebranding happens, in those scenarios automation will help sync brands and keep updating them with latest and greatest.

I will be sharing some example and code snippets on GITHUB of above use cases in next blogs

Thanks for reading


Comments

Popular posts from this blog

Set up leprechaun code generation with Sitecore XM Cloud Starterkit

Hi Sitecorians, It has been amazing learning year so far and with the change in technology and shift of the focus on frontend frameworks and composable products, it has been market demand to keep learning and exploring new things. Reasons behind this blog Today's topic is something that was in my draft from April-May, and I always thought that there is already a good documentation out there for  Leprechaun  and a blog post is not needed, Until I realized that there was so many of us facing same kind of issues and same kind of problems and spending same amount of time, That is where I thought, if I could write something which can reduce that repetitive troubleshooting time, That would really help the community. 1)  In a project environment, if we get into some configuration issues, we resolve them, we make sure we are not blocked and continue, but if you think same issue, same step and same scenario will come to other people, so if we can draft it online, it will help othe...

High CPU to completely normal CPU - SXA issue, SXA pages not loading in mobile device

  Hi Team, Today i am going to share one of the nightmarish issue with you all, We are having Sitecore 9.1.1 hosted in azure PaaS environment Our site was working just fine and no noise, but we have been working on a feature release where 7-8 months of development needed to be released to production, Big GO LIVE event right?  Also to make the development smoother we also introduced BLUE/GREEN deployment slots in the same release, so we can easily SWAP slots and go live Everything went well, we went live, we even did load and performance testing on our staging and pre-prod and we were confident enough of results Very next day we started getting "SITE DOWN" alerts, and also product owners and clients mentioned that site is very slow for them in US time and in our morning when we were accessing it, it was working lighting fast so we were clue less at start, but we started digging  1) First thing caught our eyes were HIGH CPU spikes, in US time, also without any traffic CPU u...

An error occurred while receiving the HTTP response to This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

You have noticed many times that everything was working fine and suddenly the below error starts coming and you find no way to work it out An error occurred while receiving the HTTP response to This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. The reason for this is the receiving size of WCF service is smaller then the data which is coming from service It was working before because it was small,So you will have to try to increase the receiving setting in your end point,Possible settings can be following maxStringContentLength="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxArrayLength="2147483647" That would definately help you!!!