# Create environment

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /environments:
    post:
      summary: Create environment
      deprecated: false
      description: >
        The request body for POST /environments, which provisions a new CloudCLI
        development container on your account. Only name and subdomain are
        required. Everything else (GitHub clone, tokens) is optional and can be
        configured later via  the
        dashboard.                                         
      tags:
        - Environments
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEnvironmentRequest'
            examples:
              blank_environment:
                value:
                  name: My Project
                  subdomain: myproject-abc123
                summary: Blank environment
              with_github:
                value:
                  name: Backend API
                  subdomain: backend-xyz789
                  github_url: https://github.com/username/backend
                  github_token: ghp_...
                summary: With GitHub repository
      responses:
        '201':
          description: Environment created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Environment'
          headers: {}
          x-apidog-name: Created
        '400':
          description: Bad request - Missing required fields
          content:
            application/json:
              schema: &ref_0
                $ref: '#/components/schemas/Error'
          headers: {}
          x-apidog-name: Bad Request
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema: *ref_0
          headers: {}
          x-apidog-name: Unauthorized
        '402':
          description: Payment required - Environment limit reached
          content:
            application/json:
              schema: *ref_0
          headers: {}
          x-apidog-name: Payment Required
        '409':
          description: Conflict - Subdomain already taken
          content:
            application/json:
              schema: *ref_0
          headers: {}
          x-apidog-name: Conflict
        '503':
          description: Service unavailable - No servers with capacity
          content:
            application/json:
              schema: *ref_0
          headers: {}
          x-apidog-name: Service Unavailable
      security:
        - ApiKeyAuth: []
          x-apidog:
            schemeGroups:
              - id: nyTYV523pyZpXNGC1U365
                schemeIds:
                  - ApiKeyAuth
            required: true
            use:
              id: nyTYV523pyZpXNGC1U365
            scopes:
              nyTYV523pyZpXNGC1U365:
                ApiKeyAuth: []
      x-apidog-folder: Environments
      x-apidog-status: released
      x-run-in-apidog: https://app.eu.apidog.com/web/project/359666/apis/api-3998768-run
components:
  schemas:
    CreateEnvironmentRequest:
      type: object
      required:
        - name
        - subdomain
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 50
          examples:
            - My Backend API
        subdomain:
          type: string
          pattern: ^[a-z0-9-]+$
          minLength: 3
          maxLength: 30
          examples:
            - mybackend-abc123
        github_url:
          type: string
          format: uri
          examples:
            - https://github.com/username/repo
          nullable: true
        github_token:
          type: string
          description: GitHub personal access token for private repos
          nullable: true
      x-apidog-orders:
        - name
        - subdomain
        - github_url
        - github_token
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    Environment:
      type: object
      properties:
        id:
          type: string
          format: uuid
          examples:
            - 123e4567-e89b-12d3-a456-426614174000
        name:
          type: string
          examples:
            - My Backend API
        subdomain:
          type: string
          pattern: ^[a-z0-9-]+$
          examples:
            - mybackend-abc123
        access_url:
          type: string
          format: uri
          examples:
            - https://mybackend-abc123.cloudcli.ai
        status:
          type: string
          examples:
            - running
        github_url:
          type: string
          format: uri
          examples:
            - https://github.com/username/repo
          nullable: true
        created_at:
          type: string
          format: date-time
      x-apidog-orders:
        - id
        - name
        - subdomain
        - access_url
        - status
        - github_url
        - created_at
      required:
        - status
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
    Error:
      type: object
      properties:
        error:
          type: string
          examples:
            - Invalid or missing API key
      x-apidog-orders:
        - error
      x-apidog-ignore-properties: []
      x-apidog-folder: ''
  securitySchemes:
    ApiKeyAuth:
      type: apikey
      in: header
      name: X-API-KEY
      description: API key obtained from the CloudCLI dashboard
servers:
  - url: https://cloudcli.ai/api/v1
    description: Production API
security:
  - ApiKeyAuth: []
    x-apidog:
      schemeGroups:
        - id: nyTYV523pyZpXNGC1U365
          schemeIds:
            - ApiKeyAuth
      required: true
      use:
        id: nyTYV523pyZpXNGC1U365
      scopes:
        nyTYV523pyZpXNGC1U365:
          ApiKeyAuth: []

```