I have been building a site for a client and now need to migrate it to their account. How can I back up all of the content in a space and import it into another space? I have seen how you can use the content api to download json files of individual content items but that doesn’t really work for a bulk operation like this.
Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.
What are you trying to accomplish e.g. I want to integrate builder on a landing page
Screenshots or video link Screenshots of your issue, or even better a link to a video of what is happening or what you are trying to accomplish. We love using loom for that sort of thing
Code stack you are integrating Builder with e.g. NextJS, react, Shopify
Reproducible code example If you are having integration errors, please link to codesandbox or copy and paste your problematic code here. The more detail the better!
You can either use cli to clone your space and then migrate the cloned space to the client organization
Or if you prefer to use the Content API for a more automated bulk operation, you’ll need to write a script to download all content items and then upload them to the target space. Below are the general steps:
Export Content via API
Get All Content Items: Use the GET /api/v1/content endpoint to retrieve a list of all content items.
Download Content in JSON: Loop through each content item ID and download the content using the GET /api/v1/content/{model}?query={} endpoint.
Import Content via API
Create Content Items: Use the POST /api/v1/content endpoint to create new content in the target space with the downloaded JSON data.
Here is a pseudo-code example to illustrate the process:
Thanks Manish! A couple of quick additional questions:
1.) Is it possible to do this import / export with the JavaScript SDK (i.e. using the builder object)
2.) What is the recommended approach when you are talking about backing up and restoring the same space (say you had to do a roll back or something)?
Finally, I think it would be a great thing for you to add this as a formal feature for admins. Should I add it as a feature request?
I the instructions you provided to import / export worked but I am realizing that this did not export the assets in the asset library. I do however still have references to assets the old organization / space that still render. How can I do this export / import but also migrate the assets and the references to them?
Here is an example of a structured data object that had a reference to an asset that migrated but is still pointing to assets in the old instance:
To export assets from the assets library, you will need to use the upload API and then utilize the response object to update the asset links in your export body.