Update Post Publication Date and Time via News API

Learn how to update a post's publication date and time using the News API.

The News API gives you a lot of flexibility in how you create and manage your news content. Be that for integrating news content between the Staffbase and external platforms or improving efficiencies. See the [News API specifications] (https://developers.staffbase.com/api/api-news/).

In this article, we'll look at a common use case for updating the publication date and time of a News post.

Publication date and time of a post in Studio

Publication Date and Time in Studio

Publication date and time of a post in web app

Publication Date and Time in Web

Prerequisites

  • You have created an API token with editorial access or higher via the Staffbase Studio. Learn more.
  • You know how Staffbase API authentication works. Learn more.
  • You have the ID of the post for which you want to modify the publication date and time. Learn more .

When a post is updated, any notification settings you have previously set still apply. For example, if push notifications are enabled for a post, they are resent upon update, unless you disable them.

Updating the publication date and time for a News post

PUT request to the endpoint /posts/{postID}

Make a PUT request to the endpoint /posts/{postID} to update the publication date and time.
In the request body schema, set published parameter to a date and time of your choice in UTC time in ISO 8601 format. For example, 2023-11-07T09:00:00.000Z

If you are not familiar with UTC time, you can find several online converters that allow you to translate date and time into your preferred time zone to UTC.

Additionally, if you do not want to resend notifications for the updated post, in the request body schema, set the notificationChannels parameter to null.

1export POST="614ad94d23af1d5f9f8f5301"
2export AUTH="Basic TOKEN"
3
4curl "https://exampleapp.staffbase.com/api/posts/$POST" \
5 -X PUT \
6 -H "Authorization: $AUTH" \
7 -H "Content-Type: application/json; charset=UTF-8" \
8 -d '{
9 "notificationChannels": null,
10 "published": "2023-11-07T09:00:00.000Z"
11}'

You have updated the published date and time of a post. To bulk update the published date and time of several posts, add a function to loop through all post IDs to perform your requests.