Import External Content to Pages

Learn how to import content from external sources to Pages in your Staffbase platform.

Employee App
Front Door Intranet
beta

Pages are perfect for static content that has lasting relevance or needs only occasional updates.

In this article, you will learn how to create a new page with content from an external source using the Pages API.

This is particularly useful in the following scenarios:

  • Migration

    If you're transitioning to the Staffbase platform, the Pages API streamlines the process of migrating your content. Migration may be driven by various factors, such as:

    • The need for a more robust and user-friendly platform.
    • A response to unexpected changes, like the shutdown of your current platform. For instance, organizations impacted by the shutdown of Meta’s Workplace are facing the challenge of:
      • Preserving valuable content.
      • Ensuring a smooth transition to an alternative platform.

    Staffbase offers a reliable solution, enabling you to swiftly and efficiently migrate your existing content, minimize disruptions, and maintain business continuity. Learn more about other benefits.

  • Content Creation Across Multiple Sources

    In many organizations, critical information is scattered across multiple systems. The Pages API makes it easy to centralize this content in one place. For example, absence guidelines may be maintained within your HR system but must also be accessible on your intranet to keep employees well-informed. With Staffbase, you can effortlessly import content from various sources to create a cohesive, up-to-date information hub for your team.

Prerequisites

  • You have created an API token via the Staffbase Studio. Learn more.
  • You have a token with administrative access to the spaces where you want to create the page.
  • The content you want to import is ready in HTML format.
  • You have the media files from the pages you want to migrate.

Get the spaceId

If you do not want to create the page in the All Employees space, you need to get the spaceId of the space in which you want to create the page.

  1. Make a GET request to the endpoint /space to list all spaces.

Example request

curl --location 'https://exampleapp.staffbase.com/api/spaces' \
--header 'Authorization: Basic {Token}'
  1. Find the name and Id of the space you want in the response.

You have the spaceId of the space to which you want to import the content.

Upload page images using the Media API

Before creating a page, you need to upload all the media files from the page using the Media API.

  • Make a POST request to the endpoint /media to upload the file. Learn more.

You can repeat the step until all the files on a page are uploaded to the platform server.

Create a new page and import content from the external source

  • Make a POST request to the endpoint /pages.
    In the request body schema, set the following parameters:
ParameterRequiredDescription
spaceIdNoThe unique identifier of the space in which you want to create the page. If no value is provided, by default the page is created in the All employees space.
publishedNoThe status of the page. If it is set to true the page is published and if set to false the page remains in draft state.
externalIdNoThe unique external identifier for the space. This is helpful if you want to keep the external id for log purposes during the migration.
contentsYesThe object that contains the title and body of the page and specifies the language or regional format to ensure appropriate localization. For example, en_US.
readersNoAn array of IDs that can view the page. You can add the following IDs:
  • userID: This option makes the page visible only to users whose IDs are included. To get the ID, open the respective user profile in your Intranet and copy the numerical value at the end of the URL.
  • groupID: This option makes the page visible only to users of that group. To get the ID, open the respective group in the Studio and copy the numerical value at the end of the URL.
  • branchID: This option makes the page visible to all users of your organization. To get the branchID, reach out to Staffbase Support.
You can also provide both userID and groupID together. If you do not provide any IDs, the page is not visible to any users.
adminIdsNoAn array of IDs that can manage the page.

Example request

1curl --location 'https://exampleapp.staffbase.com/api/pages' \
2--header 'Authorization: Basic {Token}' \
3--header 'Content-Type: application/json' \
4--data '{
5"spaceId": "62f3e6d25a26d63100ba8381",
6"published": true,
7"externalId": "102",
8"contents": {
9"en_US": {
10"title": "New Page",
11"content": "New page content"
12}
13},
14"readers": [
15"640b192178ed6c27b6626a8c"
16],
17"adminIds": [
18"5d1374030a09a29cde85b582"
19]
20}'
21

Example response

1{
2 "id": "66d6df9155aa961f433a6c94",
3 "createdAt": "2024-09-03T10:06:09.992Z",
4 "updatedAt": "2024-09-03T10:06:09.992Z",
5 "publishedAt": "2024-09-03T10:06:09.988Z",
6 "spaceId": "62f3e6d25a26d63100ba8382",
7 "branchId": "5afac5790a09a2503e8c7103",
8 "contents": {
9 "en_US": {
10 "title": "New Page",
11 "content": "New page content"
12 }
13 },
14 "ownerId": "65fab76b2676d333af0566a2",
15 "readers": {
16 "userIds": [
17 "640b192178ed6c27b6626a8b"
18 ],
19 "groupIds": [],
20 "tokenIds": []
21 },
22 "admins": {
23 "userIds": [
24 "5d1374030a09a29cde85b581"
25 ],
26 "groupIds": [],
27 "tokenIds": []
28 }
29}

The page is created and it is added as the last item in the menu. Learn how to arrange the order in the main menu.

To bulk trigger creation and import of content to new pages, add a function to loop through multiple POST requests to perform your request.