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

# Fork environment

> Creates a live fork that inherits everything from this environment and stores only its own overrides and exclusions. Team environments fork into shared (`scope: "org"`, needs Read on the parent and counts toward your environment limit) or personal (`scope: "user"`, needs Read) forks; your own personal environments fork only into personal ones. Other people's personal environments can't be forked. Forks nest at most 3 levels. A shared fork starts with its parent's access grants, and members also need Read on every ancestor to see it.



## OpenAPI

````yaml /openapi.json post /v1/environments/{id}/fork
openapi: 3.1.0
info:
  title: Replicas API
  version: 2.0.0
  description: >-
    Create and control workspaces, and manage the environments, automations, and
    learnings they run with.
servers:
  - url: https://api.replicas.dev
    description: Production API
security:
  - apiKey: []
tags:
  - name: Replica
    description: >-
      A replica is a Replicas workspace: a cloud sandbox where a coding agent
      works on your repositories.
  - name: Chats
    description: Manage the agent chats inside a replica.
  - name: Message queue
    description: Messages waiting for the agent to finish its turn.
  - name: Commands and terminals
    description: Run commands and open shells in a replica.
  - name: Pull requests
    description: Inspect and act on pull requests a replica opened.
  - name: Previews
    description: Public URLs for ports in a replica.
  - name: Canvas
    description: Plans, reports, and other files agents produce.
  - name: Sharing
    description: Add replicas to members' Shared view.
  - name: Environments
    description: >-
      Environments define what a workspace starts with. A fork builds on the
      environments it was forked from.
  - name: Environment variables
    description: Variables injected into workspaces.
  - name: Environment files
    description: Files written into workspaces.
  - name: Environment skills
    description: Agent skills installed into workspaces.
  - name: Environment MCPs
    description: MCP servers available to workspace agents.
  - name: Hooks
    description: Scripts that run when warm pool snapshots build and when workspaces start.
  - name: Warm pools
    description: Pre-built workspaces that start faster.
  - name: Automations
    description: Run agents on schedules and events.
  - name: Repositories
    description: Repositories connected to the organization.
  - name: Learnings
    description: Organization skills every workspace agent loads.
  - name: Agent credentials
    description: >-
      API keys and endpoints that coding agents use. Connect Claude, Codex, and
      Muse subscriptions with the CLI.
  - name: Plugins
    description: Connect integrations that workspace agents can use.
  - name: Organization
    description: Who you are and who is in your organization.
  - name: Media
    description: Screenshots, recordings, and other files workspaces produce.
  - name: Slack
    description: Route Slack threads to workspaces.
  - name: Workspace identity
    description: OIDC keys for verifying workspace identity tokens.
paths:
  /v1/environments/{id}/fork:
    post:
      tags:
        - Environments
      summary: Fork environment
      description: >-
        Creates a live fork that inherits everything from this environment and
        stores only its own overrides and exclusions. Team environments fork
        into shared (`scope: "org"`, needs Read on the parent and counts toward
        your environment limit) or personal (`scope: "user"`, needs Read) forks;
        your own personal environments fork only into personal ones. Other
        people's personal environments can't be forked. Forks nest at most 3
        levels. A shared fork starts with its parent's access grants, and
        members also need Read on every ancestor to see it.
      operationId: forkEnvironment
      parameters:
        - name: id
          in: path
          required: true
          description: Environment UUID.
          schema:
            type: string
        - $ref: '#/components/parameters/ApiVersion'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ForkEnvironmentRequest'
      responses:
        '201':
          description: Fork created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EnvironmentResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  parameters:
    ApiVersion:
      name: X-Replicas-Api-Version
      in: header
      description: >-
        API version. `2026-10-07` returns `snake_case` responses. See
        [versioning](/features/api#versioning).
      required: false
      schema:
        type: string
        enum:
          - '2026-10-07'
  schemas:
    ForkEnvironmentRequest:
      type: object
      properties:
        name:
          type: string
        description:
          type:
            - string
            - 'null'
        scope:
          type: string
          enum:
            - org
            - user
          default: org
      required:
        - name
    EnvironmentResponse:
      type: object
      properties:
        environment:
          $ref: '#/components/schemas/Environment'
      required:
        - environment
    Environment:
      type: object
      description: >-
        The configuration a workspace starts with. An environment builds on its
        `source_environment_id` chain, starting at its root. Personal
        environments have `user_id` set and are visible only to their owner.
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier
        organization_id:
          type: string
          format: uuid
          description: Owning organization
        user_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Owning user for personal environments. Null for team environments.
        name:
          type: string
          description: Human-readable name
        description:
          type:
            - string
            - 'null'
          description: Optional description
        repository_ids:
          type: array
          items:
            type: string
            format: uuid
          description: >-
            Repositories workspaces in this environment clone, in checkout
            order. Inherited from the source environment when
            `inherit_repositories` is true. Empty = repo-less workspace.
        inherit_repositories:
          type: boolean
          description: >-
            True when this environment uses its source environment's
            repositories.
        system_prompt:
          type:
            - string
            - 'null'
          description: Optional system prompt prepended to every workspace's coding agent.
        personal_preferences:
          type:
            - string
            - 'null'
          description: >-
            User-authored instructions appended after the (inherited) system
            prompt. Only settable on personal environments, and editable even on
            forks.
        source_environment_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Parent environment this one forks; unset fields are inherited from
            it. Null for environments that are not forks.
        variable_count:
          type: integer
          description: Number of variables attached to this environment
        file_count:
          type: integer
          description: Number of files
        skill_count:
          type: integer
          description: Number of enabled skills
        mcp_count:
          type: integer
          description: Number of MCPs
        access:
          $ref: '#/components/schemas/EnvironmentAccess'
          description: >-
            Effective permissions for the authenticated member. Omitted from
            internal workspace-authenticated responses.
        status:
          $ref: '#/components/schemas/EnvironmentStatus'
          description: What a workspace created now starts with. Returned by list and get.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      required:
        - id
        - organization_id
        - user_id
        - name
        - description
        - repository_ids
        - inherit_repositories
        - system_prompt
        - personal_preferences
        - source_environment_id
        - created_at
        - updated_at
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
        details:
          type:
            - string
            - 'null'
          description: Additional error details
        code:
          type: string
          description: Machine-readable error code when available
      required:
        - error
    EnvironmentAccess:
      type: object
      description: >-
        Effective permissions for the caller. Read allows discovery, full
        inspection, and selection for workspaces or automations. Write allows
        all mutations and implies Read.
      properties:
        can_write:
          type: boolean
        can_read:
          type: boolean
      required:
        - can_read
        - can_write
    EnvironmentStatus:
      type: object
      description: >-
        `ready`: new workspaces start with the current setup. `applying`:
        `changes` reach new workspaces after `apply_after` (`waiting`) or once
        the warm hook finishes (`running`); until then they start with the
        previous setup. `needs_attention`: the latest changes failed to apply,
        so new workspaces start with the setup that went live at `live_since`.
      properties:
        state:
          type: string
          enum:
            - ready
            - applying
            - needs_attention
        phase:
          type:
            - string
            - 'null'
          enum:
            - waiting
            - running
            - idle
            - null
          description: >-
            `idle`: the environment is unused, so its saved changes build the
            next time someone starts or selects it
        apply_after:
          type:
            - string
            - 'null'
          format: date-time
        live_since:
          type:
            - string
            - 'null'
          format: date-time
          description: When the setup new workspaces start with went live
        first_setup:
          type: boolean
          description: True while applying an environment that has never been set up
        changes:
          type: array
          items:
            $ref: '#/components/schemas/EnvironmentChange'
        failure:
          type:
            - object
            - 'null'
          properties:
            build_id:
              type: string
              format: uuid
            kind:
              type: string
              enum:
                - hook
                - infra
              description: >-
                `hook`: a warm hook failed; it is not retried until the next
                change or an explicit retry
            message:
              type:
                - string
                - 'null'
            failed_at:
              type:
                - string
                - 'null'
              format: date-time
            run_id:
              type:
                - string
                - 'null'
              format: uuid
              description: >-
                The failed warm hook run; its full log is at
                `/v1/environments/{environment_id}/hook-runs/{run_id}`
            exit_code:
              type:
                - integer
                - 'null'
            cause:
              type:
                - object
                - 'null'
              description: >-
                Likely cause, read from the log tail and exit code. Null for
                infrastructure failures.
              properties:
                kind:
                  type: string
                  enum:
                    - timeout
                    - out_of_memory
                    - disk_full
                    - lockfile_mismatch
                    - missing_secret
                    - command_not_found
                    - network
                    - missing_file
                    - exit_code
                summary:
                  type: string
                fix:
                  type: string
                line:
                  type:
                    - string
                    - 'null'
                  description: The log line the cause was read from
              required:
                - kind
                - summary
                - fix
                - line
            log_tail:
              type: array
              items:
                type: string
              description: Last lines of the log
          required:
            - build_id
            - kind
            - message
            - failed_at
            - run_id
            - exit_code
            - cause
            - log_tail
      required:
        - state
        - phase
        - apply_after
        - live_since
        - first_setup
        - changes
        - failure
    EnvironmentChange:
      type: object
      description: One edit waiting to reach new workspaces.
      properties:
        kind:
          type: string
          enum:
            - repositories
            - warm_hook
            - variable
            - file
            - skill
            - skills_registry
            - default_skills
            - agent_auth
            - workspace_size
            - agent_setup
            - restore
            - system
        key:
          type:
            - string
            - 'null'
          description: >-
            The edited row: variable key, file path, skill slug, registry, or
            provider. The new size for `workspace_size`, and what happened for
            `system`
        op:
          type: string
          enum:
            - created
            - updated
            - deleted
        user_id:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Who made the edit. `00000000-0000-0000-0000-000000000000` when
            Replicas made it
      required:
        - kind
        - key
        - op
        - user_id
  responses:
    BadRequest:
      description: Bad request - Missing or invalid parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized - Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden - The authenticated account cannot access this resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: Organization or personal API key from **Settings → API Keys**.

````

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