Create and Manage Folders
https://mapi.storyblok.com/v1/spaces/:space_id/storiesUse the Story endpoint to create and manage content folders.
You can use a small subset of properties from the Story Object to push new folders into your space or modify their configurations:
- Use
nameandslugto identify the folder. - Always pass
trueto theis_folderin the Request Body. - Use
parent_idto determine where the folder should be created. - You can also update existent folders to accept only specific content types.
Check the request examples in this section.
Path parameters
Section titled “Path parameters”:space_idrequired numberNumeric ID of a space
:story_idnumberNumeric ID of a story. Required to update an existing folder.
Request body properties
Section titled “Request body properties”storyThe Story ObjectA single story object
Response properties
Section titled “Response properties”storyThe Story ObjectA single story object
Examples
Section titled “Examples”Create a new folder within your Space.
curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories" \ -X POST \ -H "Authorization: YOUR_PERSONAL_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"story\":{\"is_folder\":true,\"name\":\"A new folder\",\"parent_id\":0,\"slug\":\"a-new-folder\"}}"// 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.post('spaces/288868932106293/stories', { "story": { "is_folder": true, "name": "A new folder", "parent_id": 0, "slug": "a-new-folder" } }) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_PERSONAL_ACCESS_TOKEN');
$payload = ["story" => ["is_folder" => true,"name" => "A new folder","parent_id" => 0,"slug" => "a-new-folder"]];
$client->post('spaces/288868932106293/stories', $payload)->getBody();HttpResponse<String> response = Unirest.post("https://mapi.storyblok.com/v1/spaces/288868932106293/stories") .header("Content-Type", "application/json") .header("Authorization", "YOUR_PERSONAL_ACCESS_TOKEN") .body({"story":{"is_folder":true,"name":"A new folder","parent_id":0,"slug":"a-new-folder"}}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories");var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");request.AddHeader("Authorization", "YOUR_PERSONAL_ACCESS_TOKEN");request.AddParameter("application/json", "{\"story\":{\"is_folder\":true,\"name\":\"A new folder\",\"parent_id\":0,\"slug\":\"a-new-folder\"}}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories"
querystring = {}
payload = {"story":{"is_folder":true,"name":"A new folder","parent_id":0,"slug":"a-new-folder"}}headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_PERSONAL_ACCESS_TOKEN"}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_PERSONAL_ACCESS_TOKEN')
payload = {"story" => {"is_folder" => true,"name" => "A new folder","parent_id" => 0,"slug" => "a-new-folder"}}
client.post('spaces/288868932106293/stories', payload)let storyblok = URLSession(storyblok: .mapi(accessToken: .personal("YOUR_PERSONAL_ACCESS_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories")request.httpMethod = "POST"request.httpBody = try JSONSerialization.data(withJSONObject: [ "story": [ "is_folder": true, "name": "A new folder", "parent_id": 0, "slug": "a-new-folder", ],])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = Personal("YOUR_PERSONAL_ACCESS_TOKEN") }}
val response = client.post("spaces/288868932106293/stories") { setBody(buildJsonObject { putJsonObject("story") { put("is_folder", true) put("name", "A new folder") put("parent_id", 0) put("slug", "a-new-folder") } })}
println(response.body<JsonElement>())Create a folder to accept only a certain content type using the default_root property.
curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories" \ -X POST \ -H "Authorization: YOUR_PERSONAL_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"story\":{\"default_root\":\"article\",\"is_folder\":true,\"name\":\"A new folder\",\"parent_id\":0,\"slug\":\"a-new-folder\"}}"// 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.post('spaces/288868932106293/stories', { "story": { "default_root": "article", "is_folder": true, "name": "A new folder", "parent_id": 0, "slug": "a-new-folder" } }) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_PERSONAL_ACCESS_TOKEN');
$payload = ["story" => ["default_root" => "article","is_folder" => true,"name" => "A new folder","parent_id" => 0,"slug" => "a-new-folder"]];
$client->post('spaces/288868932106293/stories', $payload)->getBody();HttpResponse<String> response = Unirest.post("https://mapi.storyblok.com/v1/spaces/288868932106293/stories") .header("Content-Type", "application/json") .header("Authorization", "YOUR_PERSONAL_ACCESS_TOKEN") .body({"story":{"default_root":"article","is_folder":true,"name":"A new folder","parent_id":0,"slug":"a-new-folder"}}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories");var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");request.AddHeader("Authorization", "YOUR_PERSONAL_ACCESS_TOKEN");request.AddParameter("application/json", "{\"story\":{\"default_root\":\"article\",\"is_folder\":true,\"name\":\"A new folder\",\"parent_id\":0,\"slug\":\"a-new-folder\"}}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories"
querystring = {}
payload = {"story":{"default_root":"article","is_folder":true,"name":"A new folder","parent_id":0,"slug":"a-new-folder"}}headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_PERSONAL_ACCESS_TOKEN"}
response = requests.request("POST", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_PERSONAL_ACCESS_TOKEN')
payload = {"story" => {"default_root" => "article","is_folder" => true,"name" => "A new folder","parent_id" => 0,"slug" => "a-new-folder"}}
client.post('spaces/288868932106293/stories', payload)let storyblok = URLSession(storyblok: .mapi(accessToken: .personal("YOUR_PERSONAL_ACCESS_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories")request.httpMethod = "POST"request.httpBody = try JSONSerialization.data(withJSONObject: [ "story": [ "default_root": "article", "is_folder": true, "name": "A new folder", "parent_id": 0, "slug": "a-new-folder", ],])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = Personal("YOUR_PERSONAL_ACCESS_TOKEN") }}
val response = client.post("spaces/288868932106293/stories") { setBody(buildJsonObject { putJsonObject("story") { put("default_root", "article") put("is_folder", true) put("name", "A new folder") put("parent_id", 0) put("slug", "a-new-folder") } })}
println(response.body<JsonElement>())Update a folder with strict content types. Pass the folder ID as the :story_id path parameter.
curl "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/182794698822337" \ -X PUT \ -H "Authorization: YOUR_PERSONAL_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"story\":{\"content\":{\"content_types\":[\"category\"],\"lock_subfolders_content_types\":false},\"is_folder\":true,\"name\":\"Categories\",\"parent_id\":0,\"slug\":\"categories\"}}"// 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/182794698822337', { "story": { "content": { "content_types": [ "category" ], "lock_subfolders_content_types": false }, "is_folder": true, "name": "Categories", "parent_id": 0, "slug": "categories" } }) console.log({ response })} catch (error) { console.log(error)}$client = new \Storyblok\ManagementClient('YOUR_PERSONAL_ACCESS_TOKEN');
$payload = ["story" => ["content" => ["content_types" => ["category"],"lock_subfolders_content_types" => false],"is_folder" => true,"name" => "Categories","parent_id" => 0,"slug" => "categories"]];
$client->put('spaces/288868932106293/stories/182794698822337', $payload)->getBody();HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/182794698822337") .header("Content-Type", "application/json") .header("Authorization", "YOUR_PERSONAL_ACCESS_TOKEN") .body({"story":{"content":{"content_types":["category"],"lock_subfolders_content_types":false},"is_folder":true,"name":"Categories","parent_id":0,"slug":"categories"}}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/288868932106293/stories/182794698822337");var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");request.AddHeader("Authorization", "YOUR_PERSONAL_ACCESS_TOKEN");request.AddParameter("application/json", "{\"story\":{\"content\":{\"content_types\":[\"category\"],\"lock_subfolders_content_types\":false},\"is_folder\":true,\"name\":\"Categories\",\"parent_id\":0,\"slug\":\"categories\"}}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/288868932106293/stories/182794698822337"
querystring = {}
payload = {"story":{"content":{"content_types":["category"],"lock_subfolders_content_types":false},"is_folder":true,"name":"Categories","parent_id":0,"slug":"categories"}}headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_PERSONAL_ACCESS_TOKEN"}
response = requests.request("PUT", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_PERSONAL_ACCESS_TOKEN')
payload = {"story" => {"content" => {"content_types" => ["category"],"lock_subfolders_content_types" => false},"is_folder" => true,"name" => "Categories","parent_id" => 0,"slug" => "categories"}}
client.put('spaces/288868932106293/stories/182794698822337', payload)let storyblok = URLSession(storyblok: .mapi(accessToken: .personal("YOUR_PERSONAL_ACCESS_TOKEN")))var request = URLRequest(storyblok: storyblok, path: "spaces/288868932106293/stories/182794698822337")request.httpMethod = "PUT"request.httpBody = try JSONSerialization.data(withJSONObject: [ "story": [ "content": [ "content_types": [ "category", ], "lock_subfolders_content_types": false, ], "is_folder": true, "name": "Categories", "parent_id": 0, "slug": "categories", ],])let (data, _) = try await storyblok.data(for: request)print(try JSONSerialization.jsonObject(with: data))val client = HttpClient { install(Storyblok(MAPI)) { accessToken = Personal("YOUR_PERSONAL_ACCESS_TOKEN") }}
val response = client.put("spaces/288868932106293/stories/182794698822337") { setBody(buildJsonObject { putJsonObject("story") { putJsonObject("content") { putJsonArray("content_types") { add("category") } put("lock_subfolders_content_types", false) } put("is_folder", true) put("name", "Categories") put("parent_id", 0) put("slug", "categories") } })}
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