Skip to content

Finish a story and continue the world

Apply a finished story’s outcomes, choose which eligible new entities to retain, and build the next story in the same instance.

The instance keeps its characters, locations, items and history across stories. Stories can also introduce new entities as they unfold. When a story ends, you choose which of those additions to keep, and its outcomes become part of the continuing world.

This guide follows Mallow’s Oz story from its ending into the next story setup.

Terminal window
INSTANCE_ID=da1cc53b-9d9e-4edb-83e4-d5a9ee713130
STORY_ID=b79d72ef-92fb-4bcd-917a-9886e62d41d8

Story mutations return new events in order. An ending can include an event such as:

{
"eventId": "e15e3e1b-9b10-4417-a61c-c381b957f079",
"event": "END_STORY",
"data": {
"storyId": "b79d72ef-92fb-4bcd-917a-9886e62d41d8",
"text": "Mallow leaves the workshop in the care of a neighbor and sets off to find the source of the trouble."
}
}

This event marks the episode’s ending even when data.text is absent. The text and endReason fields are optional; use the END_STORY event type and data.storyId to recognize which story ended. A longer storyline may still have chapters to come; check its progress after completing the story.

You can also read the story directly:

Terminal window
curl \
"https://api.hiddendoor.co/experience/v1/instances/$INSTANCE_ID/stories/$STORY_ID" \
-H "Authorization: Bearer $HD_API_KEY"

Its isActive field is true while active, false when cancelled and null when completed. The story includes public turn history, objectives and any storyline references. Once it has ended, stop submitting ordinary actions and finalize its outcomes.

To retain all newly introduced entities, finalize the completed story and omit entityIdsToKeep:

Terminal window
curl --request POST \
"https://api.hiddendoor.co/experience/v1/instances/$INSTANCE_ID/stories/$STORY_ID/complete" \
-H "Authorization: Bearer $HD_API_KEY" \
-H 'Content-Type: application/json' \
--data '{}'

A successful 200 response contains storyId, gameState, events and inputRequests. This operation applies final story outcomes and storyline progress. The updated world is ready for your next story’s setup.

To retain a subset of eligible newly introduced entities, send their identifiers instead:

{
"entityIdsToKeep": ["c1a8dd94-21d2-4b9c-a417-ed5cb1325cda"]
}

Use this body instead of {} if you want to keep Brindle, the badger Mallow met, while letting other eligible new entities leave the continuing cast. Submit one completion request with your chosen retention policy:

  • Omit entityIdsToKeep to keep all newly introduced entities.
  • Supply identifiers to keep a subset.
  • Supply [] to keep none of the eligible new entities.

Existing entities, hidden entities and the lead are always preserved.

Use entity identifiers from the story and world state. After completion, use the returned gameState for the next story’s setup. If the response is lost, inspect current state before retrying.

Terminal window
curl "https://api.hiddendoor.co/experience/v1/instances/$INSTANCE_ID/storylines" \
-H "Authorization: Bearer $HD_API_KEY"

This returns storylines already instantiated in this world. Each has its own UUID, a templateId, a status and ordered beats. Beat status distinguishes open, hit and skipped; fulfilledByStoryId links a fulfilled chapter to its story.

For example, these selected fields could describe the completed Oz origin:

{
"storylines": [
{
"id": "f96d1eb9-4dc8-47dd-96d6-c8e4a3f51551",
"templateId": "oz_trouble_at_home",
"name": "The Trouble at Home",
"status": "completed",
"beats": [
{
"beatId": "oz_trouble_at_home.the_day_it_arrives",
"status": "hit",
"fulfilledByStoryId": "b79d72ef-92fb-4bcd-917a-9886e62d41d8"
}
]
}
]
}

“The Trouble at Home” has one chapter, so its storyline is now complete. Mallow can begin another storyline or have further stories in the same Oz instance.

Longer storylines include upcoming chapters. Choose how much of this information to show in your interface. Chapter entityIds, when present, refer to canon entries and may differ from instance entity UUIDs.

Generate the next story using existing characters

Section titled “Generate the next story using existing characters”

To build on the finished story without selecting a particular storyline, provide it as context:

Terminal window
curl --request POST \
"https://api.hiddendoor.co/experience/v1/instances/$INSTANCE_ID/story-options" \
-H "Authorization: Bearer $HD_API_KEY" \
-H 'Content-Type: application/json' \
--data '{
"setup": {
"playerCharacterId": "79a3af39-c171-4dfb-b51b-5a684f61525d",
"entityIds": [],
"modifierNames": [],
"contextStoryId": "b79d72ef-92fb-4bcd-917a-9886e62d41d8"
}
}'

This produces another temporary set of three options. Select one and start it using exactly the same setup, as in the story-start guide. contextStoryId provides prior-story context; it does not by itself select an existing storyline or require the same plot to continue.

To choose a new authored storyline, read the current offers and supply its identifier as startTemplateId. To continue an existing active storyline, supply its UUID as storylineId instead. targetBeatId can select a chapter in that existing storyline and requires storylineId. Do not supply both startTemplateId and storylineId.

Keep using Mallow’s identifier as playerCharacterId to follow their next adventure.

Cancel an active story when you intend to abandon it

Section titled “Cancel an active story when you intend to abandon it”

Cancellation is a different operation from successful completion:

Terminal window
curl --request POST \
"https://api.hiddendoor.co/experience/v1/instances/$INSTANCE_ID/stories/$STORY_ID/cancel" \
-H "Authorization: Bearer $HD_API_KEY" \
-H 'Content-Type: application/json' \
--data '{}'

Cancel only while the story is active. Cancellation releases its narrative constraints and returns the resulting state. The story remains in history with isActive: false.

To begin another episode in this instance, continue with story setup.