Import a Story
https://mapi.storyblok.com/v1/spaces/:space_id/stories/:story_id/import.jsonImporting a story can be done using a PUT request for each story you want to import.
Path parameters
Section titled “Path parameters”- :space_id required number
Numeric ID of a space
- :story_id required number
The numeric id of story
Query parameters
Section titled “Query parameters”- version string
Default:
1. Possible value:1,2. - lang_code string
A language code
- import_lang boolean
It shows to import language code or not.
Request body properties
Section titled “Request body properties”- story The Story Object
A single story object
Response properties
Section titled “Response properties”- story The Story Object
A single story object
Examples
Section titled “Examples”Example Request with lang_code and import_lang
curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.json?lang_code=pt-br&import_lang=true" \ -X PUT \ -H "Authorization: YOUR_OAUTH_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"story\":{\"alternates\":[],\"breadcrumbs\":[],\"can_not_view\":null,\"content\":{\"_uid\":\"98cccd01-f807-4494-996d-c6b0de2045a5\",\"component\":\"your_content_type\"},\"created_at\":\"2023-05-29T09:53:40.231Z\",\"default_root\":null,\"deleted_at\":null,\"disble_fe_editor\":false,\"expire_at\":null,\"favourite_for_user_ids\":[],\"first_published_at\":\"2023-06-06T08:47:05.426Z\",\"full_slug\":\"home\",\"group_id\":\"fb33b858-277f-4690-81fb-e0a080bd39ac\",\"id\":314931981,\"imported_at\":\"2024-02-08T11:26:42.505Z\",\"is_folder\":false,\"is_scheduled\":null,\"is_startpage\":false,\"last_author\":{\"friendly_name\":\"Storyblok\",\"id\":39821,\"userid\":\"storyblok\"},\"localized_paths\":[{}],\"meta_data\":null,\"name\":\"Home\",\"parent\":null,\"parent_id\":0,\"path\":null,\"pinned\":false,\"position\":0,\"preview_token\":{\"timestamp\":\"1545530576\",\"token\":\"279395174a25be38b702f9ec90d08a960e1a5a84\"},\"publish_at\":null,\"published\":true,\"published_at\":\"2023-08-30T09:16:42.066Z\",\"scheduled_dates\":null,\"slug\":\"home\",\"sort_by_date\":null,\"space_role_ids\":[],\"tag_list\":[],\"translated_slugs\":[{}],\"translated_stories\":[],\"unpublished_changes\":true,\"updated_at\":\"2024-02-08T11:26:42.514Z\",\"user_ids\":[12345],\"uuid\":\"2497c493-168a-443f-bbb1-ccfd6340d319\"}}"// Using the Universal JavaScript Client:// https://github.com/storyblok/storyblok-js-clientStoryblok.put('spaces/288868932106293/stories/314931981/import.json?lang_code=pt-br&import_lang=true', { "story": { "alternates": [], "breadcrumbs": [], "can_not_view": null, "content": { "_uid": "98cccd01-f807-4494-996d-c6b0de2045a5", "component": "your_content_type" }, "created_at": "2023-05-29T09:53:40.231Z", "default_root": null, "deleted_at": null, "disble_fe_editor": false, "expire_at": null, "favourite_for_user_ids": [], "first_published_at": "2023-06-06T08:47:05.426Z", "full_slug": "home", "group_id": "fb33b858-277f-4690-81fb-e0a080bd39ac", "id": 314931981, "imported_at": "2024-02-08T11:26:42.505Z", "is_folder": false, "is_scheduled": null, "is_startpage": false, "last_author": { "friendly_name": "Storyblok", "id": 39821, "userid": "storyblok" }, "localized_paths": [ {} ], "meta_data": null, "name": "Home", "parent": null, "parent_id": 0, "path": null, "pinned": false, "position": 0, "preview_token": { "timestamp": "1545530576", "token": "279395174a25be38b702f9ec90d08a960e1a5a84" }, "publish_at": null, "published": true, "published_at": "2023-08-30T09:16:42.066Z", "scheduled_dates": null, "slug": "home", "sort_by_date": null, "space_role_ids": [], "tag_list": [], "translated_slugs": [ {} ], "translated_stories": [], "unpublished_changes": true, "updated_at": "2024-02-08T11:26:42.514Z", "user_ids": [ 12345 ], "uuid": "2497c493-168a-443f-bbb1-ccfd6340d319" }}) .then(response => { console.log(response) }).catch(error => { console.log(error) })$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$payload = ["story" => ["alternates" => [],"breadcrumbs" => [],"can_not_view" => null,"content" => ["_uid" => "98cccd01-f807-4494-996d-c6b0de2045a5","component" => "your_content_type"],"created_at" => "2023-05-29T09 => 53 => 40.231Z","default_root" => null,"deleted_at" => null,"disble_fe_editor" => false,"expire_at" => null,"favourite_for_user_ids" => [],"first_published_at" => "2023-06-06T08 => 47 => 05.426Z","full_slug" => "home","group_id" => "fb33b858-277f-4690-81fb-e0a080bd39ac","id" => 314931981,"imported_at" => "2024-02-08T11 => 26 => 42.505Z","is_folder" => false,"is_scheduled" => null,"is_startpage" => false,"last_author" => ["friendly_name" => "Storyblok","id" => 39821,"userid" => "storyblok"],"localized_paths" => [[]],"meta_data" => null,"name" => "Home","parent" => null,"parent_id" => 0,"path" => null,"pinned" => false,"position" => 0,"preview_token" => ["timestamp" => "1545530576","token" => "279395174a25be38b702f9ec90d08a960e1a5a84"],"publish_at" => null,"published" => true,"published_at" => "2023-08-30T09 => 16 => 42.066Z","scheduled_dates" => null,"slug" => "home","sort_by_date" => null,"space_role_ids" => [],"tag_list" => [],"translated_slugs" => [[]],"translated_stories" => [],"unpublished_changes" => true,"updated_at" => "2024-02-08T11 => 26 => 42.514Z","user_ids" => [12345],"uuid" => "2497c493-168a-443f-bbb1-ccfd6340d319"]];
$client->put('spaces/288868932106293/stories/314931981/import.json?lang_code=pt-br&import_lang=true', $payload)->getBody();HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.json?lang_code=pt-br&import_lang=true") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"story":{"alternates":[],"breadcrumbs":[],"can_not_view":null,"content":{"_uid":"98cccd01-f807-4494-996d-c6b0de2045a5","component":"your_content_type"},"created_at":"2023-05-29T09:53:40.231Z","default_root":null,"deleted_at":null,"disble_fe_editor":false,"expire_at":null,"favourite_for_user_ids":[],"first_published_at":"2023-06-06T08:47:05.426Z","full_slug":"home","group_id":"fb33b858-277f-4690-81fb-e0a080bd39ac","id":314931981,"imported_at":"2024-02-08T11:26:42.505Z","is_folder":false,"is_scheduled":null,"is_startpage":false,"last_author":{"friendly_name":"Storyblok","id":39821,"userid":"storyblok"},"localized_paths":[{}],"meta_data":null,"name":"Home","parent":null,"parent_id":0,"path":null,"pinned":false,"position":0,"preview_token":{"timestamp":"1545530576","token":"279395174a25be38b702f9ec90d08a960e1a5a84"},"publish_at":null,"published":true,"published_at":"2023-08-30T09:16:42.066Z","scheduled_dates":null,"slug":"home","sort_by_date":null,"space_role_ids":[],"tag_list":[],"translated_slugs":[{}],"translated_stories":[],"unpublished_changes":true,"updated_at":"2024-02-08T11:26:42.514Z","user_ids":[12345],"uuid":"2497c493-168a-443f-bbb1-ccfd6340d319"}}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.json?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", "{\"story\":{\"alternates\":[],\"breadcrumbs\":[],\"can_not_view\":null,\"content\":{\"_uid\":\"98cccd01-f807-4494-996d-c6b0de2045a5\",\"component\":\"your_content_type\"},\"created_at\":\"2023-05-29T09:53:40.231Z\",\"default_root\":null,\"deleted_at\":null,\"disble_fe_editor\":false,\"expire_at\":null,\"favourite_for_user_ids\":[],\"first_published_at\":\"2023-06-06T08:47:05.426Z\",\"full_slug\":\"home\",\"group_id\":\"fb33b858-277f-4690-81fb-e0a080bd39ac\",\"id\":314931981,\"imported_at\":\"2024-02-08T11:26:42.505Z\",\"is_folder\":false,\"is_scheduled\":null,\"is_startpage\":false,\"last_author\":{\"friendly_name\":\"Storyblok\",\"id\":39821,\"userid\":\"storyblok\"},\"localized_paths\":[{}],\"meta_data\":null,\"name\":\"Home\",\"parent\":null,\"parent_id\":0,\"path\":null,\"pinned\":false,\"position\":0,\"preview_token\":{\"timestamp\":\"1545530576\",\"token\":\"279395174a25be38b702f9ec90d08a960e1a5a84\"},\"publish_at\":null,\"published\":true,\"published_at\":\"2023-08-30T09:16:42.066Z\",\"scheduled_dates\":null,\"slug\":\"home\",\"sort_by_date\":null,\"space_role_ids\":[],\"tag_list\":[],\"translated_slugs\":[{}],\"translated_stories\":[],\"unpublished_changes\":true,\"updated_at\":\"2024-02-08T11:26:42.514Z\",\"user_ids\":[12345],\"uuid\":\"2497c493-168a-443f-bbb1-ccfd6340d319\"}}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.json"
querystring = {"lang_code":"pt-br","import_lang":"true"}
payload = {"story":{"alternates":[],"breadcrumbs":[],"can_not_view":null,"content":{"_uid":"98cccd01-f807-4494-996d-c6b0de2045a5","component":"your_content_type"},"created_at":"2023-05-29T09:53:40.231Z","default_root":null,"deleted_at":null,"disble_fe_editor":false,"expire_at":null,"favourite_for_user_ids":[],"first_published_at":"2023-06-06T08:47:05.426Z","full_slug":"home","group_id":"fb33b858-277f-4690-81fb-e0a080bd39ac","id":314931981,"imported_at":"2024-02-08T11:26:42.505Z","is_folder":false,"is_scheduled":null,"is_startpage":false,"last_author":{"friendly_name":"Storyblok","id":39821,"userid":"storyblok"},"localized_paths":[{}],"meta_data":null,"name":"Home","parent":null,"parent_id":0,"path":null,"pinned":false,"position":0,"preview_token":{"timestamp":"1545530576","token":"279395174a25be38b702f9ec90d08a960e1a5a84"},"publish_at":null,"published":true,"published_at":"2023-08-30T09:16:42.066Z","scheduled_dates":null,"slug":"home","sort_by_date":null,"space_role_ids":[],"tag_list":[],"translated_slugs":[{}],"translated_stories":[],"unpublished_changes":true,"updated_at":"2024-02-08T11:26:42.514Z","user_ids":[12345],"uuid":"2497c493-168a-443f-bbb1-ccfd6340d319"}}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 = {"story" => {"alternates" => [],"breadcrumbs" => [],"can_not_view" => null,"content" => {"_uid" => "98cccd01-f807-4494-996d-c6b0de2045a5","component" => "your_content_type"},"created_at" => "2023-05-29T09 => 53 => 40.231Z","default_root" => null,"deleted_at" => null,"disble_fe_editor" => false,"expire_at" => null,"favourite_for_user_ids" => [],"first_published_at" => "2023-06-06T08 => 47 => 05.426Z","full_slug" => "home","group_id" => "fb33b858-277f-4690-81fb-e0a080bd39ac","id" => 314931981,"imported_at" => "2024-02-08T11 => 26 => 42.505Z","is_folder" => false,"is_scheduled" => null,"is_startpage" => false,"last_author" => {"friendly_name" => "Storyblok","id" => 39821,"userid" => "storyblok"},"localized_paths" => [{}],"meta_data" => null,"name" => "Home","parent" => null,"parent_id" => 0,"path" => null,"pinned" => false,"position" => 0,"preview_token" => {"timestamp" => "1545530576","token" => "279395174a25be38b702f9ec90d08a960e1a5a84"},"publish_at" => null,"published" => true,"published_at" => "2023-08-30T09 => 16 => 42.066Z","scheduled_dates" => null,"slug" => "home","sort_by_date" => null,"space_role_ids" => [],"tag_list" => [],"translated_slugs" => [{}],"translated_stories" => [],"unpublished_changes" => true,"updated_at" => "2024-02-08T11 => 26 => 42.514Z","user_ids" => [12345],"uuid" => "2497c493-168a-443f-bbb1-ccfd6340d319"}}
client.put('spaces/288868932106293/stories/314931981/import.json', {:params => { "lang_code" => "pt-br", "import_lang" => "true"}}, payload)var request = URLRequest(url: URL(string: "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/314931981/import.json?lang_code=pt-br&import_lang=true")!)request.setValue("YOUR_OAUTH_TOKEN", forHTTPHeaderField: "Authorization")request.httpMethod = "PUT"request.httpBody = try JSONSerialization.data(withJSONObject: [ "story": [ "alternates": [ ], "breadcrumbs": [ ], "can_not_view": nil, "content": [ "_uid": "98cccd01-f807-4494-996d-c6b0de2045a5", "component": "your_content_type", ], "created_at": "2023-05-29T09:53:40.231Z", "default_root": nil, "deleted_at": nil, "disble_fe_editor": false, "expire_at": nil, "favourite_for_user_ids": [ ], "first_published_at": "2023-06-06T08:47:05.426Z", "full_slug": "home", "group_id": "fb33b858-277f-4690-81fb-e0a080bd39ac", "id": 314931981, "imported_at": "2024-02-08T11:26:42.505Z", "is_folder": false, "is_scheduled": nil, "is_startpage": false, "last_author": [ "friendly_name": "Storyblok", "id": 39821, "userid": "storyblok", ], "localized_paths": [ [ ], ], "meta_data": nil, "name": "Home", "parent": nil, "parent_id": 0, "path": nil, "pinned": false, "position": 0, "preview_token": [ "timestamp": "1545530576", "token": "279395174a25be38b702f9ec90d08a960e1a5a84", ], "publish_at": nil, "published": true, "published_at": "2023-08-30T09:16:42.066Z", "scheduled_dates": nil, "slug": "home", "sort_by_date": nil, "space_role_ids": [ ], "tag_list": [ ], "translated_slugs": [ [ ], ], "translated_stories": [ ], "unpublished_changes": true, "updated_at": "2024-02-08T11:26:42.514Z", "user_ids": [ 12345, ], "uuid": "2497c493-168a-443f-bbb1-ccfd6340d319", ],])let (data, _) = try await URLSession.shared.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(ContentNegotiation) { json() } install(DefaultRequest) { url { takeFrom("https://mapi.storyblok.com/v1/") headers.append("Authorization", "YOUR_OAUTH_TOKEN") } }}
val response = client.put("spaces/288868932106293/stories/314931981/import.json") { url { parameters.append("lang_code", "pt-br") parameters.append("import_lang", "true") } contentType(ContentType.Application.Json) setBody(buildJsonObject { putJsonObject("story") { putJsonArray("alternates") { } putJsonArray("breadcrumbs") { } put("can_not_view", null) putJsonObject("content") { put("_uid", "98cccd01-f807-4494-996d-c6b0de2045a5") put("component", "your_content_type") } put("created_at", "2023-05-29T09:53:40.231Z") put("default_root", null) put("deleted_at", null) put("disble_fe_editor", false) put("expire_at", null) putJsonArray("favourite_for_user_ids") { } put("first_published_at", "2023-06-06T08:47:05.426Z") put("full_slug", "home") put("group_id", "fb33b858-277f-4690-81fb-e0a080bd39ac") put("id", 314931981) put("imported_at", "2024-02-08T11:26:42.505Z") put("is_folder", false) put("is_scheduled", null) put("is_startpage", false) putJsonObject("last_author") { put("friendly_name", "Storyblok") put("id", 39821) put("userid", "storyblok") } putJsonArray("localized_paths") { addJsonObject { } } put("meta_data", null) put("name", "Home") put("parent", null) put("parent_id", 0) put("path", null) put("pinned", false) put("position", 0) putJsonObject("preview_token") { put("timestamp", "1545530576") put("token", "279395174a25be38b702f9ec90d08a960e1a5a84") } put("publish_at", null) put("published", true) put("published_at", "2023-08-30T09:16:42.066Z") put("scheduled_dates", null) put("slug", "home") put("sort_by_date", null) putJsonArray("space_role_ids") { } putJsonArray("tag_list") { } putJsonArray("translated_slugs") { addJsonObject { } } putJsonArray("translated_stories") { } put("unpublished_changes", true) put("updated_at", "2024-02-08T11:26:42.514Z") putJsonArray("user_ids") { add(12345) } put("uuid", "2497c493-168a-443f-bbb1-ccfd6340d319") } })}
println(response.body<JsonElement>())When using the import endpoint with version 2 data, stories no longer need to be stringified. Simply use the exported stories from v2 as-is to ensure compatibility with the updated structure.
Get in touch with the Storyblok community