Back to Content Management API
scheduleCreate
Creates a schedule.
Arguments
- Name
input
- Type
- CreateScheduleInput!
- Description
An object.
title
:String!
description
:String
executeAt
:DateTime
timezone
:String
content
: [ContentToSchedule!]
Returns
- Name
Schedule.*
- Type
- Schedule
- Description
Any requested field from the Schedule object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query =
`mutation scheduleCreate($input: CreateScheduleInput!) {
scheduleCreate(input: $input) {
id
title
description
executeAt
timezone
content {
id
type
data {
title
handle
description
seo {
title
description
keywords
}
sectionIds
}
}
}
}`;
const variables = {
input: {
title: 'Schedule Title',
description: 'Schedule Description',
executeAt: '2022-01-01T00:00:00Z',
timezone: 'America/New_York',
content: [
{
type: 'YOUR-CONTENT-TYPE',
data: {
title: 'Content Title',
handle: 'content-handle',
description: 'Content Description',
seo: {
title: 'Content SEO Title',
description: 'Content SEO Description',
keywords: ['content', 'keywords']
},
sectionIds: ['YOUR-SECTION-ID']
}
}
]
}
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"scheduleCreate": {
"id": "1",
"title": "Schedule Title",
"description": "Schedule Description",
"executeAt": "2022-01-01T00:00:00Z",
"timezone": "America/New_York",
"content": [
{
"id": "1",
"type": "YOUR-CONTENT-TYPE",
"data": {
"title": "Content Title",
"handle": "content-handle",
"description": "Content Description",
"seo": {
"title": "Content SEO Title",
"description": "Content SEO Description",
"keywords": ["content", "keywords"]
},
"sectionIds": ["YOUR-SECTION-ID"]
}
}
]
}
}
}