> ## Documentation Index
> Fetch the complete documentation index at: https://nango.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an environment

> Create a new environment

<Info>
  Requires an [Account API key](/docs/reference/backend/http-api/api-keys#account-api-keys). Create one from [Account API keys](https://app.nango.dev/api-keys) in the dashboard.
</Info>

Creates a new environment. Additional environments are limited by your [pricing plan](https://www.nango.dev/pricing).

You can create a production environment by setting `is_production: true`.

The response includes the numeric environment `id`. Use it to [create an Environment API key](/docs/reference/backend/http-api/environments/create-api-key) or [delete the environment](/docs/reference/backend/http-api/environments/delete). Creating an environment also creates a default full-access Environment API key, but the secret is not returned.

<ResponseExample>
  ```json Example Response theme={null}
  {
    "data": {
      "id": 123,
      "name": "staging"
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml POST /environments
openapi: 3.1.0
info:
  title: Nango API
  description: Nango API specs used to authorize & sync data with external APIs.
  version: 1.0.0
servers:
  - url: https://api.nango.dev
    description: Production server
  - url: http://localhost:3003
    description: Local server
security:
  - bearerAuth: []
externalDocs:
  url: https://nango.dev/docs/reference/backend/http-api/authentication
paths:
  /environments:
    post:
      summary: Create an environment
      description: Create a new environment
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - name
              properties:
                name:
                  type: string
                  description: >-
                    Environment name. Lowercase letters, digits, hyphens, and
                    underscores only. Max 255 characters. The reserved name
                    `prod` is always treated as production.
                  pattern: ^[a-z0-9_-]+$
                  maxLength: 255
                  example: staging
                is_production:
                  type: boolean
                  description: >-
                    Whether to mark the environment as production. Defaults to
                    false, except for the reserved name `prod`.
                callback_url:
                  type: string
                  format: uri
                  description: Custom OAuth callback URL for this environment.
                hmac_key:
                  type: string
                  description: HMAC key used by the legacy public-key authorization flow.
                  maxLength: 1000
                hmac_enabled:
                  type: boolean
                  description: >-
                    Whether HMAC verification is enabled for the legacy
                    public-key authorization flow.
                slack_notifications:
                  type: boolean
                  description: >-
                    Whether Slack notifications are enabled for this
                    environment.
                otlp_endpoint:
                  type: string
                  description: >-
                    OpenTelemetry collector endpoint. Requires a plan with
                    OpenTelemetry export. Pass an empty string to set an empty
                    endpoint.
                otlp_headers:
                  type: array
                  description: >-
                    Headers sent with OpenTelemetry export requests. Requires a
                    plan with OpenTelemetry export. Maximum 100 headers.
                  maxItems: 100
                  items:
                    type: object
                    additionalProperties: false
                    required:
                      - name
                      - value
                    properties:
                      name:
                        type: string
                        minLength: 1
                        maxLength: 256
                      value:
                        type: string
                        minLength: 1
                        maxLength: 4000
      responses:
        '200':
          description: Successfully created an environment
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    required:
                      - id
                      - name
                    properties:
                      id:
                        type: integer
                        description: >-
                          Numeric environment ID. Use this in later
                          account-level API calls.
                        example: 123
                      name:
                        type: string
                        description: The environment name.
                        example: staging
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          description: An environment with this name already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StdError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    ServerError:
      description: Server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
  schemas:
    StdError:
      type: object
      additionalProperties: false
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - code
          properties:
            code:
              type: string
            message:
              type: string
            errors:
              type: array
              items:
                type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An Environment API key from your Nango environment, or an Account API
        key for account-level endpoints.

````