Content Management API: Endpoints and Implementation

Content management is a core part of Pack — the very reason Pack exists is so you can easily and flexibly manage complex content on your storefront. On this page, we'll dive into the different content management endpoints you can use to manage your content programmatically. Plus, we'll look at all our GraphQL endpoints for managing your content.


Authentication

All GraphQL Admin API queries need a valid Pack access token.

Add your token as an Authorization header to all API queries.

If you use the Secret Token, you'll have permission to read and write through the API. If you use the Public Token, you'll only have read access.

The @pack/client package offers a client for working with the Pack GraphQL API.

import { PackClient } from '@pack/client';

const packClient = new PackClient({
  apiUrl: 'https://app.packdigital.com/graphql',
  token: '{YOUR_SECRET_TOKEN}',
  contentEnvironment: 'content_environment_handle',
});

const query = `
query {
  siteSettings {
    settings
    seo {
      title
      description
      keywords
    }
  }
}
`;

async function fetchSiteSettings() {
    const response = await packClient.fetch(query);
    console.log(response.data.siteSettings);
}

fetchSiteSettings();

Pagination

List queries use cursor pagination with first, after, last, and before. The sections field on pages, product pages, collection pages, blogs, articles, and templates is paginated too: it returns 50 sections by default and up to 100 per request. Use sections(first: 100, after: $cursor) with pageInfo to read long pages.


Page

A page is structured data that will hold information like title, description, SEO data, and most importantly its sections – the building blocks of your site's content. When navigating to routes in your storefront under the /pages/ template, it will use this page data to get content.

Queries

Mutations


Product Page

A product page is structured data that will hold information like title, description, SEO data, and most importantly its sections – the building blocks of your site's content. When navigating to routes in your storefront under the /products/ template, it will use this page data to get content.

Queries

Mutations


Collection Page

A collection page is structured data that will hold information like title, description, SEO data, and most importantly its sections – the building blocks of your site's content. When navigating to routes in your storefront under the /collections/ template, it will use this page data to get content.

Queries

Mutations


Blog

A blog is structured data that will hold information like title, description, SEO data, and most importantly its sections – the building blocks of your site's content. When navigating to routes in your storefront under the /blogs/ template, it will use this page data to get content.

Queries

Mutations


Article

An article is structured data that will hold information like title, description, SEO data, and most importantly its sections – the building blocks of your site's content. When navigating to routes in your storefront under the /articles/ template, it will use this page data to get content.

Queries

Mutations


Section

A section is the structured data that houses the content for your page. The section's data model is derived from its corresponding component schema in your code base.

Queries

Mutations

Site Settings

This is the storefront site settings.

Queries

Mutations


Content Releases

Content Releases stage coordinated CMS changes and publish them together. Release-scoped reads and writes use the X-Pack-Release-Id header; when the header is present, Pack reads release drafts where they exist and falls through to current live content where they do not.

Use the Content Releases guide for the editor workflow and conflict review process.

Queries

Mutations


Schedules

Schedules are used to publish or unpublish content at a specific time in the future.

Queries

Mutations


Events

The store's change journal: content changes plus lifecycle events for content releases, schedules, and A/B tests. Poll it with a cursor as an alternative to webhooks.

Queries


Content Environments

Content environments hold separate copies of your storefront's content. Look one up to get the handle you pass to @pack/client or createPackClient. See Content Environments.

Queries


Locales

Locales are the language and country combinations your storefront serves. A locale's id is the localeId the *Translate mutations take. See Localization.

Queries


Nodes

Look up content by ID without knowing its type. Results can be a Page, ProductPage, CollectionPage, Article, Blog, Section, Template, or ContentRelease.

Queries


Templates

A template is a container for template sections and is used to repeat these sections throughout pages that use the template.

Queries

Mutations

Was this page helpful?