---
title: "Create dbt environment"
method: POST
path: "/v1/connections/{connectionId}/dbt/environments"
tags: ["dbt"]
---

# Create dbt environment

`POST /v1/connections/{connectionId}/dbt/environments`

## Request

- Base URL: `https://blobsrus.omniapp.co/api`
- URL: `https://blobsrus.omniapp.co/api/v1/connections/{connectionId}/dbt/environments`
- Auth: HTTP bearer

Create a new [dbt environment](/integrations/dbt/environments) on the specified connection. A dbt environment allows you to connect Omni to a specific dbt project and manage dbt-related functionality within the connection context.

dbt environments can be personal (owned by a single user) or shared (owned by no one). To create:

- **A personal environment for yourself**, you'll need **Restricted Querier** permissions or higher on the associated Omni model
- **A personal environment for another user**, you'll need **Organization Admin** permissions
- **A shared environment**, you'll need **Connection Admin** or **Organization Admin** permissions

## Path parameters

- `connectionId` string, uuid, required

## Request body

- object
  - `name` string, required: The name of the dbt environment
  - `targetSchema` string, required: The target schema for the environment
  - `isDeferralEnabled` boolean: Whether deferral is enabled for this environment. Defaults to `false`. Ignored (forced to `false`) for the default (production) environment.
  - `ownerId` string, uuid, nullable: Defines the owner of the environment, which also determines the type of environment (personal or shared) that is created. - **Personal environment** - Use the organization membership ID of the user that owns the environment, not their user ID. **Organization Admin** permissions are required to set the ID of a user other than the authenticating user. Get your own membership ID from the [Who Am I API](/api/who-am-i/get-current-identity-and-permissions), or another user's from the [Get model roles API](/api/user-model-roles/retrieve-user-model-roles). - **Shared environment** - Set to `null`. Requires **Connection Admin** or **Organization Admin** permissions.
  - `targetDatabase` string, nullable: Target database override
  - `targetName` string, nullable: Target name override
  - `targetRole` string, nullable: Target role override
  - `variables` object[]: Environment variables for the dbt environment. **Note**: While `variables` is not required, at least one variable object must be defined if `variables` is included in the request body.
    - `name` string, required: Variable name
    - `value` string, required: Variable value. May be empty, except for secret variables.
    - `isSecret` boolean, required: Whether the variable value is secret

## Response `201`

dbt environment created successfully

- DbtEnvironment
  - `id` string, uuid: Unique identifier of the dbt environment
  - `name` string: The name of the dbt environment
  - `isDefaultEnvironment` boolean: Whether this is the default environment
  - `isDeferralEnabled` boolean: Whether deferral is enabled for this environment. Ignored (forced to `false`) for the default (production) environment.
  - `ownerId` string, uuid, nullable: The organization membership ID of the owner of the dbt environment, or null
  - `targetDatabase` string, nullable: Target database override
  - `targetName` string, nullable: Target name override
  - `targetRole` string, nullable: Target role override
  - `targetSchema` string: Target schema for the environment
  - `variables` object[]: Environment variables
    - `id` string, uuid: Variable identifier
    - `name` string: Variable name
    - `value` string, nullable: Variable value. If `isSecret: true`, this value will be `null` in responses to protect sensitive information.
    - `isSecret` boolean: Whether the variable value is secret.

## Other responses

- `400`: Bad Request Possible error messages: - Invalid request body
- `401`: Missing or invalid authentication
- `403`: Forbidden Possible causes: - Insufficient permissions. Creating a shared environment requires **Connection Admin**; creating an environment owned by another user requires **Organization Admin**. - Non-admin user attempting to set `ownerId` for another user
- `404`: Connection or owner not found
- `429`: Too Many Requests - Rate limit exceeded (60 requests/minute)

---

[API](https://skmtc.dev/omni/apis/omni-api.md) - [All operations](https://skmtc.dev/omni/apis/omni-api/llms.txt) - [OpenAPI document](https://skmtc.dev/omni/apis/omni-api/revisions/43290040f88f?raw)
