Get started with Sitecore Experience Edge For XM — Part 3
In Part 2 of this blog series, we’ve looked at how to set up experience edge for XM and publish content to the Edge. In this blog, let's explore Edge APIs, administering and querying the Edge
Experience Edge offers the following APIs
- Token API —Identity and access management — https://edge.sitecorecloud.io/api/apikey/v1
- Admin API — Modify Cache settings, Modify Webhooks Https://edge.sitecorecloud.io/api/admin/v1 —
- Delivery API — Accessing published content — https://edge.sitecorecloud.io/api/graphql
Experience edge uses two different mechanisms for authentication
- For executing an operation (Admin API) you’ll have to request an access token using the Token API
- For accessing published content (Delivery API) you’ll need an API key
Requesting an access token
Experience Edge for XM uses the OAuth framework for Authorisation. In order to access APIs and execute an operation on experience edge the calling system must first obtain a JWT Token and include it in every request call to the edge, After successful authentication, the calling application will receive an access token which can be used to call experience edge API’s
curl --request POST --url "https://one-sc-production.eu.auth0.com/oauth/token" --header "content-type: application/x-www-form-urlencoded" --data grant_type=client_credentials --data client_id=<clientid> --data client_secret=<clientsecret> --data audience=https://delivery.sitecore.cloud/<tenant-id>
client_id — Provided by Sitecore sales rep
client_secret — provided by Sitecore sales rep
audience — The audience for your tenant as provided by Sitecore. It will be in the form https://delivery.sitecore.cloud/tenant-id
with tenant-id
substituted for your tenant ID.
Creating an API Key
To access Delivery API , The first step is to Generate an access token
Step tiwo to Generate an API Key
curl --request POST --url "https://edge.sitecorecloud.io/api/apikey/v1" --header "content-type: application/json" --header "Authorization: Bearer <JWT token>" --data "{ \"CreatedBy\":\"ADN\", \"Label\":\"Website token\", \"Scopes\": [\"content-#everything#\", \"audience-delivery\"] }"
<JWT Token> — to be generated by Step one
Once you have generated your token, you must pass your API token in the headers for your request. Click HTTP headers and add the token in the following format: {"sc_apikey": "YOUR_TOKEN"}
Sitecore Services Client and Sitecore GraphQL also accept API keys via query string. However, we recommend to use the sc_apikey
HTTP header as this is mirrors the behavior of Experience Edge.
API Postman collection for Experience Edge by Himadri — https://www.postman.com/blue-satellite-9251/workspace/dec0b4c9-14fd-4f81-bc66-94220a1094b9/request/2874930-2ae02dd6-cffc-4c37-9e06-76805bc8afb7