Remove metadata schema from an asset

This section shows you how to use the API to remove a previously assigned metadata schema from an asset from within your code.

Command

Use the following command to remove a metadata schema from an asset:

PATCH https://website.matrix.squiz.cloud/__management_api/v1/assets/<asset-id>

<asset-id> is the asset ID of the asset being updated.

Payload

To remove the association between a metadata schema and an asset, update the asset without including the metadata schema you want to remove. If an asset has more than one metadata schema assigned, and you just want to remove one of them, you must list ALL the metadata schemas EXCEPT the one you want to remove.

Payload examples

The examples below show the effect on the following asset configuration. Note that there are two metadata schemas assigned to this asset, as shown in the metadata_schemas section of the JSON example below.

{
    "id": "3435",
    "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": 1662684984,
        "user_id": "1227"
    },
    "published": null,
    "status_changed": {
        "date_time_unix": 1646800343,
        "user_id": "1227"
    },
    "metadata_schemas": [      (1)
        {
            "id": "5190",
            "granted": true,
            "cascades": true
        },
        {
            "id": "5191",
            "granted": true,
            "cascades": true
        }
    ],
    "metadata_values": {
        "keywords": {
            "type": "metadata_field_text",
            "value": [
                "test keywords"
            ]
        },
        "description": {
            "type": "metadata_field_text",
            "value": "test description"
        },
        "right-col": {
            "type": "metadata_field_select",
            "value": "0"
        },
        "right-col-include": {
            "type": "metadata_field_related_asset",
            "value": ""
        },
        "show-heading": {
            "type": "metadata_field_select",
            "value": "1"
        },
        "site-logo": null
    },
    "paint_layouts": {
        "asset_level": null,
        "asset_level_override": null,
        "url_based": {
            "dx-develop.dev.matrix.squiz.cloud/test-site/home": {
                "regular": null,
                "override": null
            }
        },
        "user_defined": {
            "dx-develop.dev.matrix.squiz.cloud/test-site/home": null
        }
    },
    "web_paths": [
        "home"
    ],
    "urls": [
        {
            "path": "dx-develop.dev.matrix.squiz.cloud/test-site/home",
            "schemes": [
                "https"
            ]
        }
    ],
    "external_id": ""
}
1 Two metadata schemas assigned to this asset

Remove all metadata schemas

Payload

To remove ALL the metadata schemas, pass the payload with an empty metadata_schemas attribute.

{
    "metadata_schemas": []
}

Response

The response shows that all the metadata schemas have been removed.

{
    "id": "3435",
    "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": 1662599482,
        "user_id": "1227"
    },
    "published": null,
    "status_changed": {
        "date_time_unix": 1646800343,
        "user_id": "1227"
    },
    "metadata_schemas": [],  (1)

    "metadata_values": null,
    "paint_layouts": {
        "asset_level": null,
        "asset_level_override": null,
        "url_based": {
            "dx-develop.dev.matrix.squiz.cloud/test-site/home": {
                "regular": null,
                "override": null
            }
        },
        "user_defined": {
            "dx-develop.dev.matrix.squiz.cloud/test-site/home": null
        }
    },
    "web_paths": [
        "home"
    ],
    "urls": [
        {
            "path": "dx-develop.dev.matrix.squiz.cloud/test-site/home",
            "schemes": [
                "https"
            ]
        }
    ],
    "external_id": ""
}
1 No metadata schemas associated with this asset.

Remove specific metadata schemas

To remove specific metadata schemas, list the metadata schemas you want to keep. Do not list the metadata schema you want to remove.

Payload

{
    "metadata_schemas": [
        {
            "id": "5190",  (1)
            "granted": true,
            "cascades": true
        }
    ]
}
1 List the metadata schemas you want to KEEP.

Response

The response shows that the metadata schemas listed in the payload are kept.

{
    "id": "3435",
    "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": 1662684984,
        "user_id": "1227"
    },
    "published": null,
    "status_changed": {
        "date_time_unix": 1646800343,
        "user_id": "1227"
    },
    "metadata_schemas": [
        {
            "id": "5190",   (1)
            "granted": true,
            "cascades": true
        }
    ],
    "metadata_values": {
        "keywords": {
            "type": "metadata_field_text",
            "value": [
                "test keywords"
            ]
        },
        "description": {
            "type": "metadata_field_text",
            "value": "test description"
        },
        "right-col": {
            "type": "metadata_field_select",
            "value": "0"
        },
        "right-col-include": {
            "type": "metadata_field_related_asset",
            "value": ""
        },
        "show-heading": {
            "type": "metadata_field_select",
            "value": "1"
        }
    },
    "paint_layouts": {
        "asset_level": null,
        "asset_level_override": null,
        "url_based": {
            "dx-develop.dev.matrix.squiz.cloud/test-site/home": {
                "regular": null,
                "override": null
            }
        },
        "user_defined": {
            "dx-develop.dev.matrix.squiz.cloud/test-site/home": null
        }
    },
    "web_paths": [
        "home"
    ],
    "urls": [
        {
            "path": "dx-develop.dev.matrix.squiz.cloud/test-site/home",
            "schemes": [
                "https"
            ]
        }
    ],
    "external_id": ""
}
1 The metadata schema specified in the command remains.