Skip to content

Examples: Export/Import a story (XML)

Export a story without any parameters.

curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml" \
-H "Authorization: YOUR_OAUTH_TOKEN"
Example response
<?xml version="1.0" encoding="UTF-8"?>
<page text_nodes="0" filename="mcp-and-the-rise-of-ai-agents" url="mp/mcp-and-the-rise-of-ai-agents" id="64181051491446" language="default">
<name>MCP and the Rise of AI Agents</name>
<tags>
<tag id="1e4438f0-2693-45f5-b3ef-685169281d86:custom_richtext:@richtext:richtext/content[0:heading].content[0].text" type="STRING">
<text>
<![CDATA[Introduction]]>
</text>
</tag>
<tag id="1e4438f0-2693-45f5-b3ef-685169281d86:custom_richtext:@richtext:richtext/content[1:paragraph].content[0].text" type="STRING">
<text>
<![CDATA[Watch any software company's annual conference, and you'd be surprised if the words "Artificial Intelligence" are not used at least 15 times. We are well into the AI Era, with LLM applications such as ChatGPT having deep penetration for all sorts of use cases. Large Language Models can act like good companions in the Context of a CMS, helping write first drafts and summarize research. However, the true potential of AI lies in deep integrations with your publishing stack, having a reliable way to pass context back and forth. LLMs like ChatGPT are powerful, but they're not connected. You can't ask them to fetch CMS content, run analytics, or understand your brand tone unless you set it all up manually. That's where MCPs and AI agents come in.]]>
</text>
</tag>
<tag id="1e4438f0-2693-45f5-b3ef-685169281d86:custom_richtext:@richtext:richtext/content[2:heading].content[0].text" type="STRING">
<text>
<![CDATA[MCP - a quick refresher]]>
</text>
</tag>
</tags>
</page>

Export a specific language version of a story. Use export_lang=true to export the translated values for the specified lang_code. If export_lang is false or omitted, the default language values will be exported.

curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml\
?lang_code=it\
&export_lang=true" \
-H "Authorization: YOUR_OAUTH_TOKEN"
Example response with translated content
<?xml version="1.0" encoding="UTF-8"?>
<page text_nodes="0" filename="mcp-and-the-rise-of-ai-agents" url="mp/mcp-and-the-rise-of-ai-agents" id="64181051491446" language="default">
<name>MCP and the Rise of AI Agents</name>
<tags>
<tag id="1e4438f0-2693-45f5-b3ef-685169281d86:custom_richtext:@richtext:richtext/content[0:heading].content[0].text" type="STRING">
<text>
<![CDATA[Introduction]]>
</text>
</tag>
<tag id="1e4438f0-2693-45f5-b3ef-685169281d86:custom_richtext:@richtext:richtext/content[1:paragraph].content[0].text" type="STRING">
<text>
<![CDATA[Guarda qualsiasi conferenza annuale di un'azienda di software e potresti sorprenderti se le parole "Intelligenza Artificiale" non vengono usate almeno 15 volte. Siamo profondamente entrati nell'Era dell'AI, con applicazioni di LLM come ChatGPT che hanno raggiunto una penetrazione significativa in vari casi d'uso. I Modelli di Linguaggio di Grandi Dimensioni possono agire come buoni compagni nel contesto di un sistema di gestione dei contenuti, aiutando a scrivere le prime bozze e a riassumere ricerche. Tuttavia, il vero potenziale dell'AI risiede nelle integrazioni profonde con il tuo sistema di pubblicazione, offrendo un modo affidabile per scambiare contesto. I LLM come ChatGPT sono potenti, ma non sono connessi. Non puoi chiedergli di recuperare contenuti dal sistema di gestione, eseguire analisi o comprendere il tono del tuo marchio a meno che non lo configuri manualmente. È qui che entrano in gioco i MCP e gli agenti AI.]]>
</text>
</tag>
<tag id="1e4438f0-2693-45f5-b3ef-685169281d86:custom_richtext:@richtext:richtext/content[2:heading].content[0].text" type="STRING">
<text>
<![CDATA[MCP - a quick refresher]]>
</text>
</tag>
</tags>
</page>

Previous version of the export API endpoint

Section titled “Previous version of the export API endpoint”

In the current version (version 2), rich text is expanded into separate <tag> elements with path-based id attributes and plain text in <text><![CDATA[...]]></text>.

Set version=1 to use the previous version of this API endpoint, in which rich text is exported as a single <tag id="richtext">, containing the rich text data as a stringified JSON inside CDATA.

curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml\
?lang_code=pt-br\
&export_lang=true\
&version=1" \
-H "Authorization: YOUR_OAUTH_TOKEN"
Example Version 1 response
<?xml version="1.0" encoding="UTF-8"?>
<page filename="mcp-and-the-rise-of-ai-agents" id="64181051491446" language="default">
<name>MCP and the Rise of AI Agents</name>
<tags>
<tag id="richtext" type="STRING">
<text>
<![CDATA[{"type":"doc","content":[{"type":"heading","attrs":{"level":2},"content":[{"text":"Introduction","type":"text"}]},{"type":"paragraph","content":[{"text":"This is an example of a version one XML export with richtext content stringified as JSON.","type":"text"}]}]}]]>
</text>
</tag>
</tags>
</page>

Import a story by sending data as a stringified JSON object with the structure documented in the Export a Story (XML) endpoint.

curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml" \
-X PUT \
-H "Authorization: YOUR_OAUTH_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"data\":\"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\n<page text_nodes=\\"0\\" filename=\\"home\\" url=\\"home\\" id=\\"314931981\\" language=\\"default\\">\n<name>Home</name>\n<tags>\n <tag id=\\"ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:title\\" type=\\"STRING\\">\n <text><![CDATA[Home Page Title]]></text>\n </tag>\n</tags>\n</page>\"}"

Import translated content for a specific language using the lang_code and import_lang parameters.

curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml\
?lang_code=pt-br\
&import_lang=true" \
-X PUT \
-H "Authorization: YOUR_OAUTH_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"data\":\"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\n<page text_nodes=\\"0\\" filename=\\"home\\" url=\\"home\\" id=\\"314931981\\" language=\\"pt-br\\">\n<name>Home</name>\n<tags>\n <tag id=\\"ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:title\\" type=\\"STRING\\">\n <text><![CDATA[Título traduzido]]></text>\n </tag>\n <tag id=\\"ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:subtitle\\" type=\\"STRING\\">\n <text><![CDATA[Subtítulo traduzido]]></text>\n </tag>\n</tags>\n</page>\"}"

Previous version of the import API endpoint

Section titled “Previous version of the import API endpoint”

With version=1, data must be an XML string with a single <tag id="richtext"> containing the rich text data as a stringified JSON inside CDATA.

curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml\
?version=1" \
-X PUT \
-H "Authorization: YOUR_OAUTH_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"data\":\"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\n<page filename=\\"home\\" id=\\"314931981\\" language=\\"default\\">\n<name>Home</name>\n<tags>\n <tag id=\\"richtext\\" type=\\"STRING\\">\n <text><![CDATA[{\\"type\\":\\"doc\\",\\"content\\":[{\\"type\\":\\"paragraph\\",\\"content\\":[{\\"text\\":\\"Example richtext content.\\",\\"type\\":\\"text\\"}]}]}]]></text>\n </tag>\n</tags>\n</page>\"}"

Was this page helpful?

What went wrong?

This site uses reCAPTCHA and Google's Privacy Policy (opens in a new window) . Terms of Service (opens in a new window) apply.