Exporting and importing data using the Contensis CLI
Log in to add to favouritesNavigate to your working directory
Before running the Contensis CLI, it's best to navigate to a directory where you can easily access and manage your files, such as your Desktop or Documents folder. Open a terminal and move to your desired directory:
cd /Desktop  # or /Documents
This ensures that exported files are easy to find and manage. Once in your chosen directory, you can run the Contensis CLI using:
contensis
Export data from Contensis
To make bulk edits, first export your existing data from Contensis using the CLI. This command retrieves entries using ZenQL and saves them in CSV format:
get entries --zenql "sys.contentTypeId = staff" --fields entryTitle, jobTitle, emailAddress, linkedIn, sys.id, sys.contentTypeId, sys.dataFormat, sys.language --output ./staff.csv --format csv
Lets upload this sheet to Google Sheets and edit our @LinkedIn
field data. Once we have updated our data, we can export this as a CSV file.

sys.id
sys.contentTypeId
sys.language
sys.dataFormat
This ensures that the sys
object in your imported data looks something like this:
"sys": {
"id": "6b3c63d9-fcda-41ac-9c72-5f9af7ed466b",
"contentTypeId": "staff",
"language": "en-GB",
"dataFormat": "entry"
}
Import data using the Contensis CLI
Use the CLI to import your CSV data. To view available import commands, run:
contensis import --help
contensis import entries --from-file updated-staff.csv --preserve-guids
This will render a preview of the changes for you to review:

Commit the changes
If everything looks good in the preview, commit the changes:
contensis import entries --from-file updated-staff.csv --preserve-guids --commit
Once the changes have been successfully committed, a confirmation will be displayed in the terminal:

The imported entries will then be available in your Contensis project. They will be stored in the Draft state until you are ready to publish them:

Conclusion
By following these steps, you can efficiently export and import data in Contensis CMS using the CLI. This process ensures data integrity and prevents duplication while streamlining large updates.
Troubleshooting
Need help setting up the Contensis CLI? Check out this article here.