Back to Content Management API

template

Returns a template by ID in a draft or published state.

Arguments

  • Name
    id
    Type
    ID!
    Description

    The ID of the template.

  • Name
    version
    Type
    Version
    Description

    The state of the template you want to retrieve.

    • To get the latest content use CURRENT.
    • To get the latest published content use PUBLISHED

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 = `
query GetTemplate($id: ID!, $version: Version) {
  template(id: $id, version: $version) {
    id
    title
    status
  }
}
`
const variables = {
  id: 'template-id',
}
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
    "data": {
        "template": {
            "title": "Template Title",
            "status": "DRAFT"
        }
    }
}

Was this page helpful?