> ## 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.

# Set Workspace Environment

> Set whether deploying this workspace to an environment requires its test cases, and which of that environment's users they answer as. For production this is the workspace's CI switch.



## OpenAPI

````yaml patch /v2/api/projects/{projectId}/workspaces/{workspaceId}/environments/{environment}
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}/workspaces/{workspaceId}/environments/{environment}:
    patch:
      summary: Set whether deploying this workspace to an enviro…
      description: >-
        Set whether deploying this workspace to an environment requires its test
        cases, and which of that environment's users they answer as. For
        production this is the workspace's CI switch.
      operationId: PatchV2ApiProjectsProjectIdWorkspacesWorkspaceIdEnvironmentsEnvironment
      parameters:
        - name: projectId
          in: path
          required: true
          description: The project the workspace belongs 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 workspace belongs to.
        - name: workspaceId
          in: path
          required: true
          description: The workspace.
          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 workspace.
        - name: environment
          in: path
          required: true
          description: 'The environment''s slug: `production` or one the project created.'
          schema:
            type: string
            description: 'The environment''s slug: `production` or one the project created.'
      requestBody:
        description: >-
          PATCH
          /v2/api/projects/:projectId/workspaces/:workspaceId/environments/:environment
          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})$
                requireTests:
                  description: >-
                    Whether deploying to this environment replays the test cases
                    first. For production this writes the workspace's CI switch.
                  type: boolean
                testProjectUserId:
                  description: >-
                    The project user test cases answer as when deploying here;
                    must belong to this environment. Null clears it.
                  type:
                    - string
                    - 'null'
              required: []
            examples:
              example1:
                value:
                  apiKey: up_embed_************
                  organizationId: 123e4567-e89b-12d3-a456-426614174000
      responses:
        '200':
          description: >-
            PATCH
            /v2/api/projects/:projectId/workspaces/:workspaceId/environments/:environment
            Positive response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: success
                  data:
                    type: object
                    properties:
                      environment:
                        type: string
                        description: >-
                          The environment's slug: `production` or one the
                          project created.
                      name:
                        type: string
                        description: The environment's display name.
                      isDefault:
                        type: boolean
                        description: True for production.
                      version:
                        type:
                          - integer
                          - 'null'
                        minimum: -9007199254740991
                        maximum: 9007199254740991
                      connectionId:
                        type:
                          - string
                          - 'null'
                      connectionStatus:
                        type: string
                        enum:
                          - mapped
                          - unmapped
                        description: >-
                          `unmapped` when the environment has no mapping for
                          that connection: its requests are refused until one is
                          added.
                      requireTests:
                        type: boolean
                        description: >-
                          Whether deploying to this environment replays the test
                          cases first. For production this is the workspace's CI
                          switch or the organization's requirement.
                      requiredByOrganization:
                        type: boolean
                        description: >-
                          True when the organization requires tests on every
                          production deploy, whatever the workspace's own switch
                          says. Always false outside production.
                      testProjectUserId:
                        type:
                          - string
                          - 'null'
                      validationError:
                        type:
                          - string
                          - 'null'
                      lastDeployment:
                        type:
                          - object
                          - 'null'
                        properties:
                          deploymentId:
                            type: string
                            description: The deployment's id.
                          version:
                            type: integer
                            minimum: -9007199254740991
                            maximum: 9007199254740991
                            description: The version it deployed.
                          status:
                            type: string
                            description: pending, running, succeeded, failed or cancelled.
                          createdAt:
                            type: string
                            description: When it was requested.
                          finishedAt:
                            type:
                              - string
                              - 'null'
                        required:
                          - deploymentId
                          - version
                          - status
                          - createdAt
                          - finishedAt
                        additionalProperties: false
                    required:
                      - environment
                      - name
                      - isDefault
                      - version
                      - connectionId
                      - connectionStatus
                      - requireTests
                      - requiredByOrganization
                      - testProjectUserId
                      - validationError
                      - lastDeployment
                    additionalProperties: false
                required:
                  - status
                  - data
                additionalProperties: false
        '400':
          description: >-
            PATCH
            /v2/api/projects/:projectId/workspaces/:workspaceId/environments/:environment
            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.