Back to Content Management API

templateRestore

Restores a template's title and section order from one of its revisions. Other settings, such as rules and whether it's the default template, aren't changed. The restored template is a draft until you publish it.

With a content release selected (X-Pack-Release-Id), the restore is saved to the release instead. Revisions older than your plan's revision-history window can't be restored.

Arguments

  • Name
    id
    Type
    ID!
    Description

    The ID of the template.

  • Name
    revisionId
    Type
    ID!
    Description

    The ID of the revision to restore, from templateHistory.

Returns

  • Name
    Template.*
    Type
    Template
    Description

    Any requested field from the Template object.

Request

import { PackClient } from '@pack/client'
const packClient = new PackClient({
  token: 'YOUR-PACK-SECRET-TOKEN'
});

const query = `
  mutation TemplateRestore($id: ID!, $revisionId: ID!) {
    templateRestore(id: $id, revisionId: $revisionId) {
      id
      title
      status
    }
  }
`;

const variables = {
  id: 'YOUR-TEMPLATE-ID',
  revisionId: 'YOUR-REVISION-ID'
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
    "data": {
        "templateRestore": {
            "id": "YOUR-TEMPLATE-ID",
            "title": "Product Template",
            "status": "draft"
        }
    }
}

Was this page helpful?