---
updatedAt: 2026-06-04T20:25:44.000Z
agentTools:
  projectIndex: https://api-docs.render.com/llms.txt
---

# Update environment variables

Replace all environment variables for a service with the provided list of environment variables.

This endpoint updates the list of environment variables for a service to match the request body sent in. Any environment variables that are not included will be removed from the service.

Changes will **not** be deployed automatically. Instead you must call the deploy API to have changes pushed out to your service, irrespective of the `autoDeploy` option set on the service.

# OpenAPI definition

```json
{
  "openapi": "3.0.2",
  "info": {
    "title": "Render Public API",
    "description": "Manage everything about your Render services",
    "version": "1.0.0",
    "contact": {
      "name": "Render API",
      "url": "https://community.render.com",
      "email": "support@render.com"
    }
  },
  "x-readme": {
    "metrics-enabled": false
  },
  "servers": [
    {
      "url": "https://api.render.com/v1"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Services",
      "description": "[Services](https://render.com/docs/service-types) allow you to manage your web services, private services, background workers, cron jobs, and static sites.\n"
    }
  ],
  "paths": {
    "/services/{serviceId}/env-vars": {
      "parameters": [
        {
          "$ref": "#/components/parameters/serviceIdParam"
        }
      ],
      "put": {
        "summary": "Update environment variables",
        "description": "Replace all environment variables for a service with the provided list of environment variables.",
        "operationId": "update-env-vars-for-service",
        "tags": [
          "Services"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "object",
                  "oneOf": [
                    {
                      "type": "object",
                      "required": [
                        "key",
                        "value"
                      ],
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "value": {
                          "type": "string"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "required": [
                        "key",
                        "generateValue"
                      ],
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "generateValue": {
                          "type": "boolean",
                          "description": "If true, Render generates a strong random value for this environment variable on creation. Cannot be combined with `value`."
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/envVarWithCursor"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/400BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/401Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/403Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/404NotFound"
          },
          "406": {
            "$ref": "#/components/responses/406NotAcceptable"
          },
          "410": {
            "$ref": "#/components/responses/410Gone"
          },
          "429": {
            "$ref": "#/components/responses/429RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/500InternalServerError"
          },
          "503": {
            "$ref": "#/components/responses/503ServiceUnavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "parameters": {
      "serviceIdParam": {
        "name": "serviceId",
        "in": "path",
        "required": true,
        "description": "The ID of the service",
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "cursor": {
        "type": "string"
      },
      "envVar": {
        "type": "object",
        "required": [
          "key",
          "value"
        ],
        "properties": {
          "key": {
            "type": "string"
          },
          "value": {
            "type": "string"
          }
        }
      },
      "envVarWithCursor": {
        "type": "object",
        "required": [
          "envVar",
          "cursor"
        ],
        "properties": {
          "envVar": {
            "$ref": "#/components/schemas/envVar"
          },
          "cursor": {
            "$ref": "#/components/schemas/cursor"
          }
        }
      },
      "error": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "A stable, machine-readable identifier present on specific errors that clients can handle specially. Each endpoint documents the codes it can return. The errorCode schema lists the full vocabulary of codes."
          }
        }
      }
    },
    "responses": {
      "400BadRequest": {
        "description": "The request could not be understood by the server.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "401Unauthorized": {
        "description": "Authorization information is missing or invalid.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "403Forbidden": {
        "description": "You do not have permissions for the requested resource. If a scoped API token does not satisfy the endpoint's minimum scope requirements, the response has code insufficient_token_scope and its message lists all minimum required scopes. Broader scopes that include their permissions also satisfy the requirements. Passing this check does not guarantee access to the requested resource or to conditional operations.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "404NotFound": {
        "description": "Unable to find the requested resource.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "406NotAcceptable": {
        "description": "Unable to generate preferred media types as specified by Accept request header.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "410Gone": {
        "description": "The requested resource is no longer available.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "429RateLimit": {
        "description": "Rate limit has been surpassed.\n\nRate-limited endpoints also return `RateLimit-Limit`, `RateLimit-Remaining`, and\n`RateLimit-Reset` on successful responses so clients can track their remaining quota.\n",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying the request.",
            "schema": {
              "type": "integer",
              "example": 30
            }
          },
          "RateLimit-Limit": {
            "description": "Maximum number of requests allowed in the current window.",
            "schema": {
              "type": "integer",
              "example": 100
            }
          },
          "RateLimit-Remaining": {
            "description": "Number of requests remaining in the current window. Always `0` for this response.",
            "schema": {
              "type": "integer",
              "example": 0
            }
          },
          "RateLimit-Reset": {
            "description": "Seconds until the current rate limit window resets.",
            "schema": {
              "type": "integer",
              "example": 30
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            },
            "example": {
              "message": "rate limit exceeded"
            }
          }
        }
      },
      "500InternalServerError": {
        "description": "An unexpected server error has occurred.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "503ServiceUnavailable": {
        "description": "Server currently unavailable.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      }
    }
  }
}
```