Managing Stories

Getting a list of stories

Endpoint

GET /v1/spaces/:space_id/stories

Parameters

Name Description
page Current page of stories
contain_component Filters by component in all levels of the content. Allows comma separated value for multiple components
search_term Filter by a term using full text search

Request

Query Parameters

page=0
contain_component=headline

cURL

curl "https://api.storyblok.com/v1/spaces/616/stories?page=0&contain_component=headline" -X GET \
	-H "Accept: application/json" \
	-H "Content-Type: application/json"
	-H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4ODAsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.-TZDY3Ro797STmzijXpFf3HcrBkHtEFczqsrzNWrRiI" \

Response

Body

{
  "stories": [
    {
      "name": "Test",
      "parent_id": 0,
      "created_at": "2018-07-20T08:34:52.406Z",
      "deleted_at": null,
      "group_id": "ad4f1ed1-af27-416e-a458-98ffa7bdc707",
      "sort_by_date": null,
      "updated_at": "2018-07-20T08:34:52.406Z",
      "published_at": null,
      "id": 1055,
      "uuid": "17067eef-aa84-4f9a-b36e-4318356a0b9a",
      "is_folder": false,
      "published": false,
      "slug": "test",
      "path": null,
      "full_slug": "test",
      "position": 0,
      "unpublished_changes": null,
      "is_startpage": false,
      "pinned": false,
      "publish_at": null,
      "expire_at": null
    }
  ]
}

Get a single story

Endpoint

GET /v1/spaces/:space_id/stories/:id

Request

cURL

curl "https://api.storyblok.com/v1/spaces/615/stories/1054" -X GET \
	-H "Accept: application/json" \
	-H "Content-Type: application/json"
	-H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4NzcsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.p2dO2ejrIgvFLDGG-5m6H13eOv0hRmz52z1u9-Tri8A" \

Response

Body

{
  "story": {
    "name": "Home",
    "parent_id": 0,
    "group_id": "0748dbcf-3a72-4c32-a6ba-8aa77f0259b2",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:52.290Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:52.324Z",
    "published_at": null,
    "id": 1054,
    "uuid": "290c83e2-a7c6-45bb-aa9e-23221a637830",
    "is_folder": false,
    "content": {
      "_uid": "xyz",
      "body": [
        {
          "_uid": "a9e16ab8-887f-4001-9548-313a09daeb2a",
          "text": "test1",
          "component": "headline"
        },
        {
          "_uid": "89a3cd23-8fd1-4ddc-abfe-a6396d012d14",
          "text": "test2",
          "component": "headline"
        }
      ],
      "component": "root"
    },
    "published": false,
    "slug": "home",
    "path": null,
    "full_slug": "home",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": null,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075692"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

Creating an story

Stories are not published by default. If you want to create a published Story add the parameter publish=1.

Endpoint

POST /v1/spaces/:space_id/stories

Parameters

Name Description
publish If '1' the story will be published immediately after creating
story[name] required Name of story
story[slug] required Slug to be used to receive the story from the api
story[content] JSON tree of the content
story[disble_fe_editor] Wether to disable the visual editor
story[default_root] Defaul root component. (Required if a folder story)
story[is_folder] Wether the story acts as a folder
story[group_id] Group ID. For example to make linkages between language versions
story[path] Url path the editor is opening the story
story[is_startpage] Wether the story is a startpage for this folder
story[parent_id] Id of the parent folder
story[sort_by_date] Sort by date
story[meta_data] Key value pairs to add meta data that is not setting the story status to unpublished changes. Example: User ratings.
story[pinned] To pin the story in the toolbar

Request

cURL

curl "https://api.storyblok.com/v1/spaces/617/stories" -d '{"story":{"name":"Story 1","content":{"component":"root","body":[]},"path":"/v1/spaces/617/stories"}}' -X POST \
	-H "Accept: application/json" \
	-H "Content-Type: application/json"
	-H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4ODMsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.N5LY4hBe9aFpJwQG0hugKWB5gGoH_phKv8LKd4lXNCU" \

Response

Body

{
  "story": {
    "name": "Story 1",
    "parent_id": 0,
    "group_id": "67f3ffa7-2c35-4cda-b4a0-a785b309d378",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:52.532Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:52.532Z",
    "published_at": null,
    "id": 1057,
    "uuid": "67c3f2d5-68f7-40ea-9088-a1987d6fa792",
    "is_folder": false,
    "content": {
      "component": "root",
      "body": [

      ],
      "_uid": "94e61722-c18f-479a-9618-d732d6365629"
    },
    "published": false,
    "slug": "3e85af6f-0103-4142-8fd1-73e76239fd9b",
    "path": "/v1/spaces/617/stories",
    "full_slug": "3e85af6f-0103-4142-8fd1-73e76239fd9b",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": null,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075692"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

Deleting a story

Endpoint

DELETE /v1/spaces/:space_id/stories/:id

Request

cURL

curl "https://api.storyblok.com/v1/spaces/630/stories/1085" -d '' -X DELETE \
	-H "Accept: application/json" \
	-H "Content-Type: application/json"
	-H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo5MjIsInRpbWVzdGFtcCI6MTUzMjY4MDQ5NH0.C41rwZzODXjlu_6cveHRFAJ28t-wxHtS0Vvd0U6kFAk" \

Response

Body

{
  "story": {
    "name": "Home",
    "parent_id": 0,
    "group_id": "71d24ea9-9855-4b69-b51a-2f0f83d01776",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:54.310Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:54.310Z",
    "published_at": null,
    "id": 1085,
    "uuid": "467a0759-7682-497f-bdbe-25f913170c72",
    "is_folder": false,
    "content": {
      "_uid": "xyz",
      "body": [
        {
          "_uid": "a9e16ab8-887f-4001-9548-313a09daeb2a",
          "text": "test1",
          "component": "headline"
        },
        {
          "_uid": "89a3cd23-8fd1-4ddc-abfe-a6396d012d14",
          "text": "test2",
          "component": "headline"
        }
      ],
      "component": "root"
    },
    "published": false,
    "slug": "home",
    "path": null,
    "full_slug": "home",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": null,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075694"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

Updating a story

Endpoint

PUT /v1/spaces/:space_id/stories/:id

Parameters

Name Description
force_update If '1' it will overwrite a locked story
publish If '1' the story will be published immediately after creating
story[name] required Name of story
story[slug] required Slug to be used to receive the story from the api
story[content] JSON tree of the content
story[disble_fe_editor] Wether to disable the visual editor
story[default_root] Defaul root component. (Required if a folder story)
story[is_folder] Wether the story acts as a folder
story[group_id] Group ID. For example to make linkages between language versions
story[path] Url path the editor is opening the story
story[is_startpage] Wether the story is a startpage for this folder
story[parent_id] Id of the parent folder
story[sort_by_date] Sort by date
story[meta_data] Key value pairs to add meta data that is not setting the story status to unpublished changes. Example: User ratings.
story[pinned] To pin the story in the toolbar

Request

cURL

curl "https://api.storyblok.com/v1/spaces/618/stories/1059" -d '{"story":{"name":"Story 1","content":{"component":"root","body":[]},"path":"/v1/spaces/618/stories/1059"}}' -X PUT \
	-H "Accept: application/json" \
	-H "Content-Type: application/json"
	-H "Authorization: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo4ODYsInRpbWVzdGFtcCI6MTUzMjY4MDQ5Mn0.y-gbDSuLmhgZQsJFbZEyG8krrmoNRx7oAkoUCLv_jjA" \

Response

Body

{
  "story": {
    "name": "Story 1",
    "parent_id": 0,
    "group_id": "a93198d7-c65a-49db-b601-956b0b697420",
    "alternates": [

    ],
    "created_at": "2018-07-20T08:34:52.639Z",
    "sort_by_date": null,
    "tag_list": [

    ],
    "updated_at": "2018-07-20T08:34:52.679Z",
    "published_at": null,
    "id": 1059,
    "uuid": "27c08048-0331-4ae0-b639-6e258541b734",
    "is_folder": false,
    "content": {
      "component": "root",
      "body": [

      ],
      "_uid": "75752f90-07ed-4f3a-bdbe-e15a930085a9"
    },
    "published": false,
    "slug": "home",
    "path": "/v1/spaces/618/stories/1059",
    "full_slug": "home",
    "default_root": null,
    "disble_fe_editor": false,
    "parent": null,
    "is_startpage": false,
    "unpublished_changes": true,
    "meta_data": null,
    "imported_at": null,
    "preview_token": {
      "token": "",
      "timestamp": "1532075692"
    },
    "pinned": false,
    "breadcrumbs": [

    ],
    "publish_at": null,
    "expire_at": null
  }
}

Export a story as JSON

ResourceInformation
Endpointhttps://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.json
MethodGET
HeaderAuthorization:YOUR_MANAGEMENT_TOKEN

Export a story as XML

ResourceInformation
Endpointhttps://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/export.xml
MethodGET
HeaderAuthorization:YOUR_MANAGEMENT_TOKEN

Import a story as JSON

ResourceInformation
Endpointhttps://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/import.json
MethodPUT
HeaderAuthorization:YOUR_MANAGEMENT_TOKEN
Body{"data":"{ \"a9e16ab8-887f-4001-9548-313a09daeb2a:headline:text\":\"translated1\", \"89a3cd23-8fd1-4ddc-abfe-a6396d012d14:headline:text\":\"translated2\", \"page\":\"285\"}"}

Import a story as XML

ResourceInformation
Endpointhttps://mapi.storyblok.com/v1/spaces/:space_id/stories/:id/import.xml
MethodPUT
HeaderAuthorization:YOUR_MANAGEMENT_TOKEN
Body{"data":"<?xml version=\"1.0\" encoding=\"UTF-8\"?><page filename=\"home\" url=\"home\" id=\"283\"> <name>Home</name> <tags><tag id=\"a9e16ab8-887f-4001-9548-313a09daeb2a:headline:text\" type=\"STRING\"><text><![CDATA[translated1]]></text></tag><tag id=\"89a3cd23-8fd1-4ddc-abfe-a6396d012d14:headline:text\" type=\"STRING\"><text><![CDATA[translated2]]></text></tag> </tags></page>"}

Documentation