# How to create two Environments and test them in Embeddable

**URL:** <https://community.embeddable.com/t/how-to-create-two-environments-and-test-them-in-embeddable/58>\
**Category:** Support Forum\
**Created:** [May 10, 2024, 4:13pm UTC](https://community.embeddable.com/t/how-to-create-two-environments-and-test-them-in-embeddable/58 "2024-05-10T16:13:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ella-embeddable](https://dub1.discourse-cdn.com/flex013/user_avatar/community.embeddable.com/ella-embeddable/32/15_2.png) [@ella-embeddable](https://community.embeddable.com/u/ella-embeddable)\
**Post date:** [May 10, 2024, 4:13pm UTC](https://community.embeddable.com/t/how-to-create-two-environments-and-test-them-in-embeddable/58/1 "2024-05-10T16:13:57Z")

</div>

A question we often get is how to create two environments - for example “Production” and “Staging” and test them in Embeddable. To achieve this, you can define your `.cube.yml` files like so:

```auto
cubes:
  - name: customers
    title: My customers
    data_source: default # can omit, as `data_source` has value `default` by default
    sql: >
        ...

```

And use the [Connections API](https://www.notion.so/Connections-API-ff4af10f7eaf4288b6952fde04e6e933?pvs=21) to provide your db credentials like so:

```auto
body: JSON.stringify({
	name: 'production-postgres',
	type: 'postgres',
	credentials: {
		...

```

and

```auto
body: JSON.stringify({
	name: 'staging-postgres',
	type: 'postgres',
	credentials: {
		...

```

and then just [create two environments](https://www.notion.so/Environments-API-497169036b5148b38f7936aa75e62949?pvs=21) like so:

```auto
body: JSON.stringify({
	name: 'production',
	datasources: [
		{ data_source: 'default', connection: 'production-postgres'}
	]
})

```

and

```auto
body: JSON.stringify({
	name: 'staging',
	datasources: [
		{ data_source: 'default', connection: 'staging-postgres'}
	]
})

```

and then when [generating your security token](https://www.notion.so/Tokens-API-6e7ea1d1f5f444dd8c3c2dd4ae69d4a9?pvs=21), simply pass either “production” or “staging” to the `environment` field. When you pass “production” to the `environment` field it will dynamically map all the models whose `data_source` is “default” to the “production-postgres” database. Whereas for “staging” it will map them to the “staging-postgres” database.

To test this in the Embeddable no-code builder, just update your `src/presets/security-contexts.sc.yml` file to specify the environment, like so:

```auto
- name: Example customer 1
  securityContext:
    country: United States
  environment: production

- name: Example customer 2
  securityContext:
    country: Germany
  environment: staging

```

Now you can test against staging data as well as production data in the builder, before clicking “publish”.
