Skip to content

Read and save stories ​

All routes here require an authoring session and server-side permission for the story. Examples use same-origin requests from a signed-in application context. They are not anonymous public API examples.

Routes ​

MethodPathPurpose
GET/studio-api/sessionRead the current author identity
GET/studio-api/storiesList stories visible for authoring
POST/studio-api/storiesCreate an owned story
GET/studio-api/stories/{story_id}Read the authoring document
POST/studio-api/stories/{story_id}/initializeInitialize missing content
PUT/studio-api/stories/{story_id}Save a complete authoring document

The create operation accepts a nonempty title and can accept a story_id. The server assigns ownership to the authenticated user; a caller cannot claim another user's identity. Do not use initialize to overwrite an existing story.

Read a document ​

js
const path = `/studio-api/stories/${encodeURIComponent(storyId)}`;
const response = await fetch(path, { credentials: 'same-origin' });
if (!response.ok) throw new Error(`Read failed: ${response.status}`);
const { document } = await response.json();

Keep the returned revision with the document. Do not replace structured page text with strings or remove fields you do not recognize. Preserve existing content IDs and conversation relationships.

Save with revision control ​

Make a copy of the complete document, change only the intended records, and submit the revision you read:

js
const nextDocument = structuredClone(document);
nextDocument.story_title = 'A revised title';

const saved = await fetch(path, {
  method: 'PUT',
  credentials: 'same-origin',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    base_revision: document.revision,
    document: nextDocument,
  }),
});
if (saved.status === 409) {
  throw new Error('The story changed. Reload and reconcile before saving.');
}
if (!saved.ok) throw new Error(`Save failed: ${saved.status}`);
const result = await saved.json();

A successful save returns the saved document and its new revision. Read it back and check the intended change. A title change inside the authoring document should not be assumed to update every separate catalog metadata field.

On a conflict, compare the newly saved version with your intended edit. Do not repeat an old whole-document write using a freshly fetched revision; that could silently overwrite another editor's work.

Scope of this reference ​

Resource-level edit/query routes present in newer development code are not listed as deployed APIs here. Story document schemas need a versioned contract before broad third-party authoring can be advertised. See AI editors.

Non Linear documentation · Files in GitHub, no wiki database.