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

# Migrate the environment routing mode

> Move the environment from `PER_ROUTER_LISTENER_SET` (one router per service) to `PER_HOSTNAME_LISTENER_SET` (one router for the environment), so several services can share a custom domain by path.

Beta: only organizations enabled by Qovery support can migrate. For the others, the response lists the `BETA_FEATURE_NOT_ENABLED` blocker.
Needs the same permission as deploying the environment.

With `dryRun=true`, nothing changes: the response lists the blockers and what the migration would change. Call it first.

Without `dryRun`, the migration is refused with a 409 while any blocker applies. Otherwise it switches the routing mode, updates the services' `HOST_EXTERNAL` and `HOSTS_EXTERNAL` variables to the new hostnames, and queues a deploy of the whole environment.
The deploy installs the environment router next to the service routers, then uninstalls the service routers once the new hostnames serve. Until then the old routing keeps serving.
Legacy Qovery hostnames listed in `legacy_hostnames` stay served until the service is deleted. There is no reverse migration.




## OpenAPI

````yaml /api-reference/openapi.yaml post /environment/{environmentId}/routingMode/migrate
openapi: 3.0.0
info:
  version: 1.0.4
  title: Qovery API
  description: >
    - Qovery is the fastest way to deploy your full-stack apps on any Cloud
    provider.

    - ℹ️ The API is stable and still in development.
  contact:
    name: Qovery Product Team
    url: https://www.qovery.com
    email: support+api+documentation@qovery.com
  x-logo:
    url: https://console.qovery.com/assets/logos/logo-white.svg
    altText: Qovery
servers:
  - url: https://api.qovery.com
security:
  - bearerAuth: []
  - ApiKeyAuth: []
tags:
  - name: Account
  - name: Account Info
  - name: IPs
  - name: Alert Receivers
  - name: Alert Rules
  - name: Admin
  - name: ArgoCD
  - name: Agentic Workflows
  - name: Application
  - name: Application Actions
  - name: Application Build Analysis
  - name: Application Configuration
  - name: Application Database
  - name: Application Deployment Restriction
  - name: Application Deployment History
  - name: Application Environment Variable
  - name: Application Logs
  - name: Application Main Calls
  - name: Application Secret
  - name: Application Annotations Group
  - name: Applications
  - name: AutoscalingPolicy
  - name: Container
  - name: Container Actions
  - name: Container Configuration
  - name: Container Database
  - name: Container Deployment History
  - name: Container Environment Variable
  - name: Container Logs
  - name: Container Main Calls
  - name: Container Registry
  - name: Container Secret
  - name: Container Annotations Group
  - name: Containers
  - name: Deployment Stage Main Calls
  - name: Job
  - name: Job Actions
  - name: Job Build Analysis
  - name: Job Configuration
  - name: Job Database
  - name: Job Deployment Restriction
  - name: Job Deployment History
  - name: Job Environment Variable
  - name: Job Logs
  - name: Job Main Calls
  - name: Job Registry
  - name: Job Secret
  - name: Job Annotations Group
  - name: Jobs
  - name: KedaTriggerAuthentication
  - name: Helm
  - name: Helm Actions
  - name: Helm Configuration
  - name: Helm Database
  - name: Helm Deployment Restriction
  - name: Helm Deployment History
  - name: Helm Logs
  - name: Helm Main Calls
  - name: Helm Repository
  - name: Helms
  - name: Backups
  - name: Billing
  - name: Blueprint Catalog
  - name: Cloud Provider
  - name: Cloud Provider Credentials
  - name: Clusters
  - name: Cluster Deployment History
  - name: Cluster Operator
  - name: Platform Configuration
  - name: Custom Domain
  - name: Container Custom Domain
  - name: LLM Providers
  - name: MCP Servers
  - name: Agent Activity
    description: >-
      What members' coding agents did on Qovery, linked to the skills they
      loaded: skill loads, API calls made from a Qovery skill, Qovery MCP server
      tool calls and policy denials. Built only from what Qovery already
      records. It returns no prompt text and no request content.
  - name: Skill Presets
    description: >-
      A skill preset is how an organization tells its members' coding agents to
      use Qovery: which Qovery skills apply, team instructions on top of them,
      and skills of the organization's own. Admins manage presets and assign
      each one to the organization, to roles or to members. Any member can read
      the preset that applies to them, which is what the agent's Qovery loader
      skill fetches. Every saved preset is inspected for content that could turn
      a member's agent against them, and every create, edit, delete and skill
      load is recorded in the audit log.
  - name: Database
  - name: Database Actions
  - name: Database Application
  - name: Database Container
  - name: Database Deployment History
  - name: Database Main Calls
  - name: Database Annotations Group
  - name: Databases
  - name: Environment
  - name: Environment Actions
  - name: Environment Custom Domain
  - name: Environment Deployment History
  - name: Environment Deployment Rule
  - name: Environment Logs
  - name: Environment Main Calls
  - name: Environment Secret
  - name: Environment Variable
  - name: Environments
  - name: Git
  - name: Github App
  - name: Git repositories
  - name: Members
  - name: Organization
  - name: Organization Account Git Repositories
  - name: Organization Cluster Lock
  - name: Organization Main Calls
  - name: Organization Custom Role
  - name: Organization Custom Domain
  - name: Organization Event
  - name: Organization Api Token
  - name: Organization Policy Api Token
  - name: Organization Webhook
  - name: Organization Annotations Group
  - name: Organization Labels Group
  - name: Organization Enterprise Connection
  - name: Project
  - name: Project Deployment Rule
  - name: Project Environment Variable
  - name: Project Main Calls
  - name: Project Secret
  - name: Projects
  - name: Referral & Rewards
  - name: Secret Manager Access
  - name: Terraforms
  - name: Terraform Main Calls
  - name: Terraform Resources
  - name: Terraform Deployment History
  - name: Terraform Deployment Restriction
  - name: Container Registries
  - name: Helm Repositories
  - name: User Sign Up
  - name: Variable Main Calls
  - name: Helm Custom Domain
  - name: Lifecycle Template Main Calls
  - name: Blueprint Main Calls
  - name: Service Main Calls
paths:
  /environment/{environmentId}/routingMode/migrate:
    post:
      tags:
        - Environment Actions
      summary: Migrate the environment routing mode
      description: >
        Move the environment from `PER_ROUTER_LISTENER_SET` (one router per
        service) to `PER_HOSTNAME_LISTENER_SET` (one router for the
        environment), so several services can share a custom domain by path.


        Beta: only organizations enabled by Qovery support can migrate. For the
        others, the response lists the `BETA_FEATURE_NOT_ENABLED` blocker.

        Needs the same permission as deploying the environment.


        With `dryRun=true`, nothing changes: the response lists the blockers and
        what the migration would change. Call it first.


        Without `dryRun`, the migration is refused with a 409 while any blocker
        applies. Otherwise it switches the routing mode, updates the services'
        `HOST_EXTERNAL` and `HOSTS_EXTERNAL` variables to the new hostnames, and
        queues a deploy of the whole environment.

        The deploy installs the environment router next to the service routers,
        then uninstalls the service routers once the new hostnames serve. Until
        then the old routing keeps serving.

        Legacy Qovery hostnames listed in `legacy_hostnames` stay served until
        the service is deleted. There is no reverse migration.
      operationId: migrateEnvironmentRoutingMode
      parameters:
        - $ref: '#/components/parameters/environmentId'
        - in: query
          name: dryRun
          required: false
          schema:
            type: boolean
            default: false
          description: >-
            When `true`, change nothing and return what the migration would do,
            with its blockers.
      responses:
        '200':
          description: >-
            The migration plan. Without `dryRun`, the migration is committed and
            its deploy is queued.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RoutingModeMigrationResponse'
        '401':
          $ref: '#/components/responses/401'
        '403':
          $ref: '#/components/responses/403'
        '404':
          description: The environment or its cluster is not found.
        '409':
          description: >
            Without `dryRun` only. The environment cannot be migrated now: at
            least one blocker applies (the message lists them, read them with a
            dry run), or the environment cannot be deployed now.

            Nothing was changed.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/RoutingModeMigrationProblemResponse'
        '500':
          description: >
            The deployment status could not be read or the host variables could
            not be updated: nothing was changed.

            Or the migration is committed but its deploy could not be queued,
            and `detail` says so: the old routing keeps serving. Deploy the
            environment to finish the migration; calling this endpoint again
            returns `ALREADY_MIGRATED`.
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/RoutingModeMigrationProblemResponse'
components:
  parameters:
    environmentId:
      name: environmentId
      in: path
      description: Environment ID
      required: true
      schema:
        type: string
        format: uuid
  schemas:
    RoutingModeMigrationResponse:
      type: object
      description: What the routing mode migration changes, or would change on a dry run.
      required:
        - dry_run
        - blockers
        - services
        - unrouted_services
        - services_with_pending_changes
      properties:
        dry_run:
          type: boolean
          description: >-
            `true` when nothing was changed. `false` when the migration is
            committed and its deploy is queued.
        blockers:
          type: array
          description: >-
            Why the migration cannot run now. The migration runs only when this
            is empty. Always empty when `dry_run` is `false`.
          items:
            $ref: '#/components/schemas/RoutingModeMigrationBlocker'
        services:
          type: array
          description: >-
            The services with a public HTTP or gRPC port, which move to the
            environment router. Sorted by `service_id`.
          items:
            $ref: '#/components/schemas/RoutingModeMigrationServiceChange'
        unrouted_services:
          type: array
          description: >-
            The services with a router but no public HTTP or gRPC port. They do
            not join the environment router and lose their host variables.
            Sorted by `service_id`.
          items:
            $ref: '#/components/schemas/RoutingModeMigrationUnroutedService'
        services_with_pending_changes:
          type: array
          description: >-
            IDs of the services not up to date (out of date or never deployed).
            The migration redeploys the whole environment, so their pending
            changes are deployed with it. Services skipped from deployment are
            left out. Sorted.
          items:
            type: string
            format: uuid
    RoutingModeMigrationProblemResponse:
      type: object
      description: A problem detail (RFC 9457).
      required:
        - status
        - title
        - detail
      properties:
        type:
          type: string
          example: about:blank
        title:
          type: string
          example: Conflict
        status:
          type: integer
          example: 409
        detail:
          type: string
          description: Why the request failed. On a 409 for blockers, lists them.
          example: 'The environment cannot be migrated: ENVIRONMENT_STOPPED'
        instance:
          type: string
          description: The request path.
    RoutingModeMigrationBlocker:
      type: string
      description: >
        Why the environment cannot move to `PER_HOSTNAME_LISTENER_SET` now.

        * `BETA_FEATURE_NOT_ENABLED`: the organization is not enabled for the
        beta. Ask Qovery support.

        * `ALREADY_MIGRATED`: the environment already uses
        `PER_HOSTNAME_LISTENER_SET`.

        * `CLUSTER_WITHOUT_GATEWAY_API`: the cluster does not deploy and use the
        Gateway API.

        * `CLUSTER_NOT_READY`: the cluster is not ready for a deployment.

        * `ENVIRONMENT_STOPPED`: the environment is stopped, uninstalled or
        deleted. Start it first.

        * `DEPLOYMENT_IN_PROGRESS`: a deployment is queued or running.

        * `PUBLIC_REGEX_HTTP_PATH`: a public HTTP port uses a regex path. The
        environment router matches path prefixes only.

        * `SEVERAL_PUBLIC_PORTS_NOT_SUPPORTED_YET`: a service has more than one
        public port.

        * `EXPOSED_HELM_NOT_SUPPORTED_YET`: a Helm service has a public port.

        * `PUBLIC_PORT_NOT_DEFAULT_NOT_SUPPORTED_YET`: a service with a public
        HTTP or gRPC port has a private port marked as default. Make the public
        port the default one. A service with no default port is not blocked: the
        deploy marks its public port as default.


        The `NOT_SUPPORTED_YET` values are no longer returned once support
        widens. More values may be added: treat an unknown value as a blocker.
      enum:
        - BETA_FEATURE_NOT_ENABLED
        - ALREADY_MIGRATED
        - CLUSTER_WITHOUT_GATEWAY_API
        - CLUSTER_NOT_READY
        - ENVIRONMENT_STOPPED
        - DEPLOYMENT_IN_PROGRESS
        - PUBLIC_REGEX_HTTP_PATH
        - SEVERAL_PUBLIC_PORTS_NOT_SUPPORTED_YET
        - EXPOSED_HELM_NOT_SUPPORTED_YET
        - PUBLIC_PORT_NOT_DEFAULT_NOT_SUPPORTED_YET
      example: BETA_FEATURE_NOT_ENABLED
    RoutingModeMigrationServiceChange:
      type: object
      description: The Qovery hostname a service gets, and the ones it keeps serving.
      required:
        - service_id
        - service_type
        - legacy_hostname
        - legacy_hostnames
        - new_hostname
        - variables
      properties:
        service_id:
          type: string
          format: uuid
        service_type:
          $ref: '#/components/schemas/RoutingModeMigrationServiceType'
        legacy_hostname:
          type: string
          description: >-
            Current Qovery hostname of the service's default port. Kept served
            until the service is deleted.
        legacy_hostnames:
          type: array
          description: >
            Every current Qovery hostname of the service, kept served until the
            service is deleted. `legacy_hostname` first, then one
            `<portName>-<legacy_hostname>` per public HTTP or gRPC port.

            Computed from the saved port configuration: a port renamed since the
            last deploy is listed under its new name, and the alias of its old
            name is not kept.
          items:
            type: string
        new_hostname:
          type: string
          description: The Qovery hostname the environment router serves for the service.
        variables:
          type: array
          description: >-
            The service's `HOST_EXTERNAL` and `HOSTS_EXTERNAL` variables, moved
            to the new hostname.
          items:
            $ref: '#/components/schemas/RoutingModeMigrationVariableChange'
    RoutingModeMigrationUnroutedService:
      type: object
      description: >-
        A service with a router but no public HTTP or gRPC port. Its host
        variables pointed to a hostname no router served.
      required:
        - service_id
        - service_type
        - removed_variables
      properties:
        service_id:
          type: string
          format: uuid
        service_type:
          $ref: '#/components/schemas/RoutingModeMigrationServiceType'
        removed_variables:
          type: array
          description: >-
            Names of the host variables the migration removes. Each is removed
            only if it exists, so a name listed here may not exist on the
            service. The environment router creates them again if the service
            gets a public port later.
          items:
            type: string
    RoutingModeMigrationServiceType:
      type: string
      description: Type of a service that has its own router.
      enum:
        - APPLICATION
        - CONTAINER
        - HELM
      example: APPLICATION
    RoutingModeMigrationVariableChange:
      type: object
      description: >-
        A built-in host variable, with its value resolved on the legacy and on
        the new hostname. The migration updates the variable, or creates it when
        it does not exist.
      required:
        - name
        - old_value
        - new_value
      properties:
        name:
          type: string
          description: Name of the variable.
        old_value:
          type: string
          description: >-
            Value built from the legacy hostname. Computed, so it does not prove
            the variable exists.
        new_value:
          type: string
          description: Value pointing to the new hostname.
  responses:
    '401':
      description: Access token is missing or invalid
    '403':
      description: Access forbidden
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT tokens should be used with OIDC account (human to machine). JWT
        tokens used by the Qovery console to communicate with the API have a
        TTL. Curl Example ' curl https://console.qovery.com/organization -H
        "Authorization: Bearer $qovery_token" '
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Token API are generated by Qovery to manage machine to machine
        interaction and do not have a TTL. Curl Example ' curl
        https://console.qovery.com/organization -H "Authorization: Token
        $qovery_token" '

````

## Related topics

- [Edit an environment](https://www.qovery.com/docs/api-reference/environment-main-calls/edit-an-environment.md)
- [Environment](https://www.qovery.com/docs/configuration/environment.md)
- [List environments](https://www.qovery.com/docs/api-reference/environments/list-environments.md)
- [Get environment by ID](https://www.qovery.com/docs/api-reference/environment-main-calls/get-environment-by-id.md)
- [Create an environment](https://www.qovery.com/docs/api-reference/environments/create-an-environment.md)


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