# Environment

## GET /api/public/v1/environment

> Export the full environment configuration including models, relationships, metrics, glossary terms, and AI analysts. Supports filtering by entity type and output format.

```json
{"openapi":"3.1.0","info":{"title":"Actian AI Analyst","version":"0.1.0"},"servers":[{"url":"https://app.wobby.ai","variables":{}}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key obtained from Settings > API Keys. Pass as: Authorization: Bearer <your-api-key>"}}},"paths":{"/api/public/v1/environment":{"get":{"parameters":[{"in":"query","name":"entities","description":"Comma-separated list of entity types to include. Valid values: models, relationships, metrics, glossary, ai_analysts. Defaults to all.","schema":{"type":"string"}},{"in":"query","name":"format","description":"Output format. Defaults to json.","schema":{"type":"string","enum":["json","yaml"],"default":"json"}}],"responses":{"200":{"description":"Environment export","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"string"},"exported_at":{"type":"string","format":"date-time"},"models":{"type":"array","items":{"type":"object"},"description":"Models with dimensions, measures, filters, and grain"},"relationships":{"type":"array","items":{"type":"object"},"description":"Relationships between models"},"metrics":{"type":"array","items":{"type":"object"},"description":"Defined metrics with expressions and joins"},"glossary":{"type":"array","items":{"type":"object"},"description":"Glossary terms with definitions and mappings"},"ai_analysts":{"type":"array","items":{"type":"object"},"description":"AI analysts with semantic layer access configuration"}}}}}},"400":{"description":"No environment context available"},"401":{"description":"Unauthorized — missing or invalid API key"}},"tags":["Environment"],"description":"Export the full environment configuration including models, relationships, metrics, glossary terms, and AI analysts. Supports filtering by entity type and output format."}}}}
```

## PUT /api/public/v1/environment

> Sync (upsert) the environment configuration from a JSON payload. Supports models, relationships, metrics, glossary terms, and AI analysts. Only include the entity types you want to sync — omitted types are left untouched. Blocks if any referenced data source does not exist.

```json
{"openapi":"3.1.0","info":{"title":"Actian AI Analyst","version":"0.1.0"},"servers":[{"url":"https://app.wobby.ai","variables":{}}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"API key obtained from Settings > API Keys. Pass as: Authorization: Bearer <your-api-key>"}}},"paths":{"/api/public/v1/environment":{"put":{"parameters":[],"responses":{"200":{"description":"Sync summary","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer","description":"Number of entities created"},"updated":{"type":"integer","description":"Number of entities updated"},"deleted":{"type":"integer","description":"Number of orphaned entities deleted (0 if orphaned=keep)"},"unchanged":{"type":"integer","description":"Number of entities that were already up to date"}}}}}},"400":{"description":"No environment context available"},"401":{"description":"Unauthorized — missing or invalid API key"},"422":{"description":"Validation error — one or more referenced data sources do not exist"}},"tags":["Environment"],"description":"Sync (upsert) the environment configuration from a JSON payload. Supports models, relationships, metrics, glossary terms, and AI analysts. Only include the entity types you want to sync — omitted types are left untouched. Blocks if any referenced data source does not exist.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"models":{"type":"array","items":{"type":"object"},"description":"Models to create or update (matched by name)"},"relationships":{"type":"array","items":{"type":"object"},"description":"Relationships between models"},"metrics":{"type":"array","items":{"type":"object"},"description":"Metrics to create or update (matched by name)"},"glossary":{"type":"array","items":{"type":"object"},"description":"Glossary terms to create or update (matched by term)"},"ai_analysts":{"type":"array","items":{"type":"object"},"description":"AI analysts to create or update (matched by name)"},"orphaned":{"type":"string","enum":["keep","delete"],"default":"keep","description":"What to do with existing entities not present in the payload. \"delete\" removes them, \"keep\" (default) leaves them."}}}}}}}}}}
```
