Back to Content Management API

templatePublish

Publishes a template.

Arguments

  • Name
    id
    Type
    ID!
    Description

    The ID of the template you want to publish.

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-TOKEN'
});

const query = `
  mutation templatePublish($id: ID!) {
    templatePublish(id: $id) {
      id
      title
      type
      isDefault
      status
      publishedAt
      createdAt
    }
  }
`;

const variables = {
  id: 'YOUR-TEMPLATE-ID'
};

const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
  "data": {
    "templatePublish": {
      "id": "YOUR-TEMPLATE-ID",
      "title": "YOUR-TEMPLATE-TITLE",
      "type": "YOUR-TEMPLATE-TYPE",
      "isDefault": false,
      "status": "published",
      "publishedAt": "2022-01-01T00:00:00Z",
      "createdAt": "2022-01-01T00:00:00Z"
    }
  }
}

Was this page helpful?