Explore News API use case scenarios for your organization.
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 platform and external platforms or improving efficiencies. All News API specifications are listed here.
In this article, let's look at the everyday business use cases for the News API in your organization. The following is not an exhaustive list of use cases for the News API.
With the Staffbase News API, you can import all the news content created in any platform you use to your Staffbase platform. Import the content to a specific news channel in the Staffbase platform and publish it immediately or schedule it to be published later.
Importing news content from an external platform to the Staffbase platform can be helpful in many cases.
For example:
- To migrate all the content created in an external platform to the Staffbase platform
- To ensure that the content is accessible to your users on both platforms
- To build sync between the two platforms and provide a seamless flow of content
For syncing content, you need to create additional middleware between the two platforms.
- You have generated an API token with editorial access or higher via the Staffbase Studio.
- Ensure that the video or image content in your news content has a URL. If not, you need to upload the video or image content to the platform via Media API before proceeding with the News API. Learn more about it here.
- From the Staffbase Studio, obtain the channel ID for the news channel to which you want to import the news. Learn more about it here.
- Make a
POST
request to endpoint/channels/{channelID}/posts
to add a news post to the channel you want.
1export CHANNEL="5db0221d0a09a219c4ce9218"2export AUTH="Basic TOKEN"34curl "https://exampleapp.staffbase.com/api/channels/$CHANNEL/posts" \5 -X POST \6 -H "Authorization: $AUTH" \7 -H "Content-Type: application/json; charset=UTF-8" \8 -d '{9 "contents": {10 "en_US": {11 "title": "Very nice title.",12 "teaser": "Some clickbait",13 "content": "Full HTML content."14 }15 },16 "published": "true",17 "notificationChannels": ["email", "push"]18}' \19 --compressed | json_pp
You can set up an automation to import the news content on a regular basis.
When importing news content from an external platform to the Staffbase platform using the POST
request to the News API, you need to provide the URL of the video or image displayed along with the teaser. If the image or video file in the content does not have a URL, you can upload the file first using the Media API.
- You have generated an API token with editorial access or higher via the Staffbase Studio.
Reuse the API token you generated for importing news to the Staffbase platform.
- Make a
POST
request to the endpoint/media
to upload the file. Learn more about it here.
Once you have uploaded the image or video file using the Media API, you will get the URL to the uploaded file in the response sample. Use the URL when importing the news content from an external platform to the Staffbase Platform.
You want to resend the notification to HR-related posts published in the previous month to all the employees who have not read the post.
- You have generated an API token with editorial access or higher via the Staffbase Studio.
- From the Staffbase Studio, obtain the channel ID for the news channel where HR-related posts are published. Learn more about it here.
- Make a
GET
request to the endpoint/posts
to list all posts in the channel by providing thechannelID
. Learn more about it here. - From the response list you got, filter for the posts that fall into the time frame you want.
- Get the list of the postIDs for the posts in the time frame.
- Make a
POST
request to the endpoint/posts/{postID}/notifications
to resend notifications to all employees who have not read the post. In the request body schema, set therecipients
parameter tounread
.
1export POST="614ad94d23af1d5f9f8f5301"2export AUTH="Basic TOKEN"34curl "https://exampleapp.staffbase.com/api/posts/$POST/notifications" \5 -X POST \6 -H "Authorization: $AUTH" \7 -H "Content-Type: application/json; charset=UTF-8" \8 -d '{9 "email": false,10 "push": true,11 "recipients": "unread",12 "contents": {13 "en_US": {14 "text": "Custom notification text."15 },16 "de_DE": {17 "text": "Angepasster Benachrichtigungstext."18 }19 }20 }' \21 --compressed | json_pp
To resend the notifications to all users instead of users who have not yet read the post, set the recipients parameter to all.
You can manage your Campaigns with greater ease with the Staffbase APIs. Let's look at how to assign news posts to a campaign.
- You have generated an API token with editorial access or higher via the Staffbase Studio.
- Make a
GET
request to the endpoint/campaigns
to list all campaigns. Learn more about it here. - Get the
campaignID
for which you want to assign a post. - Make a
PUT
request to the endpoint/posts/{postID}
and in the request body schema, provide the value for the parametercampaignID
. Learn more about it here.