Skip to main content

How to export and import a translatable version of my content?

To export or import translatable versions of your content, you need to use the Storyblok management API.

Export content entry as XML

To export content entires, you need your space ID and the ID of the space, you want to export content from. Then you can make a GET request. Also, make sure you add Authorization to the header with your personal 0auth access token as the value.

Resource Information
Endpoint https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.xml?lang_code=language_code&export_lang=true
Method GET
Header Authorization:YOUR_0AUTH_TOKEN

Like this:

GET https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.xml?lang_code=language_code&export_lang=true

E.g:

axios
  .get(
     "https://mapi.storyblok.com/v1/spaces/134445/stories/86930141/export.xml?lang_code=language_code&export_lang=true",
     {
       headers: {
         Authorization: "YOUR_OAUTH_TOKEN",
       },
     }
  )
  .then((res) => console.log(res))
  .catch((err) => console.log(err));

Export content entry as JSON

Resource Information
Endpoint https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.json?lang_code=language_code&export_lang=true
Method GET
Header Authorization: YOUR_OAUTH_TOKEN

Like this:

GET https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.json?lang_code=language_code&export_lang=true

E.g:

axios
  .get(
     "https://mapi.storyblok.com/v1/spaces/134445/stories/86930141/export.json?lang_code=language_code&export_lang=true",
     {
       headers: {
         Authorization: "YOUR_OAUTH_TOKEN",
       },
     }
  )
  .then((res) => console.log(res))
  .catch((err) => console.log(err));
hint:

You can find your 0Auth token in your Storyblok user account dashboard.

Import content entry

You can either import content entries as XML or JSON. To do this, just like when exporting content entries, you need your space ID and the ID of the space, you want to import the content into. Since you’ll be updating your space, you need to make a PUT request and add Authorization to the header with your personal access token as the value. The body of the request should then contain the content you want to import in this format {"data": YOUR_IMPORT_CONTENT}. It's important to note that imported content can only be in JSON or XML format.

NOTE:

The data you’re importing must be a string. Whether it’s in XML or JSON format.

Resource Information
Endpoint https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/import.xml
Method PUT
Header Authorization: YOUR_OAUTH_TOKEN
Body {"data":YOUR_IMPORT_XML}

E.g

const xml = `<?xml version="1.0" encoding="UTF-8"?>
<page text_nodes="0" filename="building-a-food-store" url="posts/building-a-food-store" id="86930141" language="default">
  <name>Building a phone store</name>
  <tags>
    <tag id="69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:image" type="STRING">
      <text>
        <![CDATA[//a.storyblok.com/f/134445/1500x844/19eeaff370/eeacbea1-99a3-4a96-8ee9-980ae5f9dfe6.jpeg]]>
      </text>
    </tag>
    <tag id="69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:intro" type="STRING">
      <text>
        <![CDATA[phone stores are important for mankind]]>
      </text>
    </tag>
    <tag id="69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:title" type="STRING">
      <text>
        <![CDATA[Building a phone store]]>
      </text>
    </tag>
    <tag id="69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:author" type="STRING">
      <text>
        <![CDATA[cd9f7534-b437-4d3f-b23d-022f464f4cf3]]>
      </text>
    </tag>
    <tag id="69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:richtext:long_text" type="STRING">
      <text>
        <![CDATA[{"type":"doc","content":[{"type":"paragraph","content":[{"text":"this is a phone store ","type":"text"}]}]}]]>
      </text>
    </tag>
  </tags>
</page>`;

axios({
  url: "https://mapi.storyblok.com/v1/spaces/134445/stories/86930141/import.xml",
  method: "put",
  headers: {
    Authorization: "YOUR_OAUTH_TOKEN",
  },
  data: { data: xml },
});

Import content entry as JSON

Resource Information
Endpoint https://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/import.json
Method PUT
Header Authorization:YOUR_MANAGEMENT_TOKEN
Body {"data":YOUR_IMPORT_JSON}}

E.g

const json = {
    "69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:author":
      "cd9f7534-b437-4d3f-b23d-022f464f4cf3",
    "69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:image":
      "//a.storyblok.com/f/134445/1500x844/19eeaff370/eeacbea1-99a3-4a96-8ee9-980ae5f9dfe6.jpeg",
    "69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:intro":
      "iphone stores are important for mankind",
    "69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:richtext:long_text":
      '{"type":"doc","content":[{"type":"paragraph","content":[{"text":"this is a iphone store ","type":"text"}]}]}',
    "69c9f9dd-b5e5-4859-a5ee-0bf8a1319c8e:Post:title": "Building a iphone store",
    language: "default",
    page: "86930141",
    text_nodes: 0,
    url: "posts/building-a-iphone-store",
  };

axios({
  url: "https://mapi.storyblok.com/v1/spaces/134445/stories/86930141/import.json",
  method: "put",
  headers: {
    Authorization: "YOUR_OAUTH_TOKEN",
  },
  data: { data: JSON.stringify(json) },
});

Parameters for the specific language

To export/import your content in specific languages already added to your space, add the optional param ?lang_code=language_code to the endpoint.

NOTE:

You can easily import and export translatable fields of your contents using the import translatable fields and export translatable fields apps respectively. The app is available in the team plan or superior