Post a story
Create a story with the storyPost mutation: choose the space, the body format and whether to publish it.
Creating a story is one mutation, storyPost. Its input is large, so split the request into two parts: the mutation and the variables.
The mutation:
mutation storyPostExample($input: StoryPostInput!) {
storyPost(input: $input) {
story {
id
slug
version {
title
}
}
errors {
__typename
... on MutationError {
path
}
}
}
}
The variables:
{
"input": {
"publish": true,
"spaceId": "SPACE_ID",
"title": "My first story",
"body": {
"format": "MARKDOWN",
"markup": "# Hello world\n\nThis story was created through the API."
}
}
}
The fields you will use most:
spaceIdis the GraphQL ID of the space. If you only know its slug, read the ID withspace(slug:) { id }, as Get a story does for a story. Set it tonullto post in the user's personal content.body.formatis one of the body formats:MARKDOWNfor plain Markdown,MARKDOWN_ELIUMfor Markdown with Elium directives,HTMLorHTML_ELIUMfor HTML.publishisfalseby default: the story stays a draft. Set it totrueto publish it.schemaIdapplies a template.tagsandhashtagstake lists of IDs.langsets the language of the version.
The response:
{
"data": {
"storyPost": {
"story": {
"id": "U3Rvcnk6MTIz",
"slug": 123,
"version": {
"title": "My first story"
}
},
"errors": null
}
}
}
To attach a file to the new story, see Post a story with a file.