Create a page using the asset management API
The Squiz Matrix asset management API (asset management API) adds an interface to your Matrix instance that lets you create assets beneath a specified parent asset from your code.
The asset management API is a Representational State Transfer (REST) API. This means that it complies with the REST architectural constraints.
There are many use cases for using an API to build a Matrix page. The most common use case is when you need to create many pages at one time, for example:
A university needs to create new pages twice a year to show which courses are available and provide details.
A retail business needs to create pages automatically from their product database.
A multi-lingual website wants to automatically create translated copies of pages when a page is updated.
A council wants to automatically publish a list of services from its database to its website.
Instead of using the Matrix Admin UI to create each page individually, you can write code to create many pages quickly.
There are some setup steps before using the Squiz Matrix asset management API.
Get an API token. Read Create a Token to find out how to get an API token.
Find out about authentication. Each request needs to be authenticated with a bearer token. Read Authentication for information about the bearer token.
Read the Create request overview to find out about the fields and settings in the create request.
The asset management API manipulates individual Matrix assets. Standard pages are compound assets made up of multiple dependent assets, so there are four steps to creating a page through the API:
|Each step is dependent on the successful completion of the previous step.|
These instructions will create a structure like the one shown in the following image:
The structure supports the dependent nature of the assets.
Read API response codes for explanations of the most common error codes.
Read Open API details for more information about the API definition.
When you run the instructions above in order, you will end up with the structure shown in Asset structure:
You will need to run the whole set of four asset creation steps in this guide for each page required.