---
title: "Register Byo Environment"
method: POST
path: "/api/agent-data/environments"
tags: ["agent-data"]
---

# Register Byo Environment

`POST /api/agent-data/environments`

## Request

- Base URL: `https://app.thinqos.com` (the document declares no server; this is the origin it was published from)
- URL: `https://app.thinqos.com/api/agent-data/environments`
- Auth: none declared

Self-service BYO registration: guided-BYO fallback (TOS-1614, TOS-1617).

Any authenticated identity may register their OWN external Postgres — no
admin role required. This is the "paste a connection string" path every
provider gets uniformly, including a Supabase project a customer already
has (deliberately NOT a Supabase-specific browse/pick UI over their
Management API — see the ticket for why). The caller becomes the
environment's owner, which is what makes ``_can_use_environment`` work
for them afterward with zero additional wiring. Runs the exact same
fail-closed verification as admin registration (agent_data_admin.py) —
self-service gets no weaker a check than an internal registration does.

Anti-SSRF (TOS-1614 review round 4): the DSN host must resolve to public
addresses only — this endpoint makes the server dial caller-supplied
hosts, and without the guard it is an internal-network probe oracle.

## Request body

- RegisterByoEnvironmentIn
  - `name` string, required
  - `admin_dsn` string, required

## Response `200`

Successful Response

- EnvironmentDetailOut
  - `id` string, required
  - `name` string, required
  - `kind` string, required
  - `owner_identity_id` string, nullable, required
  - `status` string, required
  - `ownership_kind` string, required
  - `detached_at` string, nullable, required
  - `verification` object, nullable, required
  - `verified_at` string, nullable, required
  - `created_at` string, nullable, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/thinqos/apis/thinqos-api.md) · [All operations](https://skmtc.dev/thinqos/apis/thinqos-api/llms.txt) · [OpenAPI document](https://skmtc.dev/thinqos/apis/thinqos-api/revisions/ce2c2ce318b1?raw)
