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

# Update an environment

> `envVars` replaces the whole map when present. Values read back masked and sent again unchanged keep their stored secret, so a read-modify-write of the map does not destroy the secrets it did not touch.



## OpenAPI

````yaml PATCH /v1/environments/{environmentId}
openapi: 3.0.0
info:
  title: Devic.ai Public API
  description: >-
    Devic.ai is an AI platform that allows you to create, manage, and use AI
    agents for various tasks.
  version: 1.0.0
  contact:
    name: Devic.ai Support
    url: https://devic.ai
  x-logo:
    url: https://devic.ai/logo.png
    altText: Devic.ai Logo
  x-summary: Public API for interacting with Devic.ai platform
servers:
  - url: https://api.devic.ai
    description: Production server
  - url: https://staging-api.devic.ai
    description: Staging server
security:
  - bearerAuth: []
tags:
  - name: Environments
    description: >-
      The machine an agent works on and everything it may reach: sandbox,
      snapshot, knowledge, tools and encrypted variables
  - name: Sandboxes
    description: >-
      Start a real Linux machine on an environment, run commands and files on
      it, and save its snapshot
  - name: Projects
    description: Group agents, assistants, documents and costs into projects
  - name: Documents
    description: >-
      Knowledge base documents: create, version, attach and index markdown
      content for RAG
  - name: Document Folders
    description: Organise knowledge base documents into folders and attach them in bulk
  - name: Files
    description: Upload files and obtain shareable download URLs to attach to messages
  - name: Agents
    description: Endpoints related to AI agents and their operations
  - name: Assistants
    description: Endpoints for interacting with assistants and their specializations
  - name: Tool Servers
    description: Endpoints for managing tool servers and their tool definitions
  - name: Health
    description: API health check endpoints
  - name: Documentation
    description: Endpoints for retrieving markdown documentation
  - name: Integrations
    description: Connect third-party apps and turn them into tools
  - name: Triggers
    description: Start an agent or an assistant from an app event
  - name: Tenant Integrations
    description: Apps that each end user connects for themselves
  - name: Memory
    description: What an assistant remembers between conversations
  - name: Skills
    description: Reusable instruction packs for agents and assistants
  - name: Speech to Text
    description: Audio transcription
  - name: Tenants
    description: Tenants, subtenants and their usage
  - name: MCP Gateway
    description: One MCP endpoint over many servers, with visibility per user
  - name: Tenant Sessions
    description: Tokens that prove which end user is calling
paths:
  /v1/environments/{environmentId}:
    patch:
      tags:
        - Environments
      summary: Update an environment
      description: >-
        `envVars` replaces the whole map when present. Values read back masked
        and sent again unchanged keep their stored secret, so a
        read-modify-write of the map does not destroy the secrets it did not
        touch.
      operationId: update
      parameters:
        - name: environmentId
          required: true
          in: path
          description: Environment id
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateEnvironmentPublicDto'
      responses:
        '200':
          description: Success
        '400':
          description: Bad request — invalid or inconsistent payload
        '401':
          description: Unauthorized — missing or invalid API key
        '403':
          description: Forbidden — not reachable with this credential
        '404':
          description: Not found
      security:
        - bearerAuth: []
components:
  schemas:
    UpdateEnvironmentPublicDto:
      type: object
      properties:
        name:
          type: string
          description: Environment name
          example: Reporting box
        description:
          type: string
          description: What this environment is for
        projectId:
          type: string
          description: Project id, or null to unassign the environment from its project.
        imgUrl:
          type: string
          description: Image URL for the environment
        availableToolsGroupsUids:
          description: Tool groups (MCPs and built-in tools) available on this environment
          type: array
          items:
            type: string
        knowledgeDocumentIds:
          description: Knowledge documents attached
          type: array
          items:
            type: string
        knowledgeFolderIds:
          description: Knowledge folders attached
          type: array
          items:
            type: string
        knowledgeSkills:
          description: Knowledge skills attached
          type: array
          items:
            $ref: '#/components/schemas/KnowledgeSkillRefDto'
        envVars:
          type: object
          description: >-
            Environment-level variables, encrypted at rest and returned masked.
            Available to every agent and assistant connected to this
            environment.
          example:
            REPORT_RECIPIENT: ops@example.com
        sandboxConfig:
          description: Sandbox configuration
          allOf:
            - $ref: '#/components/schemas/SandboxConfigDto'
    KnowledgeSkillRefDto:
      type: object
      properties:
        id:
          type: string
          description: >-
            The skill document `_id` (document-skill) or folder `_id`
            (folder-skill), as returned by `GET /api/v1/documents/skills`.
        type:
          type: string
          description: >-
            Which of the two shapes `id` refers to. Load-bearing: it decides
            whether the skill is resolved as a document or as a folder at
            runtime, so a wrong value leaves the skill announced but unreadable.
          enum:
            - document
            - folder
        enabled:
          type: boolean
          description: Opt-out switch. Defaults to true when omitted.
        preloadContent:
          type: boolean
          description: >-
            Inlines the whole skill content into the system prompt instead of
            loading it on demand. Defaults to false. Forced in practice when the
            Advanced knowledge search tool group is not attached, since the
            model would have no way to load it.
      required:
        - id
        - type
    SandboxConfigDto:
      type: object
      properties:
        runtime:
          type: string
          description: Base image the sandbox boots from.
          enum:
            - node24
            - node22
            - python3.13
          example: node24
        initScript:
          type: string
          description: >-
            Shell script run when a NEW sandbox is created. Skipped on a restore
            from snapshot, where the work it does is already baked in.
          example: apt-get install -y postgresql-client
        envVars:
          type: object
          description: >-
            Environment variables injected into the machine, encrypted at rest
            and returned masked. Send the whole map: it replaces the stored one.
            A value read back masked and sent again unchanged keeps its stored
            secret.
          example:
            DATABASE_URL: postgres://…
            SSH_PRIVATE_KEY: '-----BEGIN…'
        snapshotEnabled:
          type: boolean
          description: >-
            Save the filesystem when a session ends, so the next one starts
            where the last left off.
        replaceSnapshotOnStop:
          type: boolean
          description: >-
            Replace the snapshot on every session close (an evolving snapshot).
            False pins sessions to a fixed state and discards what they do.
        perTenantSnapshots:
          type: boolean
          description: >-
            Give every tenant its own snapshot, derived from the base one.
            Opt-in.
        persistAfterSessionClose:
          type: boolean
          description: Keep the machine alive after the conversation ends.
        autoExtend:
          type: boolean
          description: >-
            Renew the timeout whenever an operation arrives, so a long task does
            not lose its machine halfway through. Idle sandboxes still expire.
        autoRestart:
          type: boolean
          description: >-
            Restore the sandbox when its public URL is visited and no session is
            running. Opt-out: absent means enabled.
        publicSlug:
          type: string
          description: >-
            Subdomain the snapshot is published under (…​.sandbox.devic.ai).
            Must be a valid DNS label; null releases it.
          example: my-app
        startCommand:
          type: string
          description: >-
            Command run after each restore to bring the published service back
            up. Not the init script: this one runs on every restore.
          example: cd /workspace && npm start
        memoryMib:
          type: number
          description: Memory for the sandbox, in MiB.
          example: 2048
        provider:
          type: string
          description: Sandbox provider. Left unset, the platform default is used.
          enum:
            - vercel
            - devic-sandbox
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use JWT token for authentication

````