Environments API

Endpoints for creating, listing, duplicating, and managing environments within a project.

Endpoints

GET/v1/projects/{project_id}/environmentsList all environments
POST/v1/projects/{project_id}/environmentsCreate a new environment
DELETE/v1/environments/{env_id}Delete an environment
POST/v1/environments/{env_id}/rotate/{key_type}Rotate public or secret key
POST/v1/environments/{env_id}/duplicateDuplicate environment with fresh keys

GET /v1/projects/{project_id}/environments

// Response 200
[
  {
    "id": "uuid",
    "project_id": "project_uuid",
    "name": "Production",
    "public_key": "pk_live_6e4abe...",
    "created_at": "2026-01-01T00:00:00Z"
  },
  {
    "id": "uuid",
    "project_id": "project_uuid",
    "name": "Development",
    "public_key": "pk_live_a1b2c3...",
    "created_at": "2026-01-01T00:00:00Z"
  }
]

Secret keys are never returned in list responses. View and rotate them from the dashboard.

POST /v1/environments/{env_id}/rotate/{key_type}

// key_type: "public" or "secret"

// POST /v1/environments/env_uuid/rotate/public

// Response 200
{
  "key_type": "public",
  "new_key": "pk_live_newkey123...",
  "message": "Old key is now invalid. Update your Flutter app."
}

POST /v1/environments/{env_id}/duplicate

// Request
{ "name": "Staging Copy" }

// Response 201
{
  "id": "new_env_uuid",
  "name": "Staging Copy",
  "public_key": "pk_live_freshkey...",
  "copied_from": "original_env_uuid",
  "created_at": "2026-01-01T00:00:00Z"
}

// Note: copies flags, configs, and version policy only.
// Does NOT copy: database records, storage, users, functions, secrets.