Assign a metadata schema to an asset
This section shows you how to use the Asset Management API to add a metadata schema to a page from within your code. This function is a subset of the update asset endpoint.
The metadata schema being assigned with this command must already exist. |
Command
Use the following command to assign a metadata schema to an asset:
PATCH https://website.matrix.squiz.cloud/__management_api/v1/assets/<asset-id>
<asset-id>
is the ID of the asset to which you want to assign the metadata schema.
Payload
Set the following fields as shown on the example metadata schemas payload:
{
"metadata_schemas": [
{
"id": "5190", (1)
"granted": true, (2)
"cascades": true (3)
}
],
"metadata_values": {
}
}
1 | The asset ID of the metadata schema to be applied. |
2 | Value supplied for granted . Granted can have a value of 'true' or 'deny'. |
3 | Value supplied for cascades. |
Response
The API response will contain:
{
"id": "3435", (1)
"type": "page_standard",
"attributes": {
"name": "Home ",
"short_name": "Home"
},
"status": "under_construction",
"version": "0.0.3",
"created": {
"date_time_unix": 1646800343,
"user_id": "1227"
},
"updated": {
"date_time_unix": 1650604104,
"user_id": "1227"
},
"published": null,
"status_changed": {
"date_time_unix": 1646800343,
"user_id": "1227"
},
"metadata_schemas": [ (2)
{
"id": "5190", (3)
"granted": true, (4)
"cascades": true (5)
}
],
"metadata_values": {
"keywords": null,
"description": null,
"right-col": null,
"right-col-include": null,
"show-heading": null
},
"paint_layouts": {
"asset_level": null,
"asset_level_override": null,
"url_based": {
"domainname.matrix.squiz.cloud/test-site/home": {
"regular": null,
"override": null
}
},
"user_defined": {
"domainname.matrix.squiz.cloud/test-site/home": null
}
},
"web_paths": [
"home"
],
"urls": [
{
"path": "domainname.matrix.squiz.cloud/test-site/home",
"schemes": [
"https"
]
}
],
"external_id": ""
}
1 | The asset ID to which the metada schema was applied. |
2 | The section that provides information about the metadata schema that was applied by this command. |
3 | The asset ID of the metadata schema. |
4 | The value of the 'granted' setting. |
5 | The value of the 'cascades' setting. |