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

# Map Environment Connection

> Map a production connection to the connection it means in this environment ("in staging, Warehouse means Warehouse-Staging"). Every workspace whose versions target the source follows it. The two must be of the same type.



## OpenAPI

````yaml put /v2/api/projects/{projectId}/environments/{environment}/connections/{sourceConnectionId}
openapi: 3.1.0
info:
  title: Upsolve API
  version: 1.5.0
servers:
  - url: https://api.upsolve.ai
security: []
tags: []
paths:
  /v2/api/projects/{projectId}/environments/{environment}/connections/{sourceConnectionId}:
    put:
      summary: Map a production connection to the connection it …
      description: >-
        Map a production connection to the connection it means in this
        environment ("in staging, Warehouse means Warehouse-Staging"). Every
        workspace whose versions target the source follows it. The two must be
        of the same type.
      operationId: >-
        PutV2ApiProjectsProjectIdEnvironmentsEnvironmentConnectionsSourceConnectionId
      parameters:
        - name: projectId
          in: path
          required: true
          description: The project the environments belong to.
          schema:
            type: string
            format: uuid
            pattern: >-
              ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
            description: The project the environments belong to.
        - name: environment
          in: path
          required: true
          description: The environment's slug, e.g. `staging`.
          schema:
            type: string
            description: The environment's slug, e.g. `staging`.
        - name: sourceConnectionId
          in: path
          required: true
          description: >-
            The production connection to map: one a workspace in this project
            targets.
          schema:
            type: string
            description: >-
              The production connection to map: one a workspace in this project
              targets.
      requestBody:
        description: >-
          PUT
          /v2/api/projects/:projectId/environments/:environment/connections/:sourceConnectionId
          Request body
        content:
          application/json:
            schema:
              type: object
              properties:
                apiKey:
                  type: string
                  minLength: 1
                  description: >-
                    Upsolve API key, generated under Account → Developer
                    settings in the Upsolve Hub. Keys are user-scoped: pass
                    organizationId alongside the key to select which org to act
                    on.
                  examples:
                    - up_embed_************
                organizationId:
                  description: >-
                    Your Upsolve organization's UUID — the org that owns the API
                    key and project. This is NOT a project organization: do not
                    pass a value registered via /projects/register-organization,
                    and do not pass an `externalId` (only
                    `projectOrganizationId` accepts those). Omit it when using
                    an org-bound API key — the org is read from the key and any
                    value sent here is ignored. Required only for user-scoped
                    API keys (created under Account → Developer settings) and
                    for the Supabase JWT path, where the org is ambiguous and
                    membership is verified against it.
                  examples:
                    - 123e4567-e89b-12d3-a456-426614174000
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$
                connectionId:
                  type: string
                  description: >-
                    The connection the source means in this environment. Must be
                    in this project and of the same type as the source.
              required:
                - connectionId
            examples:
              example1:
                value:
                  apiKey: up_embed_************
                  organizationId: 123e4567-e89b-12d3-a456-426614174000
        required: true
      responses:
        '200':
          description: >-
            PUT
            /v2/api/projects/:projectId/environments/:environment/connections/:sourceConnectionId
            Positive response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: success
                  data:
                    type: object
                    properties:
                      slug:
                        type: string
                        description: >-
                          The environment's identifier, immutable: `production`
                          or the slug it was created with.
                      name:
                        type: string
                        description: The environment's display name.
                      isDefault:
                        type: boolean
                        description: >-
                          True for production: built in, listed first, cannot be
                          renamed or deleted, and where every user is unless
                          they were put elsewhere.
                      connections:
                        type: array
                        items:
                          type: object
                          properties:
                            sourceConnectionId:
                              type: string
                              description: >-
                                The production connection this mapping stands in
                                for: the connection a workspace's versions
                                target.
                            connectionId:
                              type: string
                              description: >-
                                The connection that source means in this
                                environment. May equal the source, for an
                                environment that shares production's data.
                            updatedAt:
                              type:
                                - string
                                - 'null'
                          required:
                            - sourceConnectionId
                            - connectionId
                            - updatedAt
                          additionalProperties: false
                        description: >-
                          The environment's connection mappings. Empty for
                          production, which runs every version on the connection
                          it targets.
                      userCount:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                        description: >-
                          How many project users belong to this environment, the
                          organization members' own users included.
                      organizationCount:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                        description: >-
                          How many project organizations belong to this
                          environment, the members' shadow organization
                          included.
                      memberUserCount:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                        description: >-
                          Of `userCount`, the users Upsolve keeps for each
                          organization member (one per member). They are deleted
                          with the environment, so they do not keep it from
                          being deleted.
                      memberOrganizationCount:
                        type: integer
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                        description: >-
                          Of `organizationCount`, the shadow organization
                          holding the members' users. Deleted with the
                          environment.
                      createdAt:
                        type:
                          - string
                          - 'null'
                    required:
                      - slug
                      - name
                      - isDefault
                      - connections
                      - userCount
                      - organizationCount
                      - memberUserCount
                      - memberOrganizationCount
                      - createdAt
                    additionalProperties: false
                required:
                  - status
                  - data
                additionalProperties: false
        '400':
          description: >-
            PUT
            /v2/api/projects/:projectId/environments/:environment/connections/:sourceConnectionId
            Negative response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: error
                  error:
                    type: object
                    properties:
                      message:
                        type: string
                      code:
                        type: string
                      details:
                        type: object
                        propertyNames:
                          type: string
                        additionalProperties: {}
                    required:
                      - message
                    additionalProperties: false
                required:
                  - status
                  - error
                additionalProperties: false
      security:
        - APIKEY_1: []
components:
  securitySchemes:
    APIKEY_1:
      type: apiKey
      in: query
      name: apiKey
      x-in-actual: body
      description: apiKey MUST be supplied within the request body instead of query

````

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