{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/oec-sh/json-schema/oec-sh-project-environment-create-schema.json",
  "title": "ProjectEnvironmentCreate",
  "description": "Schema for creating a project environment.",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/oec-sh-api-openapi.json#/components/schemas/ProjectEnvironmentCreate",
  "properties": {
    "name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Name",
      "description": "Environment name (auto-generated if not provided)"
    },
    "env_type": {
      "$ref": "#/$defs/EnvironmentType",
      "description": "Environment type"
    },
    "repository_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Repository Url",
      "description": "Git repo URL override for this environment"
    },
    "git_branch": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Git Branch",
      "description": "Git branch for this environment"
    },
    "odoo_image_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Odoo Image Id",
      "description": "Selected odoo_versions catalog row for this env (#909), overriding the project's. Server-validated as selectable/non-EOL. NULL inherits."
    },
    "template_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Template Id",
      "description": "Deployment template used to pre-fill this environment"
    },
    "migration_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Migration Id",
      "description": "Migration to restore from (if migrating)"
    },
    "vm_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Vm Id",
      "description": "VM/Server to deploy this environment to"
    },
    "domain": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Domain",
      "description": "Custom domain"
    },
    "subdomain": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Subdomain",
      "description": "Subdomain on oec.sh"
    },
    "port": {
      "type": "integer",
      "maximum": 65535.0,
      "minimum": 1.0,
      "title": "Port",
      "description": "Odoo HTTP port",
      "default": 8069
    },
    "db_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Db Name",
      "description": "Database name"
    },
    "auto_deploy": {
      "type": "boolean",
      "title": "Auto Deploy",
      "description": "Auto-deploy on git push (legacy)",
      "default": false
    },
    "auto_deploy_config": {
      "anyOf": [
        {
          "$ref": "#/$defs/AutoDeployConfig"
        },
        {
          "type": "null"
        }
      ],
      "description": "Advanced auto-deployment configuration with branch patterns, cooldown, and path filters"
    },
    "environment_vars": {
      "type": "object",
      "title": "Environment Vars",
      "description": "Environment variables"
    },
    "odoo_config": {
      "anyOf": [
        {
          "$ref": "#/$defs/OdooConfig"
        },
        {
          "type": "null"
        }
      ],
      "description": "Odoo configuration overrides"
    },
    "cpu_cores": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 32.0,
          "minimum": 0.25
        },
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Cpu Cores",
      "description": "Total CPU cores allocated"
    },
    "ram_mb": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 131072.0,
          "minimum": 256.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Ram Mb",
      "description": "Total RAM in MB"
    },
    "disk_gb": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 1000.0,
          "minimum": 1.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Disk Gb",
      "description": "Disk space in GB"
    },
    "postgres_cpu_cores": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 16.0,
          "minimum": 0.1
        },
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Postgres Cpu Cores",
      "description": "PostgreSQL CPU cores (auto-calculated as 30% of total if not set)"
    },
    "postgres_ram_mb": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 65536.0,
          "minimum": 128.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Postgres Ram Mb",
      "description": "PostgreSQL RAM in MB (auto-calculated as 30% of total if not set)"
    },
    "postgres_version": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Postgres Version",
      "description": "PostgreSQL version override (e.g., '15', '16'). Auto-detected if not set."
    },
    "enable_pgtune": {
      "type": "boolean",
      "title": "Enable Pgtune",
      "description": "Enable PGTune automatic PostgreSQL optimization",
      "default": true
    },
    "enable_pgbouncer": {
      "type": "boolean",
      "title": "Enable Pgbouncer",
      "description": "Enable PgBouncer connection pooling",
      "default": true
    },
    "enable_read_replica": {
      "type": "boolean",
      "title": "Enable Read Replica",
      "description": "Enable PostgreSQL read replica (requires Odoo 18+)",
      "default": false
    },
    "with_demo_data": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "With Demo Data",
      "description": "Load demo data into the database. If None, auto-determined by env_type: development=True, staging/production=False. Explicitly setting True/False overrides this behavior."
    },
    "language": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 10
        },
        {
          "type": "null"
        }
      ],
      "title": "Language",
      "description": "Odoo locale code for the database (e.g. 'fr_FR', 'es_ES'). Passed as --load-language to odoo -i base at init time. NULL / absent = en_US (English, no flag needed)."
    },
    "locale": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "en_US",
            "de_DE",
            "fr_FR",
            "es_ES",
            "pt_BR",
            "nl_NL",
            "it_IT",
            "pl_PL",
            "hi_IN",
            "ar_001"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Locale",
      "description": "Closed-allowlist locale code for Odoo DB init. Same intent as `language` but enum-validated. When set, takes precedence over `language`. Whitelist defends against shell injection at the schema layer."
    },
    "load_demo_data": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Load Demo Data",
      "description": "Whether to load Odoo demo data. When None, the route picks the default based on the selected server: demo VMs default to True, regular envs follow env_type semantics (dev=True, stg/prod=False)."
    },
    "subdomain_slug": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 32,
          "minLength": 3,
          "pattern": "^[a-z0-9][a-z0-9-]{1,30}[a-z0-9]$"
        },
        {
          "type": "null"
        }
      ],
      "title": "Subdomain Slug",
      "description": "Vanity subdomain for a demo deploy (e.g. 'acme-demo'). Only used when the selected server has domain_pattern='vanity'. Validated against the 30-day reservation table by the route."
    },
    "captcha_token": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Captcha Token",
      "description": "Cloudflare Turnstile token for demo deploys. Required when the selected server has is_demo=true; ignored otherwise."
    },
    "external_database_connection_id": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "External Database Connection Id",
      "description": "ID of the ExternalDatabaseConnection to use as the primary database cluster. If set, the platform does NOT deploy a PostgreSQL container. Requires Pro plan or higher."
    },
    "external_database_name": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 63
        },
        {
          "type": "null"
        }
      ],
      "title": "External Database Name",
      "description": "Database name on the external cluster. Must match ^[a-z0-9_-]{1,63}$. Defaults to a sanitised environment UUID when omitted."
    }
  },
  "type": "object",
  "required": [
    "env_type"
  ],
  "$defs": {
    "AutoDeployConfig": {
      "properties": {
        "enabled": {
          "type": "boolean",
          "title": "Enabled",
          "description": "Whether auto-deployment is enabled",
          "default": false
        },
        "branch_patterns": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Branch Patterns",
          "description": "Glob patterns for branches to auto-deploy (e.g., 'main', 'release/*', 'feature-*'). Empty = only the environment's own branch; '*' = every branch (#1363)."
        },
        "cooldown_minutes": {
          "type": "integer",
          "maximum": 1440.0,
          "minimum": 0.0,
          "title": "Cooldown Minutes",
          "description": "Minimum time between auto-deploys in minutes (0 = no cooldown)",
          "default": 0
        },
        "include_paths": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Include Paths",
          "description": "Only auto-deploy if changes are in these paths (glob patterns). None = all paths"
        },
        "exclude_paths": {
          "items": {
            "type": "string"
          },
          "type": "array",
          "title": "Exclude Paths",
          "description": "Skip auto-deploy if ONLY these paths changed (e.g., 'docs/*', '*.md')"
        },
        "update_modules": {
          "type": "boolean",
          "title": "Update Modules",
          "description": "#877: also run a module update after the auto-deploy. An auto-deploy pulls the new code and restarts, which is enough for Python/QWeb changes but NOT for schema changes - new fields do not appear until the modules are upgraded. Off by default because a module update takes the environment through a schema upgrade, which is not something to do on every push to a production environment without asking.",
          "default": false
        },
        "deploy_window": {
          "anyOf": [
            {
              "$ref": "#/$defs/DeployWindow"
            },
            {
              "type": "null"
            }
          ],
          "description": "#1260: only deploy pushes inside this window; pushes outside it are held and the latest one deploys when the window opens. null = any time."
        }
      },
      "type": "object",
      "title": "AutoDeployConfig",
      "description": "Auto-deployment rule configuration.\n\nControls automatic deployment behavior based on branch patterns, cooldown periods,\nand file path filters. Similar to GitHub Actions / GitLab CI patterns but simpler."
    },
    "DeployWindow": {
      "properties": {
        "timezone": {
          "type": "string",
          "maxLength": 64,
          "title": "Timezone",
          "description": "IANA timezone, e.g. Europe/Rome"
        },
        "days": {
          "items": {
            "type": "integer"
          },
          "type": "array",
          "title": "Days",
          "description": "Weekdays the window opens on, Mon=0 .. Sun=6"
        },
        "start": {
          "type": "string",
          "title": "Start",
          "description": "Opening time, HH:MM"
        },
        "end": {
          "type": "string",
          "title": "End",
          "description": "Closing time, HH:MM (before start = overnight)"
        }
      },
      "type": "object",
      "required": [
        "timezone",
        "days",
        "start",
        "end"
      ],
      "title": "DeployWindow",
      "description": "#1260: pushes outside this window are held and deploy when it opens.\n\n``days`` are ISO weekdays from 0 (Mon=0) and name the day the window\nOPENS; an overnight window (``end`` before ``start``) closes the next day.\nTimes are wall-clock in ``timezone``, so 02:00 stays 02:00 across DST."
    },
    "EnvironmentType": {
      "type": "string",
      "enum": [
        "development",
        "staging",
        "production"
      ],
      "title": "EnvironmentType",
      "description": "Project environment types."
    },
    "OdooAdvancedConfig": {
      "properties": {
        "server_wide_modules": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Server Wide Modules",
          "description": "Comma-separated list of always-loaded modules (default: 'base,web')"
        },
        "unaccent": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Unaccent",
          "description": "Enable PostgreSQL unaccent extension for better search"
        },
        "geoip_database": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Geoip Database",
          "description": "Path to GeoIP database for geolocation"
        },
        "csv_internal_sep": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 1
            },
            {
              "type": "null"
            }
          ],
          "title": "Csv Internal Sep",
          "description": "CSV internal separator character (default: ',')"
        },
        "osv_memory_age_limit": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Osv Memory Age Limit",
          "description": "OSV memory record age limit in hours"
        },
        "osv_memory_count_limit": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Osv Memory Count Limit",
          "description": "Maximum number of OSV memory records"
        },
        "proxy_mode": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Proxy Mode",
          "description": "Enable proxy mode (required behind reverse proxy like Traefik/Nginx)"
        }
      },
      "type": "object",
      "title": "OdooAdvancedConfig",
      "description": "Advanced configuration settings."
    },
    "OdooConfig": {
      "properties": {
        "preset": {
          "anyOf": [
            {
              "$ref": "#/$defs/OdooConfigPreset"
            },
            {
              "type": "null"
            }
          ],
          "description": "Apply a predefined configuration preset"
        },
        "performance": {
          "anyOf": [
            {
              "$ref": "#/$defs/OdooPerformanceConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Performance and resource limit settings"
        },
        "logging": {
          "anyOf": [
            {
              "$ref": "#/$defs/OdooLoggingConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Logging configuration"
        },
        "email": {
          "anyOf": [
            {
              "$ref": "#/$defs/OdooEmailConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Email/SMTP settings"
        },
        "security": {
          "anyOf": [
            {
              "$ref": "#/$defs/OdooSecurityConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Security settings"
        },
        "development": {
          "anyOf": [
            {
              "$ref": "#/$defs/OdooDevelopmentConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Development and testing settings"
        },
        "advanced": {
          "anyOf": [
            {
              "$ref": "#/$defs/OdooAdvancedConfig"
            },
            {
              "type": "null"
            }
          ],
          "description": "Advanced settings"
        },
        "custom_params": {
          "anyOf": [
            {
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Custom Params",
          "description": "Custom key=value parameters to add to odoo.conf"
        }
      },
      "type": "object",
      "title": "OdooConfig",
      "description": "Complete Odoo configuration schema.\n\nThis schema allows customization of odoo.conf parameters.\nParameters set here will override defaults during deployment."
    },
    "OdooConfigPreset": {
      "type": "string",
      "enum": [
        "minimal",
        "standard",
        "production",
        "high_performance"
      ],
      "title": "OdooConfigPreset",
      "description": "Predefined configuration presets."
    },
    "OdooDevelopmentConfig": {
      "properties": {
        "dev_mode": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Dev Mode",
          "description": "Development mode options: 'reload', 'qweb', 'werkzeug', 'xml' or combinations"
        },
        "test_enable": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Test Enable",
          "description": "Enable test mode"
        },
        "test_tags": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Test Tags",
          "description": "Test tags to run (e.g., 'standard', '-at_install')"
        },
        "without_demo": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Without Demo",
          "description": "Disable demo data loading ('all' or comma-separated modules)"
        },
        "demo": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Demo",
          "description": "Load demo data for specific modules"
        }
      },
      "type": "object",
      "title": "OdooDevelopmentConfig",
      "description": "Development and testing configuration settings."
    },
    "OdooEmailConfig": {
      "properties": {
        "email_from": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Email From",
          "description": "Default 'From' email address"
        },
        "smtp_server": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Smtp Server",
          "description": "SMTP server hostname"
        },
        "smtp_port": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 65535.0,
              "minimum": 1.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Smtp Port",
          "description": "SMTP server port (default: 25)"
        },
        "smtp_ssl": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Smtp Ssl",
          "description": "Use SSL for SMTP connection"
        },
        "smtp_user": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Smtp User",
          "description": "SMTP authentication username"
        },
        "smtp_password": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Smtp Password",
          "description": "SMTP authentication password"
        }
      },
      "type": "object",
      "title": "OdooEmailConfig",
      "description": "Email/SMTP configuration settings."
    },
    "OdooLoggingConfig": {
      "properties": {
        "log_level": {
          "anyOf": [
            {
              "$ref": "#/$defs/schemas__project__LogLevel"
            },
            {
              "type": "null"
            }
          ],
          "description": "Global logging level"
        },
        "log_handler": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Log Handler",
          "description": "Logging handlers (e.g., ':INFO', 'werkzeug:WARNING')"
        },
        "log_db": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Log Db",
          "description": "Enable logging to database"
        },
        "log_db_level": {
          "anyOf": [
            {
              "$ref": "#/$defs/schemas__project__LogLevel"
            },
            {
              "type": "null"
            }
          ],
          "description": "Database logging level"
        },
        "syslog": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Syslog",
          "description": "Send logs to syslog"
        }
      },
      "type": "object",
      "title": "OdooLoggingConfig",
      "description": "Logging configuration settings."
    },
    "OdooPerformanceConfig": {
      "properties": {
        "workers": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 32.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Workers",
          "description": "Number of worker processes (0 = no multi-processing, recommended for dev)"
        },
        "max_cron_threads": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 8.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Max Cron Threads",
          "description": "Maximum number of cron worker threads"
        },
        "limit_memory_hard": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Limit Memory Hard",
          "description": "Hard memory limit per worker in bytes (default: 2684354560 = 2.5GB)"
        },
        "limit_memory_soft": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Limit Memory Soft",
          "description": "Soft memory limit per worker in bytes (default: 2147483648 = 2GB)"
        },
        "limit_time_cpu": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Limit Time Cpu",
          "description": "Maximum CPU time per request in seconds (default: 900)"
        },
        "limit_time_real": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Limit Time Real",
          "description": "Maximum real time per request in seconds (default: 1200)"
        },
        "limit_time_real_cron": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Limit Time Real Cron",
          "description": "Maximum real time for cron jobs in seconds (default: 900)"
        },
        "limit_request": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Limit Request",
          "description": "Maximum request size in bytes (default: 8192)"
        },
        "transient_age_limit": {
          "anyOf": [
            {
              "type": "number",
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Transient Age Limit",
          "description": "Time limit for transient records cleanup in hours (default: 1.0)"
        }
      },
      "type": "object",
      "title": "OdooPerformanceConfig",
      "description": "Performance and resource limit settings."
    },
    "OdooSecurityConfig": {
      "properties": {
        "admin_passwd": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Admin Passwd",
          "description": "Master/admin password for database management"
        },
        "list_db": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "List Db",
          "description": "Allow listing databases on login page"
        },
        "dbfilter": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Dbfilter",
          "description": "Regular expression to filter available databases"
        }
      },
      "type": "object",
      "title": "OdooSecurityConfig",
      "description": "Security configuration settings."
    },
    "schemas__project__LogLevel": {
      "type": "string",
      "enum": [
        "debug",
        "info",
        "warn",
        "error",
        "critical",
        "notset",
        "debug_rpc",
        "debug_sql",
        "debug_rpc_answer",
        "test",
        "runbot"
      ],
      "title": "LogLevel",
      "description": "Odoo log levels.\n\nIMPORTANT: Odoo uses 'warn' NOT 'warning'. This is consistent across all versions (14.0-19.0).\nValid levels: info, debug_rpc, warn, test, critical, runbot, debug_sql, error, debug, debug_rpc_answer, notset"
    }
  }
}