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

# Create or Update Environment

> Creates the environment when the name is new, otherwise updates the fields you send. Up to 10 environments per agent. `production` cannot be edited here (409 environment_builtin): publish instead. A `revision` must exist in the agent's version history.



## OpenAPI

````yaml PUT /agents/{id}/environments/{name}
openapi: 3.1.0
info:
  title: RevRing Voice AI API
  description: >-
    RevRing Voice AI platform API for managing AI voice agents, phone calls, SIP
    trunks, and analytics. Build intelligent voice applications that can handle
    inbound and outbound phone calls with AI-powered conversational agents.
  version: 1.0.0
  contact:
    name: RevRing Support
    url: https://revring.ai
servers:
  - url: https://api.revring.ai/v1
    description: Production API
security:
  - apiKeyAuth: []
tags:
  - name: Messaging Connections
    description: Connect messaging providers so agents can send text messages
  - name: Messages
    description: Send text messages and read your message log
  - name: Conversations
    description: List and clear managed conversation threads
  - name: SIP Trunks
    description: Manage SIP trunks for connecting agents to the phone network
  - name: Agents
    description: Manage AI voice agents and their configuration
  - name: Agent Folders
    description: Organize agents into folders for dashboard navigation
  - name: Calls
    description: Manage and query phone calls
  - name: Analytics
    description: Get analytics and metrics about your calls
  - name: Knowledge Bases
    description: >-
      Manage knowledge bases and sources for agent retrieval-augmented
      generation
  - name: Test Suites
    description: Manage test suites, test cases, and test runs for agent evaluation
  - name: Voices
    description: Browse the voices available to your organization for agent speech
  - name: Webhooks
    description: Webhook delivery settings for your organization
paths:
  /agents/{id}/environments/{name}:
    put:
      tags:
        - Agents
      summary: Create or Update Environment
      description: >-
        Creates the environment when the name is new, otherwise updates the
        fields you send. Up to 10 environments per agent. `production` cannot be
        edited here (409 environment_builtin): publish instead. A `revision`
        must exist in the agent's version history.
      parameters:
        - name: name
          in: path
          required: true
          schema:
            type: string
            pattern: ^[a-z][a-z0-9-]{0,31}$
          description: Environment name (slug). Immutable once created
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentEnvironmentUpsert'
      responses:
        '200':
          description: Environment
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/AgentEnvironment'
        '400':
          description: >-
            invalid_environment_name | invalid_body | revision_not_found |
            environment_limit
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '409':
          description: environment_builtin
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
components:
  schemas:
    AgentEnvironmentUpsert:
      type: object
      properties:
        revision:
          type: integer
          nullable: true
          minimum: 1
          description: >-
            Version to run on. null = the saved draft. Omit to leave unchanged
            on update
        variables:
          type: object
          additionalProperties: true
          description: >-
            Variable defaults for this environment. Omit to leave unchanged on
            update
      example:
        revision: 12
        variables:
          tone: formal
          region: EU
    AgentEnvironment:
      type: object
      properties:
        name:
          type: string
          description: >-
            Slug. `production` is built in: it is the published version and
            changes through POST /agents/{id}/publish
        revision:
          type: integer
          nullable: true
          description: Version calls in this environment run on; null means the saved draft
        variables:
          type: object
          additionalProperties: true
          description: >-
            Variable defaults that override the agent's defaultVariables on
            calls in this environment
        builtin:
          type: boolean
          description: true for production
        phoneNumbers:
          type: array
          items:
            type: string
          description: Inbound numbers bound to this environment
        createdAt:
          type: string
          format: date-time
          nullable: true
        updatedAt:
          type: string
          format: date-time
          nullable: true
      required:
        - name
        - revision
        - variables
        - builtin
        - phoneNumbers
  responses:
    UnauthorizedError:
      description: Authentication required or API key invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: unauthorized
    NotFoundError:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
                example: not_found
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Generate API keys from the RevRing
        dashboard.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.