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

# Clone an environment

> Clone all published features and plans from the source environment into a target environment. If target_environment_id is provided, entities are cloned into that existing environment. Otherwise a new environment is created from name and type first.



## OpenAPI

````yaml /api-reference/openapi.json post /environments/{id}/clone
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
security: []
paths:
  /environments/{id}/clone:
    post:
      tags:
        - Environments
      summary: Clone an environment
      description: >-
        Clone all published features and plans from the source environment into
        a target environment. If target_environment_id is provided, entities are
        cloned into that existing environment. Otherwise a new environment is
        created from name and type first.
      operationId: cloneEnvironment
      parameters:
        - name: id
          in: path
          description: Source Environment ID
          required: true
          schema:
            type: string
      requestBody:
        description: Clone configuration
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CloneEnvironmentRequest'
        required: true
      responses:
        '202':
          description: Accepted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/models.TemporalWorkflowResult'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CloneEnvironmentRequest:
      type: object
      properties:
        name:
          type: string
          description: >-
            Name of the new environment (required when target_environment_id is
            not provided)
        target_environment_id:
          type: string
          description: >-
            TargetEnvironmentID is the ID of an existing environment to clone
            into (optional).

            When provided, Name and Type are ignored. When omitted, Name and
            Type are required.
        type:
          $ref: '#/components/schemas/types.EnvironmentType'
    models.TemporalWorkflowResult:
      type: object
      properties:
        message:
          type: string
        run_id:
          type: string
        workflow_id:
          type: string
    errors.ErrorResponse:
      type: object
      properties:
        code:
          type: string
          enum:
            - not_found
            - already_exists
            - version_conflict
            - validation_error
            - invalid_operation
            - permission_denied
            - http_client_error
            - database_error
            - system_error
            - internal_error
            - service_unavailable
        details:
          type: object
          additionalProperties:
            type: object
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    types.EnvironmentType:
      type: string
      enum:
        - development
        - production
      x-enum-varnames:
        - EnvironmentDevelopment
        - EnvironmentProduction
      x-speakeasy-name-override: EnvironmentType
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````