Learn how to sync and update the data of a subset of users using the (New) CSV Import API.
CSV Imports is one of the easiest ways to import and sync user data into the Staffbase platform. Using the (new) CSV Import API makes it even easier to automate data syncs and keep your constantly evolving user database up to date.
In this article, we’ll look at how to do a delta import using the (new) CSV Import API.
Delta import refers to imports that sync and update only a subset of your user base. This can be very useful in different scenarios. If you want to offboard users using delta imports, by deactivating or deleting their accounts, you need to specify the intended user status in the CSV file. To do this, you can add a column called Status_code in your CSV file and populate each user’s account status. For information on setting up the file, see the examples. You can add the following account statuses for users:
During the delta import, if deactivated status is added for:
The delta imports are different from the legacy partial imports. You do not need partial import CSV tags. All user data changes only if the changes are included explicitly. This gives delta imports more flexibility over the legacy partial imports.
For example:
In all of the above cases, if you do not use the delta import and update all users, the import deactivates active users and deletes pending users who are not in the CSV file.
The process of performing an automated CSV import in a nutshell.
POST
request to /users/imports/
.PUT
request to /users/imports/{importId}/config/
.PATCH
request to /users/imports/{importId}
with state parameter set to PREVIEW_PENDING
.PATCH
request to /users/imports/{importId}
.
with state parameter set to IMPORT_PENDING
.Make a POST
request to the endpoint /users/imports
with the path of the CSV file in your local computer.
The following cURL command uploads a new CSV file from your local computer to your Staffbase platform.
Your CSV file is uploaded to the Staffbase platform. You can view it in the overview page of the Staffbase Studio.
In the response header, you can see the location URL of the imported file.
For example, https://exampleapp.staffbase.com/api/users/imports/660e76a12487882f89a095b4e
You can save the id from the response. In this case, 660e76a12487882f89a095b4e.
This id is the importId required for further steps.
Do the following to map the CSV attributes to the Staffbase Studio profile fields:
GET
request to the endpoint /users/imports
.importId
required in the next step.If there are multiple imports, you can identify the import you want based on the following parameters:
PUT
request to the endpoint /users/imports/{importId}/config/
, with delta
parameter set to true
.status
parameter to the Status_code column of your CSV file only if you want to add or update user data using the delta import. You can map one column from your CSV file to multiple profile fields. For example, externalId,userName
maps the identifier and username based on the same column.
See CSV Import error list to help you analyze your CSV import and get more information on potential warning and error codes.
After configuring the mapping, you can preview the file.
Make a PATCH
request to the endpoint /users/imports/{importId}
, with state parameter set to IMPORT_PENDING
.
You can now schedule the imports and updates based on your business requirements using this CSV import workflow. You can use any scheduling tool of your choice. For example, if you’re using the cURL command-line for Unix or Linux, you can use the cron job command for scheduling.