Back to Content Management API
scheduleAddContent
Adds content to a schedule by ID.
Arguments
- Name
id
- Type
- ID!
- Description
The ID of the schedule.
- Name
input
- Type
- AddContentToScheduleInput!
- Description
An object.
content
:[ContentToSchedule!]!
The
ContentToSchedule
object format is:contentId
:ID!
contentType
:ContentType!
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 scheduleAddContent($id: ID!, $input: AddContentToScheduleInput!) {
scheduleAddContent(id: $id, input: $input) {
id
title
description
executeAt
timezone
content {
id
type
data
}
}
}
`;
const variables = {
id: 'YOUR-SCHEDULE-ID',
input: {
content: [
{
contentId: 'YOUR-CONTENT-ID',
contentType: 'YOUR-CONTENT0-TYPE'
}
]
}
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"scheduleAddContent": {
"id": "YOUR-SCHEDULE-ID",
"title": "Schedule Title",
"description": "Schedule Description",
"executeAt": "2022-01-01T00:00:00Z",
"timezone": "America/New_York",
"content": [
{
"id": "YOUR-CONTENT-ID",
"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"]
}
}
]
}
}
}