Set up connection environments with the API
Requirements
To follow the steps in this guide, you’ll need:- An Omni API key
- Connection Admin permissions on an existing Omni database connection
Steps
1
Create the base connection
This is the default connection. Omni uses it for users whose user attribute value is one of the base connection’s default values. Use the Create a connection API to create the connection.In this example, this would be a connection to your development database:
POST /api/v1/connections
2
Create environment connections
Environment conditions are additional connections with the same dialect as the base connection. Use the Create a connection API to create the connection(s).In this example, this would be a connection to your production database:
POST /api/v1/connections
3
Connect the base and environment connections
Use the Create connection environments API to associate the base connection with the environment connections. Provide the following:
baseConnectionId- The ID of the base connection. In this example, that’s your development database.environmentConnectionIds- The ID(s) of the connection environments. In this example, that’s your production database.
POST /api/v1/connection-environments
4
Configure the base connection user attribute
Use the Update a connection API to specify which user attribute will be used to determine the connection environment.In this example, configure the base connection to use the To remove the user attribute from the base connection, set
environment user attribute and set its default values to ["dev"]:PATCH /api/v1/connections/:id
environmentUserAttribute to null.Connection responses show these settings as
userAttributeNameForConnectionEnvironments and userAttributeValuesForDefaultEnvironment. Don’t use those field names in the update request. The endpoint rejects them.5
Define user attribute values for environments
Use the Update connection environment user attributes API to specify which user attribute values will trigger the use of each environment connection.In this example, set the user attribute values for the production environment connection to Now, users with the
prod:PUT /api/v1/connection-environments/:id
environment attribute set to prod use the production database, and users with the environment attribute set to dev use the development database.
