Skip to main content

Developers - API

Publishing

Changes made on the preview site have to be published before they become visible on the live site.
Perfection offers an API to publish component and section instances on a given page through the Publishing API.

Before being able to publish a page through the API, you need to know which components and sections are on the page.
By using the Instances API, you can retrieve all section and component instances that are referenced on the provided page.

Get instance IDs

Request the page details by performing a GET request as demonstrated below. Replace the subscription id and site name with the values from your environment. Make sure the specify the preview query string parameter as true to get the instance references currently in preview.

curl 'https://delivery.api.perfection.dev/api/v1/subscriptions/{subscriptionId}/sites/{siteName}/instances?preview=true'

The response will look something like this:

{
"message": "string",
"result": {
"sections": [
{
"id": "string",
"inner": "string",
"outer": "string",
"version": 0,
"published": true
...
}
],
"components": [
{
"groupId": "string",
"id": "string",
"version": 0,
"published": true,
...
}
]
}
}

The properties we are interested in in this response object, are the section ids and component groupId and id combinations. When an instance is marked as already published, you don't have to include it in the publishing API request.

Perform Publish

Having gathered the IDs in the previous step, we can now publish them. Publishing happens by posting a JSON object containing a page ID, a list of section IDs and a list of component groupId and id combinations.

{
"pageId": "string",
"sections": ["string"],
"components": [
{
"groupId": "string",
"id": "string"
}
]
}

The JSON object than has to be posted to the Publishing API as follows:

curl -X POST https://delivery.api.perfection.dev/api/v1/subscriptions/{subscriptionId}/sites/{siteName}/publish
-H 'Content-Type: application/json'
-d '{"pageId": "string","sections": ["string"],"components": [{"groupId": "string","id": "string"}]}'

The response object of the Publishing API will return lists of sections and components that have been published.

References