---
updatedAt: 2025-08-27T17:32:05.000Z
agentTools:
  projectIndex: https://documentation.bunnyshell.com/llms.txt
---

# Creates a new environment.

Creates a new environment.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "API Bunnyshell Environments",
    "description": "Interact with Bunnyshell Platform",
    "termsOfService": "https://www.bunnyshell.com/bunnyshell-customer-agreement/",
    "contact": {
      "name": "API Support",
      "url": "https://www.bunnyshell.com/",
      "email": "osi+support@bunnyshell.com"
    },
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "api.environments.bunnyshell.com/",
      "description": ""
    }
  ],
  "paths": {
    "/v1/environments": {
      "post": {
        "operationId": "environmentCreate",
        "tags": [
          "environment"
        ],
        "responses": {
          "200": {
            "description": "environment resource created",
            "content": {
              "application/hal+json": {
                "schema": {
                  "$ref": "#/components/schemas/environment-item"
                }
              }
            },
            "links": {}
          },
          "400": {
            "description": "Invalid input"
          },
          "422": {
            "description": "Unprocessable entity"
          },
          "4XX": {
            "description": "Request Error",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/problem.generic"
                }
              }
            }
          }
        },
        "summary": "Creates a new environment.",
        "description": "Creates a new environment.",
        "parameters": [],
        "requestBody": {
          "description": "The new environment resource",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/environment.CreateAction"
              }
            }
          },
          "required": true
        },
        "deprecated": false
      },
      "parameters": []
    }
  },
  "components": {
    "schemas": {
      "BuildSettings-item": {
        "type": "object",
        "properties": {
          "useManagedRegistry": {
            "description": "Use the managed container registry.",
            "type": "boolean"
          },
          "registryIntegration": {
            "description": "The Container Registry used for the built images.",
            "type": "string",
            "nullable": true
          },
          "useManagedCluster": {
            "description": "Use the managed builds Cluster.",
            "type": "boolean"
          },
          "kubernetesIntegration": {
            "description": "The Kubernetes integration cluster used for the image builds.",
            "type": "string",
            "nullable": true
          },
          "cpu": {
            "description": "The CPU allocated for the build runner.",
            "type": "string",
            "nullable": true
          },
          "memory": {
            "description": "The memory allocated for the build runner.",
            "type": "integer",
            "nullable": true
          },
          "lastStatus": {
            "description": "The latest status of the build settings.",
            "type": "string",
            "nullable": true
          },
          "lastError": {
            "description": "The latest status of the build settings.",
            "type": "string",
            "nullable": true
          }
        }
      },
      "FromGit": {
        "type": "object",
        "properties": {
          "type": {
            "default": "git",
            "example": "git",
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "branch": {
            "type": "string"
          },
          "yamlPath": {
            "type": "string"
          }
        }
      },
      "FromGitSpec": {
        "type": "object",
        "properties": {
          "type": {
            "default": "git-spec",
            "example": "git-spec",
            "type": "string"
          },
          "spec": {
            "type": "string"
          }
        }
      },
      "FromString": {
        "type": "object",
        "properties": {
          "type": {
            "default": "string",
            "example": "string",
            "type": "string"
          },
          "yaml": {
            "type": "string"
          }
        }
      },
      "FromTemplate": {
        "type": "object",
        "properties": {
          "type": {
            "default": "template",
            "example": "template",
            "type": "string"
          },
          "variables": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "integer"
                },
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          },
          "template": {
            "type": "string"
          }
        }
      },
      "PrimaryOptionsCreate": {
        "type": "object",
        "properties": {
          "whitelistEnabled": {
            "type": "boolean"
          },
          "branchWhitelist": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "environment-item": {
        "type": "object",
        "description": "An environment holds a collection of buildable and deployable components.",
        "properties": {
          "id": {
            "readOnly": true,
            "description": "Environment identifier.",
            "type": "string"
          },
          "labels": {
            "readOnly": true,
            "description": "Environment labels.",
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "type": {
            "readOnly": true,
            "description": "Environment type: primary or ephemeral.",
            "type": "string"
          },
          "name": {
            "readOnly": true,
            "description": "Environment name.",
            "type": "string"
          },
          "namespace": {
            "readOnly": true,
            "description": "Environment k8s namespace.",
            "type": "string"
          },
          "totalComponents": {
            "readOnly": true,
            "description": "Service component identifier",
            "type": "integer"
          },
          "operationStatus": {
            "readOnly": true,
            "description": "Environment operation status.",
            "type": "string"
          },
          "clusterStatus": {
            "readOnly": true,
            "description": "Environment cluster status.",
            "type": "string"
          },
          "buildSettings": {
            "readOnly": true,
            "description": "Environment build settings.",
            "anyOf": [
              {
                "$ref": "#/components/schemas/BuildSettings-item"
              },
              {
                "type": "null"
              }
            ]
          },
          "project": {
            "readOnly": true,
            "description": "Project identifier.",
            "type": "string"
          },
          "kubernetesIntegration": {
            "readOnly": true,
            "description": "Kubernetes integration identifier.",
            "type": "string",
            "nullable": true
          },
          "ephemeralKubernetesIntegration": {
            "readOnly": true,
            "description": "Kubernetes integration identifier for the ephemeral auto deploy cluster.",
            "type": "string",
            "nullable": true
          },
          "hasTerminationProtection": {
            "readOnly": true,
            "description": "Environment termination protection.",
            "type": "boolean"
          },
          "hasEphemeralAutoDeploy": {
            "readOnly": true,
            "description": "Environment ephemeral auto deploy status.",
            "type": "boolean"
          },
          "hasEphemeralCreateOnPr": {
            "readOnly": true,
            "description": "Environment ephemeral create-on-PR status.",
            "type": "boolean"
          },
          "hasEphemeralDestroyOnPrClose": {
            "readOnly": true,
            "description": "Environment ephemeral destroy-on-PR close status.",
            "type": "boolean"
          },
          "hasEphemeralBranchWhitelist": {
            "readOnly": true,
            "description": "Environment ephemeral branch whitelist status.",
            "type": "boolean"
          },
          "ephemeralBranchWhitelistRegex": {
            "readOnly": true,
            "description": "Environment ephemeral branch whitelist regex.",
            "type": "string",
            "nullable": true
          }
        }
      },
      "environment.CreateAction": {
        "type": "object",
        "description": "An environment holds a collection of buildable and deployable components.",
        "required": [
          "name",
          "project"
        ],
        "properties": {
          "name": {
            "maxLength": 255,
            "type": "string"
          },
          "project": {
            "type": "string"
          },
          "genesis": {
            "description": "The environment creation method",
            "oneOf": [
              {
                "$ref": "#/components/schemas/FromGit"
              },
              {
                "$ref": "#/components/schemas/FromGitSpec"
              },
              {
                "$ref": "#/components/schemas/FromString"
              },
              {
                "$ref": "#/components/schemas/FromTemplate"
              }
            ]
          },
          "type": {
            "type": "string"
          },
          "remoteDevelopmentAllowed": {
            "type": "boolean"
          },
          "autoUpdate": {
            "type": "boolean"
          },
          "terminationProtection": {
            "type": "boolean"
          },
          "createEphemeralOnPrCreate": {
            "type": "boolean"
          },
          "destroyEphemeralOnPrClose": {
            "type": "boolean"
          },
          "autoDeployEphemeral": {
            "type": "boolean"
          },
          "kubernetesIntegration": {
            "type": "string",
            "nullable": true
          },
          "ephemeralKubernetesIntegration": {
            "type": "string",
            "nullable": true
          },
          "labels": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "primaryOptions": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PrimaryOptionsCreate"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "problem.generic": {
        "type": "object",
        "description": "Generic Error",
        "properties": {
          "title": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "violations": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/problem.violation"
            }
          }
        }
      },
      "problem.violation": {
        "type": "object",
        "description": "A validation error",
        "properties": {
          "propertyPath": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    },
    "securitySchemes": {
      "oauth": {
        "type": "oauth2",
        "description": "OAuth 2.0 password Grant",
        "flows": {
          "password": {
            "tokenUrl": "/token",
            "refreshUrl": "refresh",
            "scopes": {}
          }
        }
      },
      "ApiKeyAuth": {
        "type": "apiKey",
        "description": "Value for the X-Auth-Token header parameter.",
        "name": "X-Auth-Token",
        "in": "header"
      },
      "JWT": {
        "type": "apiKey",
        "description": "Value for the Authorization header parameter.",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "oauth": []
    },
    {
      "ApiKeyAuth": []
    },
    {
      "JWT": []
    }
  ],
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```