Back to Content Management API

articleUpdateBulk

Allows you to bulk update articles.

Arguments

  • Name
    ids
    Type
    [ID!]
    Description

    Array of article IDs that you want to update.

  • Name
    input
    Type
    [ArticleUpdateInput!]!
    Description

    Array of objects for each corresponding article 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!]
    • blogId: String The ID of the blog the article belongs to.
    • author: String
    • category: String
    • tags: [String!]
    • excerpt: String
    • bodyHtml: String
    • 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 ArticleUpdateBulk($ids: [ID!]!, $input: [ArticleUpdateInput!]!) {
      articleUpdateBulk(ids: $ids, input: $input) {
        id
      }
    }
`;

const variables = {
  "ids": ["article-id-1", "article-id-2"],
  "input": [
    {
      "title": "New Title",
      "handle": "new-title",
      "firstPublishedAt": "2021-01-01T00:00:00Z",
      "firstPublishedAtTimezone": "America/New_York",
      "description": "New Description",
      "seo": {
        "title": "New SEO Title",
        "description": "New SEO Description",
        "image": "https://example.com/image.jpg",
        "keywords": ["keyword1", "keyword2"]
      },
      "template": "new-template",
      "sectionIds": ["section-id-1", "section-id-2"]
    },
    {
      "title": "New Title 2",
      "handle": "new-title-2",
      "firstPublishedAt": "2021-01-01T00:00:00Z",
      "firstPublishedAtTimezone": "America/New_York",
      "description": "New Description 2",
      "seo": {
        "title": "New SEO Title 2",
        "description": "New SEO Description 2",
        "image": "https://example.com/image2.jpg",
        "keywords": ["keyword3", "keyword4"]
      },
      "template": "new-template-2",
      "sectionIds": ["section-id-3", "section-id-4"]
    }
  ]
};

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

console.log(response.data);


Response

{
    "data": {
        "articleUpdateBulk": {
          "id": "1"
        }
    }
}

Was this page helpful?