Examples: Export/Import a story (XML)
Basic export
Section titled “Basic export”Export a story without any parameters.
curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml" \ -H "Authorization: YOUR_OAUTH_TOKEN"// storyblok-js-client@>=7, node@>=18import Storyblok from "storyblok-js-client";
const storyblok = new Storyblok({ oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",});
try { const response = await storyblok.get('spaces/288868932106293/stories/314931981/export.xml', {}) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$client->get('spaces/288868932106293/stories/314931981/export.xml')->getBody();HttpResponse<String> response = Unirest.get("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml") .header("Authorization", "YOUR_OAUTH_TOKEN") .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml");var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml"
querystring = {}
payload = ""headers = { 'Authorization': "YOUR_OAUTH_TOKEN"}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
client.get('spaces/288868932106293/stories/314931981/export.xml')let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))let request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/314931981/export.xml")let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") }}
val response = client.get("spaces/288868932106293/stories/314931981/export.xml")
println(response.body<JsonElement>())<?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 translated content
Section titled “Export translated content”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"// storyblok-js-client@>=7, node@>=18import Storyblok from "storyblok-js-client";
const storyblok = new Storyblok({ oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",});
try { const response = await storyblok.get('spaces/288868932106293/stories/314931981/export.xml', { "lang_code": "it", "export_lang": "true"}) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$client->get('spaces/288868932106293/stories/314931981/export.xml', [ "lang_code" => "it", "export_lang" => "true"])->getBody();HttpResponse<String> response = Unirest.get("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml?lang_code=it&export_lang=true") .header("Authorization", "YOUR_OAUTH_TOKEN") .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml?lang_code=it&export_lang=true");var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml"
querystring = {"lang_code":"it","export_lang":"true"}
payload = ""headers = { 'Authorization': "YOUR_OAUTH_TOKEN"}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
client.get('spaces/288868932106293/stories/314931981/export.xml', {:params => { "lang_code" => "it", "export_lang" => "true"}})let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/314931981/export.xml")request.url!.append(queryItems: [ URLQueryItem(name: "lang_code", value: "it"), URLQueryItem(name: "export_lang", value: "true")])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") }}
val response = client.get("spaces/288868932106293/stories/314931981/export.xml") { url { parameters.append("lang_code", "it") parameters.append("export_lang", "true") }}
println(response.body<JsonElement>())<?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"// storyblok-js-client@>=7, node@>=18import Storyblok from "storyblok-js-client";
const storyblok = new Storyblok({ oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",});
try { const response = await storyblok.get('spaces/288868932106293/stories/314931981/export.xml', { "lang_code": "pt-br", "export_lang": "true", "version": "1"}) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$client->get('spaces/288868932106293/stories/314931981/export.xml', [ "lang_code" => "pt-br", "export_lang" => "true", "version" => "1"])->getBody();HttpResponse<String> response = Unirest.get("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml?lang_code=pt-br&export_lang=true&version=1") .header("Authorization", "YOUR_OAUTH_TOKEN") .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml?lang_code=pt-br&export_lang=true&version=1");var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/export.xml"
querystring = {"lang_code":"pt-br","export_lang":"true","version":"1"}
payload = ""headers = { 'Authorization': "YOUR_OAUTH_TOKEN"}
response = requests.request("GET", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
client.get('spaces/288868932106293/stories/314931981/export.xml', {:params => { "lang_code" => "pt-br", "export_lang" => "true", "version" => "1"}})let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/314931981/export.xml")request.url!.append(queryItems: [ URLQueryItem(name: "lang_code", value: "pt-br"), URLQueryItem(name: "export_lang", value: "true"), URLQueryItem(name: "version", value: "1")])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") }}
val response = client.get("spaces/288868932106293/stories/314931981/export.xml") { url { parameters.append("lang_code", "pt-br") parameters.append("export_lang", "true") parameters.append("version", "1") }}
println(response.body<JsonElement>())<?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>Basic import
Section titled “Basic import”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>\"}"// storyblok-js-client@>=7, node@>=18import Storyblok from "storyblok-js-client";
const storyblok = new Storyblok({ oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",});
try { const response = await storyblok.put('spaces/288868932106293/stories/314931981/import.xml', { "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>"}) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$payload = ["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>"];
$client->put('spaces/288868932106293/stories/314931981/import.xml', $payload)->getBody();HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"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>"}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml");var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");request.AddParameter("application/json", "{\"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>\"}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml"
querystring = {}
payload = {"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>"}headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN"}
response = requests.request("PUT", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
payload = {"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>"}
client.put('spaces/288868932106293/stories/314931981/import.xml', payload)let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/314931981/import.xml")request.httpMethod = "PUT"request.httpBody = try JSONSerialization.data(withJSONObject: [ "data": "<?xml version="1.0" encoding="UTF-8"?><page text_nodes="0" filename="home" url="home" id="314931981" language="default"><name>Home</name><tags> <tag id="ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:title" type="STRING"> <text><![CDATA[Home Page Title]]></text> </tag></tags></page>",])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") }}
val response = client.put("spaces/288868932106293/stories/314931981/import.xml") { setBody(buildJsonObject { put("data", "<?xml version="1.0" encoding="UTF-8"?><page text_nodes="0" filename="home" url="home" id="314931981" language="default"><name>Home</name><tags> <tag id="ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:title" type="STRING"> <text><![CDATA[Home Page Title]]></text> </tag></tags></page>") })}
println(response.body<JsonElement>())Import translated content
Section titled “Import translated content”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>\"}"// storyblok-js-client@>=7, node@>=18import Storyblok from "storyblok-js-client";
const storyblok = new Storyblok({ oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",});
try { const response = await storyblok.put('spaces/288868932106293/stories/314931981/import.xml?lang_code=pt-br&import_lang=true', { "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>"}) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$payload = ["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>"];
$client->put('spaces/288868932106293/stories/314931981/import.xml?lang_code=pt-br&import_lang=true', $payload)->getBody();HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml?lang_code=pt-br&import_lang=true") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"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>"}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml?lang_code=pt-br&import_lang=true");var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");request.AddParameter("application/json", "{\"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>\"}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml"
querystring = {"lang_code":"pt-br","import_lang":"true"}
payload = {"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>"}headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN"}
response = requests.request("PUT", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
payload = {"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>"}
client.put('spaces/288868932106293/stories/314931981/import.xml', {:params => { "lang_code" => "pt-br", "import_lang" => "true"}}, payload)let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/314931981/import.xml")request.url!.append(queryItems: [ URLQueryItem(name: "lang_code", value: "pt-br"), URLQueryItem(name: "import_lang", value: "true")])request.httpMethod = "PUT"request.httpBody = try JSONSerialization.data(withJSONObject: [ "data": "<?xml version="1.0" encoding="UTF-8"?><page text_nodes="0" filename="home" url="home" id="314931981" language="pt-br"><name>Home</name><tags> <tag id="ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:title" type="STRING"> <text><![CDATA[Título traduzido]]></text> </tag> <tag id="ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:subtitle" type="STRING"> <text><![CDATA[Subtítulo traduzido]]></text> </tag></tags></page>",])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") }}
val response = client.put("spaces/288868932106293/stories/314931981/import.xml") { url { parameters.append("lang_code", "pt-br") parameters.append("import_lang", "true") } setBody(buildJsonObject { put("data", "<?xml version="1.0" encoding="UTF-8"?><page text_nodes="0" filename="home" url="home" id="314931981" language="pt-br"><name>Home</name><tags> <tag id="ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:title" type="STRING"> <text><![CDATA[Título traduzido]]></text> </tag> <tag id="ebf2eb36-2a3b-4231-b039-7a64178f50c2:feature:subtitle" type="STRING"> <text><![CDATA[Subtítulo traduzido]]></text> </tag></tags></page>") })}
println(response.body<JsonElement>())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>\"}"// storyblok-js-client@>=7, node@>=18import Storyblok from "storyblok-js-client";
const storyblok = new Storyblok({ oauthToken: "YOUR_PERSONAL_ACCESS_TOKEN",});
try { const response = await storyblok.put('spaces/288868932106293/stories/314931981/import.xml?version=1', { "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>"}) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$payload = ["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>"];
$client->put('spaces/288868932106293/stories/314931981/import.xml?version=1', $payload)->getBody();HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml?version=1") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"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>"}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml?version=1");var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");request.AddParameter("application/json", "{\"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>\"}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.xml"
querystring = {"version":"1"}
payload = {"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>"}headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN"}
response = requests.request("PUT", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
payload = {"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>"}
client.put('spaces/288868932106293/stories/314931981/import.xml', {:params => { "version" => "1"}}, payload)let storyblok = URLSession(storyblok: .mapi(accessToken: .oauth("YOUR_OAUTH_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/314931981/import.xml")request.url!.append(queryItems: [ URLQueryItem(name: "version", value: "1")])request.httpMethod = "PUT"request.httpBody = try JSONSerialization.data(withJSONObject: [ "data": "<?xml version="1.0" encoding="UTF-8"?><page filename="home" id="314931981" language="default"><name>Home</name><tags> <tag id="richtext" type="STRING"> <text><![CDATA[{"type":"doc","content":[{"type":"paragraph","content":[{"text":"Example richtext content.","type":"text"}]}]}]]></text> </tag></tags></page>",])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = OAuth("YOUR_OAUTH_TOKEN") }}
val response = client.put("spaces/288868932106293/stories/314931981/import.xml") { url { parameters.append("version", "1") } setBody(buildJsonObject { put("data", "<?xml version="1.0" encoding="UTF-8"?><page filename="home" id="314931981" language="default"><name>Home</name><tags> <tag id="richtext" type="STRING"> <text><![CDATA[{"type":"doc","content":[{"type":"paragraph","content":[{"text":"Example richtext content.","type":"text"}]}]}]]></text> </tag></tags></page>") })}
println(response.body<JsonElement>())Was this page helpful?
This site uses reCAPTCHA and Google's Privacy Policy (opens in a new window) . Terms of Service (opens in a new window) apply.
Get in touch with the Storyblok community