Selecting Region in SDKs

In order to use the SDK for a particular region, you need to make certain changes to the SDK configurations for different technologies.
For each technology given below, set the following region configuration according to your region.

iOS

For Swift

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

var config: Config = Config();
config.region = ContentstackRegion.<<add_your_region>>;
let stack:Stack = Contentstack.stackWithAPIKey("API_key",
accessToken:"delivery_token", 
environmentName:"environment_id", 
config:config)

Note: For European users set region as eu.
Azure North American users set region as azure_na.

For Objective-C

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

Config *config = [[Config alloc] init];
config.region = <<add_your_region>>;
Stack *stack = [Contentstack stackWithAPIKey:@"API_key" 
accessToken:@"delivery_token" 
environmentName:@"environment_id" 
config:config];

Note: For European users set region as EU.
Azure North American users set region as AZURE_NA.

.NET

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

ContentstackOptions options = new ContentstackOptions() {
    ApiKey = "<stack_api_key>",
    AccessToken = "<delivery_token>",
    Environment = "<environment_name>",
    Region = ContentstackRegion.<<add_your_region>>
}
ContentstackClient stack = new ContentstackClient(options);

For Setting the Branch for a Region.

If you want to initialize SDK in a particular branch use the code given below:

ContentstackOptions options = new ContentstackOptions() {
    ApiKey = "<api_key>",
    AccessToken = "<delivery_token>",
    Environment = "<environment_name>",
    Region = ContentstackRegion.<<add_your_region>>,
    Branch = "<branch>""
};
ContentstackClient stack = new ContentstackClient(options);

Note: For European users set region as EU.
Azure North American users set region as AZURE_NA.

Android

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

Config config = Config();
Config.region = ContentstackRegion.<<add_your_region>>;
Stack stack = Contentstack.stack(context, "stack_api_key", "delivery_token", "environment_name", config);

For Setting the Branch for a Region.

If you want to initialize SDK in a particular branch use the code given below:

Config config = Config();
config.setRegion(ContentstackRegion.<<add_your_region>>);
config.setBranch("branch");
Stack stack = Contentstack.stack("api_key", "delivery_token", "environment_name", config);

Note: For European users set region as EU.
Azure North American users set region as AZURE_NA.

Java

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

Config config = Config();
Config.region = ContentstackRegion.<<add_your_region>>;
Stack stack = Contentstack.stack("stack_api_key", "delivery_token", "environment_name", config);

For Setting the Branch for a Region.

If you want to initialize SDK in a particular branch use the code given below:

Config config = Config();
config.setRegion(ContentstackRegion.<<add_your_region>>);
config.setBranch("branch");
Stack stack = Contentstack.stack("api_key", "delivery_token", "environment_name", config);

Note: For European users set region as EU.
Azure North American users set region as AZURE_NA.

Ruby

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

@stack = Contentstack::Client.new("API_key", "delivery_token", "environment_id",{"region": Contentstack::Region::<<add_your_region>>})

For Setting the Branch for a Region.

If you want to initialize SDK in a particular branch use the code given below:

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment",{"region": Contentstack::Region::<<add_your_region>>, "branch": "branch"})

Note: For European users set region as EU.
Azure North American users set region as AZURE_NA.

JS/ React Native/ Node.js

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

const Stack = new Contentstack({ 'api_key': "stack_api_key", 'delivery_token': "environment-specific_delivery_token", 'environment': "environment_name", "region": Contentstack.Region.<<add_your_region>>})

For Setting the Branch for a Region.

If you want to initialize SDK in a particular branch use the code given below:

const Stack = Contentstack.Stack({ api_key: 'api_key', delivery_token: 'delivery_token', environment: 'environment', region: Contentstack.Region.<<add_your_region>>, host: '<<add_your_host_URL>>', branch: 'branch')

Note: For European users set region as EU and host as eu-cdn.contentstack.com.
Azure North American users set region as AZURE_NA and host as azure-na-cdn.contentstack.com.

Python

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

import contentstack

config = Config()
config.region = ContentstackRegion.<<add_your_region>>;
stack = contentstack.Stack(api_key="API_key", access_token="delivery_token",environment= "environment_id", config)

For Setting the Branch for a Region:

If you want to initialize SDK in a particular branch use the code given below:

import contentstack
stack = contentstack.Stack(api_key='api_key', access_token='delivery_token',environment= 'environment_name', region=<<add_your_region>>;,branch='branch')

Note: For European users set region as EU.
Azure North American users set region as AZURE_NA.

PHP

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

$stack = Contentstack::Stack('api_key', 'delivery_token', 'environment_name', array('region' => ContentstackRegion.<<add_your_region>>));

For Setting the Branch for a Region.

If you want to initialize SDK in a particular branch use the code given below:

static Stack = Contentstack::Stack('api_key', 'delivery_token', 'environment_name', array('region' =>> Contentstack::Region::<<add_your_region>>, "branch"=>> "branch"))

Note: For European users set region as EU.
Azure North American users set region as AZURE_NA.

Dart

By default, the SDK uses the North American region. Configuration changes are not required for North American region users.

To set the European or Azure North Amercian region, refer to the code below:

import 'package:contentstack/contentstack.dart' as contentstack;

final stack = contentstack.Stack(apiKey, deliveryToken, environment, region: contentstack.Region.<<add_your_region>>);

For Setting the Branch for a Region.

If you want to initialize SDK in a particular branch use the code given below:

import 'package:contentstack/contentstack.dart' as contentstack;

final stack = contentstack.Stack('apiKey', 'deliveryToken', 'environment', region: contentstack.Region.<<add_your_region>>, branch: 'branch');

Note: For European users set region as eu.
Azure North American users set region as azure_na.

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page

^