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

# Update an environment

> Update an environment

> [!NOTE]
>
> Requires an [Account API key](https://nango.dev/docs/reference/backend/http-api/api-keys.md#account-api-keys) with the `account:environments:update` scope.

Partially update environment settings. Omitted fields, including fields inside `webhooks`, retain their existing values.

Changing `is_production` additionally requires `account:environments:set_production`. The reserved `prod` environment cannot be renamed or have its production flag changed.

Changing OpenTelemetry settings requires access to realtime logs export (included with the [Growth add-on](https://www.nango.dev/pricing)).

> [!WARNING]
>
> Supplying `otlp_headers` replaces the entire header set; pass an empty array to clear it.

To import a webhook signing key, use [Rotate the webhook signing key](https://nango.dev/docs/reference/backend/http-api/environments/rotate-webhook-signing-key.md) with an [Environment API key](https://nango.dev/docs/reference/backend/http-api/api-keys.md#environment-api-keys).

The response is an acknowledgement on successful updates or an error on failures. To retrieve the updated configuration, use [Get an environment](https://nango.dev/docs/reference/backend/http-api/environments/get.md) with the required read permissions.


## OpenAPI

````yaml PATCH /environments/{environmentUuid}
openapi: 3.1.0
info:
  title: Nango API
  description: Nango API specs used to authorize & sync data with external APIs.
  version: 1.0.0
servers:
  - url: https://api.nango.dev
    description: Production server
  - url: http://localhost:3003
    description: Local server
security:
  - bearerAuth: []
externalDocs:
  url: https://nango.dev/docs/reference/backend/http-api/authentication
paths:
  /environments/{environmentUuid}:
    patch:
      summary: Update an environment
      description: Update an environment
      operationId: updateEnvironment
      parameters:
        - name: environmentUuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Environment UUID.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                name:
                  type: string
                  description: >-
                    Environment name. Lowercase letters, digits, hyphens, and
                    underscores only. Max 255 characters. The reserved prod
                    environment cannot be renamed.
                  pattern: ^[a-z0-9_-]+$
                  maxLength: 255
                  example: staging
                is_production:
                  type: boolean
                  description: >-
                    Change the production flag. Requires
                    account:environments:set_production in addition to
                    account:environments:update. The reserved prod environment
                    cannot have its production flag changed.
                callback_url:
                  type: string
                  format: uri
                  description: Custom OAuth callback URL for this environment.
                slack_notifications:
                  type: boolean
                  description: >-
                    Whether Slack notifications are enabled for this
                    environment.
                otlp_endpoint:
                  type: string
                  description: >-
                    OpenTelemetry collector endpoint. Requires a plan with
                    OpenTelemetry export. Pass an empty string to set an empty
                    endpoint.
                otlp_headers:
                  type: array
                  description: >-
                    Headers sent with OpenTelemetry export requests. Requires a
                    plan with OpenTelemetry export. Replaces the entire header
                    set; pass an empty array to clear it. Omitted headers are
                    preserved. Maximum 100 headers.
                  maxItems: 100
                  items:
                    type: object
                    required:
                      - name
                      - value
                    properties:
                      name:
                        type: string
                        minLength: 1
                        maxLength: 256
                      value:
                        type: string
                        minLength: 1
                        maxLength: 4000
                webhooks:
                  type: object
                  additionalProperties: false
                  description: >-
                    Partial webhook settings. Omitted fields retain their
                    existing values.
                  properties:
                    primary_url:
                      type:
                        - string
                        - 'null'
                      description: >-
                        First webhook destination. Use an empty string for no
                        destination. Pass null to clear the URL.
                    secondary_url:
                      type:
                        - string
                        - 'null'
                      description: >-
                        Second webhook destination. Webhooks are sent to both
                        configured URLs. Use an empty string for no destination.
                        Pass null to clear the URL.
                    on_sync_completion_always:
                      type: boolean
                      description: >-
                        Send sync completion webhooks even when no records were
                        added, updated, or deleted.
                    on_auth_creation:
                      type: boolean
                      description: Send webhooks when connections are created.
                    on_auth_refresh_error:
                      type: boolean
                      description: >-
                        Send webhooks when refreshing connection credentials
                        fails.
                    on_sync_error:
                      type: boolean
                      description: Send webhooks when sync functions fail.
                    on_async_action_completion:
                      type: boolean
                      description: >-
                        Send webhooks when asynchronous action functions
                        complete.
                    on_connection_deletion:
                      type: boolean
                      description: Send webhooks when connections are deleted.
      responses:
        '200':
          description: Successfully updated the environment.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                properties:
                  success:
                    type: boolean
                    const: true
                    example: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: An environment with this name already exists.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StdError'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
    ServerError:
      description: Server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/StdError'
  schemas:
    StdError:
      type: object
      additionalProperties: false
      properties:
        error:
          type: object
          additionalProperties: false
          required:
            - code
          properties:
            code:
              type: string
            message:
              type: string
            errors:
              type: array
              items:
                type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An Environment API key from your Nango environment, or an Account API
        key for account-level endpoints.

````

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