• PXM Hierarchies/
    PXM Hierarchies API/
    Duplicate a Hierarchy

    Duplicate a Hierarchy

    POST Duplicate a Hierarchy

    https://api.moltin.com/pcm/hierarchies/:hierarchyId/duplicate_job
    

    Using this option, you can duplicate an existing hierarchy. This is useful because it enables you to quickly and easily create multiple hierarchies with the same node structure.

    When you duplicate a hierarchy, you can specify a new name and/or a new description for the duplicated hierarchy. All other attributes, such as slug and locales, stay the same.

    Any nodes in the existing hierarchy are also replicted in the duplicated hierarchy. In addition, you can optionally use the include_products attribute to specify whether you want products associated with the nodes in an existing hierarchy to be associated with the nodes in the duplicated hierarchy. By default, product associations in an existing hierarchy are not duplicated in a duplicate hierarchy.

    Duplicating a hierarchy is an asynchronous operation. When you duplicate a hierarchy, a job is created. The jobId of the job is displayed in the response. When the job is complete, the duplicate hierarchy operation is also complete. You can use the jobId to see the status of your job using Get a Job. Once the job is complete, run:

    • Get all hierarchies to retrieve the HierarchyId of your duplicated hierarchy.
    • Get a hierarchy to retrieve the nodes and (if applicable) products associated with the duplicated hierarchy.

    Parameters

    Path parameters

    NameRequiredTypeDescription
    hierarchyIdRequiredstringThe unique identifier of the hierarchy you want to duplicate.

    Headers

    NameRequiredTypeDescription
    AuthorizationRequiredstringThe Bearer token required to get access to the API.

    Body

    NameRequiredTypeDescription
    typeRequiredstringAlways: hierarchy
    attributes.nameOptionalstringThe name of the duplicate hierarchy. The maximum length is 1000 characters.
    attributes.descriptionOptionalstringA description of the duplicate hierarchy.
    attributes.include_productsOptionalbooleanSpecify true if you want the product associations in the existing nodes associated in your duplicated hierarchy. If not, specify false.

    Request Example

    curl -X POST https://api.moltin.com/pcm/hierarchies/09150b64-b6a0-4928-a432-3edc721a2150/duplicate_job
         -H "Authorization: Bearer XXXX" \
         {
          "data": {
          "type": "hierarchy",
          "attributes": {
            "name": "football_games",
            "description": "All the football games we sell"
            "include_products": true
           }
         }
        }
    

    Response Example

    200 OK

    {
      "data": {
        "type": "hierarchy",
        "id": "aa5719e9-a5c4-4d57-a1f8-3ff6a267e962",
        "attributes": {
          "description": "All the football games we sell",
          "name": "football_games",
          "slug": "games"
        },
        "relationships": {
          "children": {
            "data": [],
            "links": {
              "related": "/hierarchies/aa5719e9-a5c4-4d57-a1f8-3ff6a267e962/children"
            }
          }
        },
        "meta": {
           "created_at": "2023-02-07T14:01:51.247Z",
           "owner": "store",
           "updated_at": "2023-02-07T14:01:51.247Z"
        }
      }
    }
    

    Was this helpful?

    Previous
    Update a Hierarchy