Back to Content Management API

blogUpdateBulk

Allows you to bulk update blogs.

Arguments

  • Name
    ids
    Type
    [ID!]
    Description

    Array of blog IDs that you want to update.

  • Name
    input
    Type
    [BlogUpdateInput!]!
    Description

    Array of objects for each corresponding blog ID to update.

    • title: String
    • handle: String
    • firstPublishedAt: DateTime
    • firstPublishedAtTimezone: String
    • description: String
    • seo: SEOInput
    • template: String The title of the template to attach.
    • sectionIds: [ID!]
    • templateId: ID The ID of the template to attach. Takes precedence over template.
    • sectionOverrides: JSON Section overrides for this content, as JSON.
    • draftId: ID Legacy, from the drafts system that Content Releases replaced. To read or write a release's changes, send the X-Pack-Release-Id header instead. See Content Releases.

Returns

  • Name
    Job
    Type
    Job
    Description

    The id of the background job that runs the bulk operation.

Request

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

const query = `
  mutation BlogUpdateBulk($ids: [ID!]!, $input: [BlogUpdateInput!]!) {
    blogUpdateBulk(ids: $ids, input: $input) {
      id
    }
  }
`;

const variables = {
  "ids": ["blog-id-1", "blog-id-2"],
  "input": [
    {
      "title": "New Blog Title",
      "handle": "new-blog-title",
      "description": "New blog description",
      "firstPublishedAt": "2022-01-01T00:00:00Z",
      "firstPublishedAtTimezone": "UTC",
      "seo": {
        "title": "New Blog Title",
        "description": "New blog description",
        "image": "https://example.com/image.jpg",
        "keywords": ["keyword1", "keyword2"]
      },
      "template": "blog-template",
      "sectionIds": ["section-id-1", "section-id-2"]
    }
  ]
};


const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
    "data": {
        "blogUpdateBulk": {
            "id": "YOUR-JOB-ID"
        }
    }
}

Was this page helpful?