- Create an automation client
Content Transfer API (v1.0)
The Content Transfer REST API allows SitecoreAI Organization Admins and Organization Owners to initiate, monitor, and finalize content transfer operations for migrating content data from one SitecoreAI environment (the source) to another (the destination). This enables efficient transfer of data between environments using chunked data streaming with encryption and compression support.
Each transfer operation includes at least one set of chunked data, where each chunk set represents a single data tree that was nominated for transfer. When an operation is complete, each of its chunk sets will be represented by a .raif file in the destination environment. To finish integrating the transferred data, use the separate Item Transfer API to have the destination database consume the .raif files.
Note the following:
- To use this REST API, you must authorize your API requests.
- You must be an Organization Admin or Organization Owner to use this API.
- Different endpoints in this API are called against different environments. You will switch between a source base URL and a destination base URL depending on the step in the workflow. Each endpoint description specifies which environment to use.
Note: If you previously used the Package Designer for content migrations, review the differences between the designer and the modern API-based approach.
The Content Transfer API covers the source side of a content migration. After completing the steps in this API, use the Item Transfer API to incorporate the transferred data into the destination database.
In your source environment, create a content transfer operation using a unique transfer ID of your choice. For each item you want to transfer, specify the item path, whether to include descendants, and how to handle conflicts with existing items in the destination. Depending on how much data is being transferred, the operation creates one or more chunk sets.
Ensure that the item's parent chain already exists in the destination environment with the same item IDs. If it does not, the item will transfer successfully but will not appear in the content tree. To avoid this, transfer from a common ancestor using Scope: ItemAndDescendants, or transfer the parent items first.
Poll the operation details in your source environment until State is Completed. If State is Failed, create a new transfer operation. For each chunk set in the response, record the ChunkSetId and ChunkCount because you'll need them to retrieve and save the chunks.
For each chunk set, repeat the following for every chunk in the set:
- In your source environment, retrieve the chunk. Make one request per chunk, using
chunkIdvalues0throughChunkCount - 1. Note theIsMediavalue from theContent-Dispositionresponse header because you'll need it when saving the chunk. You can retrieve multiple chunks in parallel. - In your destination environment, save the chunk, forwarding the binary stream exactly as received without modification. You can save chunks in parallel with retrieval, but every chunk must be saved before completing the chunk set.
After all chunks in a set are saved, complete the chunk set in your destination environment. This generates a .raif file and returns its name. Record the name for use in the Item Transfer API. Repeat for every chunk set in the operation.
Delete the transfer operation from your source environment to clean up all associated resources. You can do this immediately after downloading all chunks from the source environment.
Proceed to the Item Transfer API to incorporate the .raif files into the destination database.
In the base URL, replace {host} with your environment host name. You need two base URLs: one for your source environment (where you're migrating data from) and one for your destination environment (where you're migrating data to). You will switch between them as you follow the migration workflow.
Find the environment host name in SitecoreAI Deploy > Projects > your project > Authoring environments > your environment > Details > Environment host name.
Example environment host name: your-environment.sitecorecloud.io
To authorize your requests, use environment automation client credentials and generate a JSON Web Token (JWT).
Note: To create client credentials, you must be an Organization Admin or Organization Owner.
- In the Sitecore Cloud Portal, open SitecoreAI Deploy.
- Click Credentials > Environment > Create credentials > Automation.
- Fill out the automation client details, then click Create.
- Copy the client ID and the client secret because you won't be able to view them again in SitecoreAI Deploy. You'll use them to request a JWT.
Run the following cURL command to request a JWT. Replace the placeholder values with your client ID and client secret.
curl -X POST 'https://auth.sitecorecloud.io/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'client_id={YOUR_CLIENT_ID}' \
--data-urlencode 'client_secret={YOUR_CLIENT_SECRET}' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'audience=https://api.sitecorecloud.io'The JWT expires in 24 hours. If your requests unexpectedly return a response with status 403 Forbidden, request a new JWT by repeating this POST request.
We recommend that you cache the JWT for 24 hours to avoid repeating this POST request while the JWT is still valid.