Create your first space
A space holds your content model, stories, assets and tokens. Here is how to create one and wire up an SDK.
What you get
Creating a space via POST /v1/spaces (or the admin UI) provisions three default CDN tokens: public, preview, private. The creator becomes an admin collaborator. All storyblok API v2 endpoints become available at /api/v2/cdn/* scoped to the space via the token.
create-space.sh
curl -X POST https://your-osstblok.example/api/v1/spaces \
-H 'Content-Type: application/json' \
-H 'Cookie: better-auth.session_token=...' \
-d '{"name": "Marketing Site"}'
# Returns the three default tokens in the response.app.ts
import { storyblokInit, apiPlugin } from '@storyblok/js'
const { storyblokApi } = storyblokInit({
accessToken: 'sbpub_xxxx', // copy from the space overview
apiOptions: {
endpoint: 'https://your-osstblok.example/api/v2',
},
use: [apiPlugin],
})
const { data } = await storyblokApi!.get('cdn/stories', { starts_with: 'blog/' })