{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Create Environment",
  "description": "Create a new environment. Environments are isolated deployment contexts like production, staging, or development, each with independent secrets and configurations.",
  "type": "object",
  "required": ["name", "id"],
  "properties": {
    "name": {
      "type": "string",
      "title": "Environment Name",
      "description": "A human-readable name for the environment",
      "minLength": 1,
      "examples": ["Production", "Staging", "Development", "Preview"]
    },
    "id": {
      "type": "string",
      "title": "Environment ID",
      "description": "A short, memorable identifier for looking up this environment in the API and CLI. This becomes the second segment of package identifiers. For example, project 'ecomm' with environment 'prod' and component 'db' creates 'ecomm-prod-db'. Use familiar names like 'prod', 'staging', 'dev'—human-readable, not a UUID. Max 20 characters, lowercase alphanumeric only (a-z, 0-9). Immutable after creation.",
      "minLength": 1,
      "maxLength": 20,
      "pattern": "^[a-z0-9]{1,20}$",
      "examples": ["prod", "staging", "dev", "preview"]
    },
    "description": {
      "type": "string",
      "title": "Environment Description",
      "description": "An optional description of the environment's purpose",
      "maxLength": 255,
      "examples": ["Production environment for customer-facing services"]
    },
    "attributes": {
      "type": "object",
      "title": "Attributes",
      "description": "Key-value attributes for this environment. Keys and values must be strings. Must conform to the organization's custom attributes for the environment scope.",
      "additionalProperties": { "type": "string" },
      "default": {},
      "x-gql-type": "map"
    },
    "decommissionProtection": {
      "type": "boolean",
      "title": "Decommission Protection",
      "description": "When true, blocks `decommissionEnvironment` and any per-instance deployment with `action: DECOMMISSION` against this environment. Disable it via `updateEnvironment` before tearing down. Defaults to false.",
      "default": false
    },
    "separationOfDuty": {
      "type": "boolean",
      "title": "Separation of Duty",
      "description": "When true, `approveDeployment` rejects any approval from the account or service account that proposed the deployment — a proposal in this environment has to be approved by a second reviewer. Proposers can still reject their own proposals with `rejectDeployment`. Defaults to false.",
      "default": false
    }
  }
}
