How to use the Content Delivery API to Get a Story by ID from a Pipeline Stage?

I’m using the Pipelines Storyblok app.

I’m able to retrieve single stories using my preview token, such as:
https://api.storyblok.com/v1/cdn/stories/123456?token=[preview token]

But, when I use my preview branch token, I get a 404 response “This record could not be found”.

My goal is to get the content of a single story by ID from a particular pipeline stage. Is there a way to do that?

Hello Ed,

this works when using the parameter like shown:
https://api.storyblok.com/v1/cdn/stories/27300347?find_by=id&version=draft&token=wHOzQudiGjMvkzO8Erl0Dgtt&cv=1605201321
or for the UUID
https://api.storyblok.com/v1/cdn/stories/cd2c70ca-26db-4efe-9526-1188f21d62c6?find_by=uuid&version=draft&token=wHOzQudiGjMvkzO8Erl0Dgtt&cv=1605201321

Alright, that worked!
Here are the two points I did not understand:

  1. In order to query by UUID, add the parameter: find_by=uuid
  2. The story ID for a particular story on the Preview pipeline stage is not same value as the story ID (for the same story) on a different pipeline stage. If you want to query the API for a given story on different pipeline stages, the UUID works.

To 1. You need to switch to the particular id type you’re using if you want to have only 1 story but you can also use the by_uuids parameter instead:
https://api.storyblok.com/v1/cdn/stories/?by_uuids=cd2c70ca-26db-4efe-9526-1188f21d62c6&version=draft&token=wHOzQudiGjMvkzO8Erl0Dgtt&cv=1605201321
It allows you to get one or more stories by their UUIDs.

To 2. https://www.storyblok.com/faq/what-is-difference-between-story-id-and-uuid
We recommend to use UUIDs instead of the legacy id in all cases.

1 Like