---
title: "Set Container Environment Variables"
method: PUT
path: "/apps/{appId}/containers/{containerId}/env"
tags: ["Containers"]
---

# Set Container Environment Variables

`PUT /apps/{appId}/containers/{containerId}/env`

## Request

- Base URL: `https://api.bunny.net/mc`
- URL: `https://api.bunny.net/mc/apps/{appId}/containers/{containerId}/env`
- Auth: API key in header `AccessKey`
- TypeScript: <https://skmtc.dev/bunny/apis/magic-containers-api/docs/apps/:appId/containers/:containerId/env/put.ts> (a function with typed inputs; its response is checked against the schema)

Replaces all environment variables for a container template. All existing environment variables will be removed and replaced with the provided set.

## Path parameters

- `appId` string, required
- `containerId` string, required

## Request body

- object

## Response `200`

Environment variables were successfully replaced.

- ContainerTemplate: Container template model
  - `id` string, required
  - `name` string, required
  - `packageId` string, required
  - `image` string, required
  - `imageName` string, required
  - `imageNamespace` string, required
  - `imageTag` string, required
  - `imageRegistryId` string, required
  - `imageDigest` string, required
  - `imagePullPolicy` 'always' | 'ifNotPresent', required
  - `entryPoint` ContainerEntryPoint, required
    - `command` string, nullable
    - `commandArray` string[], nullable
    - `arguments` string, nullable
    - `argumentsArray` string[], nullable
    - `workingDirectory` string, nullable
  - `probes` ContainerProbes, required
    - `startup` ContainerProbe
      - `initialDelaySeconds` integer, nullable
      - `periodSeconds` integer, nullable
      - `timeoutSeconds` integer, nullable
      - `failureThreshold` integer, nullable
      - `successThreshold` integer, nullable
      - `httpGet` HttpGetProbe
        - `request` HttpGetProbeRequestDetails
          - `path` string
          - `portNumber` integer
        - `response` HttpGetProbeResponseDetails
          - `expectedStatusCode` 'continue' | 'switchingProtocols' | 'processing' | 'earlyHints' | 'ok' | 'created' | 'accepted' | 'nonAuthoritativeInformation' | 'noContent' | 'resetContent' | 'partialContent' | 'multiStatus' | 'alreadyReported' | 'imUsed' | 'multipleChoices' | 'movedPermanently' | 'found' | 'seeOther' | 'notModified' | 'useProxy' | 'unused' | 'temporaryRedirect' | 'permanentRedirect' | 'badRequest' | 'unauthorized' | 'paymentRequired' | 'forbidden' | 'notFound' | 'methodNotAllowed' | 'notAcceptable' | 'proxyAuthenticationRequired' | 'requestTimeout' | 'conflict' | 'gone' | 'lengthRequired' | 'preconditionFailed' | 'requestEntityTooLarge' | 'requestUriTooLong' | 'unsupportedMediaType' | 'requestedRangeNotSatisfiable' | 'expectationFailed' | 'misdirectedRequest' | 'unprocessableEntity' | 'locked' | 'failedDependency' | 'upgradeRequired' | 'preconditionRequired' | 'tooManyRequests' | 'requestHeaderFieldsTooLarge' | 'unavailableForLegalReasons' | 'internalServerError' | 'notImplemented' | 'badGateway' | 'serviceUnavailable' | 'gatewayTimeout' | 'httpVersionNotSupported' | 'variantAlsoNegotiates' | 'insufficientStorage' | 'loopDetected' | 'notExtended' | 'networkAuthenticationRequired'
      - `tcpSocket` TcpSocketProbe
        - `request` TcpSocketProbeRequestDetails
          - `portNumber` integer
      - `grpc` GrpcProbe
        - `request` GrpcProbeRequestDetails
          - `portNumber` integer
          - `serviceName` string, nullable: If this is not specified, the default behavior is to probe the server's overall health status.
    - `readiness` ContainerProbe
      - `initialDelaySeconds` integer, nullable
      - `periodSeconds` integer, nullable
      - `timeoutSeconds` integer, nullable
      - `failureThreshold` integer, nullable
      - `successThreshold` integer, nullable
      - `httpGet` HttpGetProbe
        - `request` HttpGetProbeRequestDetails
          - `path` string
          - `portNumber` integer
        - `response` HttpGetProbeResponseDetails
          - `expectedStatusCode` 'continue' | 'switchingProtocols' | 'processing' | 'earlyHints' | 'ok' | 'created' | 'accepted' | 'nonAuthoritativeInformation' | 'noContent' | 'resetContent' | 'partialContent' | 'multiStatus' | 'alreadyReported' | 'imUsed' | 'multipleChoices' | 'movedPermanently' | 'found' | 'seeOther' | 'notModified' | 'useProxy' | 'unused' | 'temporaryRedirect' | 'permanentRedirect' | 'badRequest' | 'unauthorized' | 'paymentRequired' | 'forbidden' | 'notFound' | 'methodNotAllowed' | 'notAcceptable' | 'proxyAuthenticationRequired' | 'requestTimeout' | 'conflict' | 'gone' | 'lengthRequired' | 'preconditionFailed' | 'requestEntityTooLarge' | 'requestUriTooLong' | 'unsupportedMediaType' | 'requestedRangeNotSatisfiable' | 'expectationFailed' | 'misdirectedRequest' | 'unprocessableEntity' | 'locked' | 'failedDependency' | 'upgradeRequired' | 'preconditionRequired' | 'tooManyRequests' | 'requestHeaderFieldsTooLarge' | 'unavailableForLegalReasons' | 'internalServerError' | 'notImplemented' | 'badGateway' | 'serviceUnavailable' | 'gatewayTimeout' | 'httpVersionNotSupported' | 'variantAlsoNegotiates' | 'insufficientStorage' | 'loopDetected' | 'notExtended' | 'networkAuthenticationRequired'
      - `tcpSocket` TcpSocketProbe
        - `request` TcpSocketProbeRequestDetails
          - `portNumber` integer
      - `grpc` GrpcProbe
        - `request` GrpcProbeRequestDetails
          - `portNumber` integer
          - `serviceName` string, nullable: If this is not specified, the default behavior is to probe the server's overall health status.
    - `liveness` ContainerProbe
      - `initialDelaySeconds` integer, nullable
      - `periodSeconds` integer, nullable
      - `timeoutSeconds` integer, nullable
      - `failureThreshold` integer, nullable
      - `successThreshold` integer, nullable
      - `httpGet` HttpGetProbe
        - `request` HttpGetProbeRequestDetails
          - `path` string
          - `portNumber` integer
        - `response` HttpGetProbeResponseDetails
          - `expectedStatusCode` 'continue' | 'switchingProtocols' | 'processing' | 'earlyHints' | 'ok' | 'created' | 'accepted' | 'nonAuthoritativeInformation' | 'noContent' | 'resetContent' | 'partialContent' | 'multiStatus' | 'alreadyReported' | 'imUsed' | 'multipleChoices' | 'movedPermanently' | 'found' | 'seeOther' | 'notModified' | 'useProxy' | 'unused' | 'temporaryRedirect' | 'permanentRedirect' | 'badRequest' | 'unauthorized' | 'paymentRequired' | 'forbidden' | 'notFound' | 'methodNotAllowed' | 'notAcceptable' | 'proxyAuthenticationRequired' | 'requestTimeout' | 'conflict' | 'gone' | 'lengthRequired' | 'preconditionFailed' | 'requestEntityTooLarge' | 'requestUriTooLong' | 'unsupportedMediaType' | 'requestedRangeNotSatisfiable' | 'expectationFailed' | 'misdirectedRequest' | 'unprocessableEntity' | 'locked' | 'failedDependency' | 'upgradeRequired' | 'preconditionRequired' | 'tooManyRequests' | 'requestHeaderFieldsTooLarge' | 'unavailableForLegalReasons' | 'internalServerError' | 'notImplemented' | 'badGateway' | 'serviceUnavailable' | 'gatewayTimeout' | 'httpVersionNotSupported' | 'variantAlsoNegotiates' | 'insufficientStorage' | 'loopDetected' | 'notExtended' | 'networkAuthenticationRequired'
      - `tcpSocket` TcpSocketProbe
        - `request` TcpSocketProbeRequestDetails
          - `portNumber` integer
      - `grpc` GrpcProbe
        - `request` GrpcProbeRequestDetails
          - `portNumber` integer
          - `serviceName` string, nullable: If this is not specified, the default behavior is to probe the server's overall health status.
  - `environmentVariables` EnvironmentVariable[], required
    - `name` string, required
    - `value` string
  - `endpoints` ContainerEndpoint[], required
    - `id` string, required: Unique endpoint id. Use this value as `container_endpoint_id` when creating a pull zone that targets this endpoint.
    - `displayName` string, required
    - `publicHost` string, required
    - `type` 'cdn' | 'anycast' | 'publicIp', required
    - `isSslEnabled` boolean, required
    - `pullZoneId` string, required
    - `portMappings` EndpointPortMapping[], required
      - `containerPort` integer, required
      - `exposedPort` integer, required
      - `protocols` ProtocolV3[], required
    - `stickySessions` EndpointStickySession
      - `enabled` boolean, required
      - `sessionHeaders` string[], required
      - `cookieName` string, required
    - `internalIpAddresses` EndpointInternalIp[], nullable
      - `address` string, required
      - `region` string, required
    - `publicIpAddresses` EndpointInternalIp[], nullable
      - `address` string, required
      - `region` string, required
  - `volumeMounts` ContainerVolumeMount[], required
    - `name` string, required
    - `mountPath` string, required

## Other responses

- `400`: Invalid input.
- `401`: User is unauthorized.
- `403`: User has invalid card or suspended.
- `404`: Application or container template not found.
- `500`: Unexpected server error.

## Changes

- **2026-08-08** `0054dcaa32fb`: 1 info
  - added the required property `endpoints/items/id` to the response with the `200` status
- **2026-04-26** `62fb48c758fb`: 191 warning, 199 info
  - added the new `accepted` enum value to the `probes/liveness/httpGet/response/expectedStatusCode` response property for the response status `200`
  - added the new `accepted` enum value to the `probes/readiness/httpGet/response/expectedStatusCode` response property for the response status `200`
  - added the new `accepted` enum value to the `probes/startup/httpGet/response/expectedStatusCode` response property for the response status `200`
  - added the new `alreadyReported` enum value to the `probes/liveness/httpGet/response/expectedStatusCode` response property for the response status `200`
  - …386 more

[Operation history](https://skmtc.dev/bunny/apis/magic-containers-api/changes/apps/:appId/containers/:containerId/env/put.md)

---

[API](https://skmtc.dev/bunny/apis/magic-containers-api.md) - [All operations](https://skmtc.dev/bunny/apis/magic-containers-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bunny/apis/magic-containers-api/revisions/7bb58a0591b0?raw)
