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

# Create an environment

> Creates an environment for the project: a noise bed and the level it plays at. Reference it by id when setting a customer flow variant's environment. Roark's curated presets always play at the default level, so this is how a project gets the same bed louder or quieter.



## OpenAPI

````yaml /api-reference/openapi.documented.json post /v1/simulation/environment
openapi: 3.1.0
info:
  title: Roark Analytics API
  description: >-
    The Roark Analytics API gives you access to the same API that powers the
    award winning Roark Analytics platform.
  version: 1.0.0
servers:
  - description: Production
    url: https://api.roark.ai
security:
  - Bearer: []
tags:
  - name: Agent
  - name: Agent Endpoint
  - name: Call
  - name: Chat
  - name: Metric
  - name: Metric Policy
  - name: Metric Collection Job
  - name: Customer Flow
  - name: Customer Flow Edge Case
  - name: Simulation
  - name: Simulation Persona
  - name: Simulation Environment
  - name: Simulation Scenario
  - name: Simulation Run Plan
  - name: Simulation Template
  - name: Simulation Run Plan Job
  - name: Simulation Job
  - name: HTTP Request Definition
  - name: Webhook
  - name: Issue
  - name: Knowledge Base
  - name: Config
  - name: CLI Auth
  - name: Call Analysis
  - name: Health
paths:
  /v1/simulation/environment:
    post:
      tags:
        - Simulation Environment
      summary: Create an environment
      description: >-
        Creates an environment for the project: a noise bed and the level it
        plays at. Reference it by id when setting a customer flow variant's
        environment. Roark's curated presets always play at the default level,
        so this is how a project gets the same bed louder or quieter.
      operationId: postV1SimulationEnvironment
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEnvironmentInput'
      responses:
        '201':
          description: The created environment
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/EnvironmentResponse'
                required:
                  - data
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Validation error
              example:
                type: validation
                code: invalid_parameter
                message: The request was invalid
                param: email
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Authentication error
              example:
                type: authentication
                code: unauthorized
                message: Authentication required
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Permission error
              example:
                type: forbidden
                code: permission_denied
                message: You do not have permission to access this resource
          description: Forbidden
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Rate limit error
              example:
                type: rate_limit
                code: too_many_requests
                message: Rate limit exceeded
          description: Too Many Requests
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Server error
              example:
                type: internal
                code: internal_error
                message: Internal server error
          description: Internal Server Error
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Roark from '@roarkanalytics/sdk';


            const client = new Roark({
              bearerToken: process.env['ROARK_API_BEARER_TOKEN'], // This is the default and can be omitted
            });


            const simulationEnvironment = await
            client.simulationEnvironment.create({
              backgroundNoise: 'OFFICE',
              name: 'Busy call centre',
            });


            console.log(simulationEnvironment.data);
        - lang: Python
          source: |-
            import os
            from roark_analytics import Roark

            client = Roark(
                bearer_token=os.environ.get("ROARK_API_BEARER_TOKEN"),  # This is the default and can be omitted
            )
            simulation_environment = client.simulation_environment.create(
                background_noise="OFFICE",
                name="Busy call centre",
            )
            print(simulation_environment.data)
components:
  schemas:
    CreateEnvironmentInput:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          description: >-
            Display name, shown wherever a flow variant references the
            environment
          example: Busy call centre
        description:
          type:
            - string
            - 'null'
          description: Optional note on when to use this environment
          example: Open-plan office at peak hours
        backgroundNoise:
          type: string
          enum:
            - NONE
            - AIRPORT
            - CHILDREN_PLAYING
            - CITY
            - COFFEE_SHOP
            - DRIVING
            - OFFICE
            - THUNDERSTORM
          description: >-
            The noise bed played underneath the simulated caller. NONE plays
            nothing.
          example: OFFICE
        backgroundNoiseVolume:
          type: number
          minimum: 0
          maximum: 1
          default: 0.1
          description: >-
            How loud the bed plays, as a gain from 0 (silent) to 1 (as loud as
            the caller). Defaults to 0.1, which sits well under the caller.
            Ignored on Vapi endpoints, which have no level control.
          example: 0.3
      required:
        - name
        - backgroundNoise
      description: Input for creating an environment
    EnvironmentResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          minLength: 1
        description:
          type:
            - string
            - 'null'
        backgroundNoise:
          type: string
          enum:
            - NONE
            - AIRPORT
            - CHILDREN_PLAYING
            - CITY
            - COFFEE_SHOP
            - DRIVING
            - OFFICE
            - THUNDERSTORM
          default: NONE
        backgroundNoiseVolume:
          type: number
          minimum: 0
          maximum: 1
          default: 0.1
        createdAt:
          type: string
          description: Creation timestamp in ISO 8601 format
        updatedAt:
          type: string
          description: Last update timestamp in ISO 8601 format
      required:
        - id
        - name
        - backgroundNoise
        - backgroundNoiseVolume
        - createdAt
        - updatedAt
      description: >-
        A simulation environment: the ambient conditions a customer flow variant
        runs under. The list includes both your own and the ones Roark curates
        for every project.
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - validation
            - authentication
            - forbidden
            - not_found
            - conflict
            - payment_required
            - rate_limit
            - internal
          description: The error type category
          examples:
            - validation
            - authentication
        code:
          type: string
          description: Machine-readable error code identifier
          examples:
            - invalid_parameter
            - missing_required_field
            - unauthorized
        message:
          type: string
          description: Human-readable error message
          examples:
            - The request was invalid
            - Authentication required
        param:
          type: string
          description: The parameter that caused the error (if applicable)
          examples:
            - email
            - user_id
        details:
          description: Additional error context information
      required:
        - type
        - code
        - message
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````