How to define specific regions in Storyblok API

There are two main areas to append region code when working with Storyblok V2 API. The first, is when making a Storyblok CDN request, and another is when working with a Storyblok SDK.

Adding region code when making a CDN request: you can add a united states region code when making a CDN request as shown below:

https://api{-us}.storyblok.com/v2

When using SDK: when using Storyblok SDK, append a region using the apiOptions property. You can see below how to set it for React and Vue.

HINT:

Since all the Storyblok SDKs use storyblok-js-client, you can use apiOptions to pass down any option to the JS Client, like the region.

React

You can add a region to your React SDK using the apiOptions property as shown below.

app.js
import { storyblokInit, apiPlugin } from "@storyblok/react"

storyblokInit({
  accessToken: "<your-token>",
  use: [apiPlugin],
  apiOptions: {
    region: "us" // region code here
  }
}) 

Vue

You can add your region in a Vue application similar to React by using the apiOptions property as shown below.

app.vue
import { StoryblokVue, apiPlugin } from "@storyblok/vue"

app.use(StoryblokVue, {
  accessToken: "<your-token>",
  use: [apiPlugin],
  apiOptions: {
    region: "us" // region code here
  }
}) 

JavaScript

With the storyblok-js-client, you can add your region in a JavaScript application by using the StoryblokClient property as shown below:

index.js
const StoryblokClient = require("storyblok-js-client");

let Storyblok = new StoryblokClient({
  accessToken: "YOUR_ACCESS_TOKEN,
 region: 'us' // if its a US server
});

Ruby

You can add your region in a Ruby application by using the Storyblok Ruby SDK as shown below:

gem 'storyblok'

client = Storyblok::Client.new(token: 'YOUR_ACCESS_TOKEN', api_region: 'us') // for a US region server

PHP

First, install the Storyblok PHP client by using the Storyblok PHP SDK. You can then add your region in a PHP application as shown below:

$client = new \Storyblok\Client(
     'your-storyblok-draft-token',
     null,
     'v2',
     false,
     'us'
 );

IMPORTANT:

Note that our Python SDK currently doesn’t support other regions.