Back to Content Management API

pageCreate

Creates a new page.

Arguments

  • Name
    input
    Type
    PageCreateInput!
    Description

    An object.

    • title: String!
    • handle: String!
    • description: String
    • seo: SEOInput
    • sectionIds: [ID!]

Returns

  • Name
    Page.*
    Type
    Page
    Description

    Any requested field from the page object.

Request

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

const query = `
  fragment PageResourceFields on PageResource {
  title
  handle
  description
}
mutation PageCreate($input: PageCreateInput!) {
  pageCreate(input: $input) {
    ...PageResourceFields
  }
}
`;
const variables = {
  "input": {
      "title": "My Page",
      "handle": "my-page",
      "description": "This is my page.", 
  }
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
    "data": {
        "pageCreate": {
            "title": "My Page",
            "handle": "my-page",
            "description": "This is my page."
        }
    }
}

Was this page helpful?