# Prepare a sandbox for `ohauthcat init`

<div class="api-op" data-api-operation>
<div class="api-op__main">

<p class="api-endpoint"><span class="method method-post">POST</span> <code>/v1/dev/init</code></p>

Sandbox discovery for `ohauthcat init`, and an idempotent redirect URI registration. Returns the environment and, when `redirect_uri` is given, its registered redirect URI (created when missing, `redirect_uri_created`; localhost is allowed in sandbox). With `test_connection`, also returns the test organization, its test IdP connection and a test sign-in URL. Sandbox environments only (`sandbox_required`).

<dl class="api-facts"><div><dt>Scope</dt><dd><code>environment:write</code></dd></div><div><dt>Auth</dt><dd>Secret key (<code>sk_…</code>)</dd></div><div><dt>Since</dt><dd>1.0</dd></div></dl>

## Headers

<ul class="api-fields">
<li class="api-field">
<p class="api-field__head"><code class="api-field__name">OhAuthCat-Version</code> <span class="api-field__type">string</span></p>
Minor version; defaults to the environment's pin.
</li>
</ul>

## Request body

<ul class="api-fields">
<li class="api-field">
<p class="api-field__head"><code class="api-field__name">redirect_uri</code> <span class="api-field__type">string (uri)</span></p>
Registered when missing (exact match).
</li>
<li class="api-field">
<p class="api-field__head"><code class="api-field__name">test_connection</code> <span class="api-field__type">boolean</span></p>
When true, also returns the sandbox's test organization and its SAML connection to the hosted test IdP (created on the first call, then found by the fixed external ID `ohauthcat-test-organization`) and a fresh one-time `test_url` for a test sign-in. Answers `service_unavailable` where no test IdP is available.
</li>
</ul>

## Responses

<ul class="api-responses">
<li class="api-response"><span class="api-status api-status--ok">200</span> <span>OK <span class="api-field__type">DevInit</span></span></li>
<li class="api-response"><span class="api-status api-status--bad">400</span> <span>Invalid request. Codes: <a href="/errors/parameter_invalid/">parameter_invalid</a>, <a href="/errors/parameter_missing/">parameter_missing</a>, <a href="/errors/version_unsupported/">version_unsupported</a> and resource-specific codes from the catalogue. <span class="api-field__type">Error</span></span></li>
<li class="api-response"><span class="api-status api-status--bad">401</span> <span>Codes: <a href="/errors/authentication_required/">authentication_required</a>, <a href="/errors/api_key_invalid/">api_key_invalid</a>. <span class="api-field__type">Error</span></span></li>
<li class="api-response"><span class="api-status api-status--bad">403</span> <span>Codes: <a href="/errors/api_key_scope_missing/">api_key_scope_missing</a>, <a href="/errors/ip_not_allowed/">ip_not_allowed</a>, <a href="/errors/plan_limit_reached/">plan_limit_reached</a>. <span class="api-field__type">Error</span></span></li>
<li class="api-response"><span class="api-status api-status--bad">429</span> <span>Code: <a href="/errors/rate_limited/">rate_limited</a>. Retry-After is set. <span class="api-field__type">Error</span></span></li>
<li class="api-response"><span class="api-status api-status--bad">503</span> <span>Code: <a href="/errors/service_unavailable/">service_unavailable</a>. Retry-After is set; writes are paused. <span class="api-field__type">Error</span></span></li>
<li class="api-response"><span class="api-status api-status--neutral">default</span> <span>Any other error, including <a href="/errors/internal_error/">internal_error</a>. Every code is in the error catalogue. <span class="api-field__type">Error</span></span></li>
</ul>

Errors share one shape; see the [error code catalogue](/errors/).

</div>
<div class="api-op__code">

**curl**

```sh wrap
curl -X POST \
  "https://api.ohauthcat.com/v1/dev/init" \
  -H "Authorization: Bearer $OHAUTHCAT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "redirect_uri": "https://app.acme.com/callback",
  "test_connection": true
}'
```

**Node**

```javascript wrap
const response = await fetch("https://api.ohauthcat.com/v1/dev/init", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.OHAUTHCAT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    redirect_uri: "https://app.acme.com/callback",
    test_connection: true,
  }),
});
const data = await response.json();
```

**Python**

```python wrap
import os
import requests

response = requests.post(
    "https://api.ohauthcat.com/v1/dev/init",
    headers={"Authorization": f"Bearer {os.environ['OHAUTHCAT_API_KEY']}"},
    json={
        "redirect_uri": "https://app.acme.com/callback",
        "test_connection": True,
    },
)
data = response.json()
```

```json title="Response 200" wrap
{
  "object": "dev_init",
  "environment": {
    "id": "env_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
    "object": "environment",
    "project": "proj_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
    "name": "Acme Corp",
    "type": "sandbox",
    "consent_screen_default": "on",
    "sign_in_failed_events": true,
    "gusto_oauth_available": true,
    "bamboohr_oauth_available": true,
    "google_oauth_available": true,
    "compat_workos_enabled": false,
    "version_pin": "example_version_pin",
    "home_region": "example_home_region",
    "portal_success_urls": {},
    "disabled_notices": ["cert_expiry"],
    "portal_logo_url": "https://app.acme.com/callback",
    "portal_embed_origins": ["example_portal_embed_origin"],
    "support_email": "jane@acme.com",
    "sign_ins_disabled": true,
    "sign_ins_disabled_at": "2026-01-15T09:30:00Z",
    "sign_ins_disabled_by": "customer",
    "residency": {
      "region": "eu",
      "data_classes": [
        {
          "data_class": "example_data_class",
          "description": "Primary SSO connection for Acme Corp.",
          "scope": "home_region",
          "region": "eu",
          "personal_data": true
        }
      ]
    }
  },
  "redirect_uri": {
    "id": "ruri_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
    "object": "redirect_uri",
    "uri": "https://app.acme.com/callback",
    "created_at": "2026-01-15T09:30:00Z"
  },
  "redirect_uri_created": true,
  "relay_path": "example_relay_path",
  "organization": {
    "id": "org_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
    "object": "organization",
    "legacy_ids": {
      "workos": "org_01H8ZQ4M7K2X8V3N5B6C1D0E9F"
    },
    "name": "Acme Corp",
    "external_id": "acme-123",
    "status": "active",
    "allowed_intents": ["sso"],
    "consent_screen": "environment_default",
    "metadata": {
      "plan": "enterprise"
    },
    "created_at": "2026-01-15T09:30:00Z",
    "updated_at": "2026-01-15T09:30:00Z"
  },
  "connection": {
    "oidc_managed": {
      "provider": "google_workspace",
      "entra_tenant_id": "01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
      "allow_personal_accounts": false
    },
    "catalogue_idp": "okta",
    "id": "conn_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
    "object": "connection",
    "legacy_ids": {
      "workos": "org_01H8ZQ4M7K2X8V3N5B6C1D0E9F"
    },
    "forwarding": {
      "acs_urls": ["https://app.acme.com/callback"],
      "redirect_uris": ["https://app.acme.com/callback"],
      "until": "2026-01-15T09:30:00Z",
      "expires_in_days": 0,
      "last_warning_days": 1,
      "hint": "example_hint"
    },
    "idp_initiated": {
      "enabled": false,
      "client_id": "client_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
      "default_redirect_uri": "https://app.acme.com/callback"
    },
    "organization_id": "org_01J9Z3K5V7W8X9Y0Z1A2B3C4D5",
    "name": "Acme Corp",
    "type": "saml",
    "state": "draft",
    "sp_entity_id": "https://idp.acme.com/saml/metadata",
    "sp_metadata_url": "https://app.acme.com/callback",
    "test_idp": true,
    "acs_urls": ["https://app.acme.com/callback"],
    "sp_slo_urls": ["https://app.acme.com/callback"],
    "routing_domains": ["acme.com"],
    "standby_registered": true,
    "import_source": "example_import_source",
    "import_lever": "A",
    "standby_acs_selection": "url",
    "idp_entity_id": "https://idp.acme.com/saml/metadata",
    "oidc_issuer": "https://idp.acme.com/saml/metadata",
    "metadata_stale_since": "2026-01-15T09:30:00Z",
    "untested_since": "2026-01-15T09:30:00Z",
    "created_at": "2026-01-15T09:30:00Z",
    "updated_at": "2026-01-15T09:30:00Z"
  },
  "test_url": "https://app.acme.com/callback",
  "test_url_expires_at": "2026-01-15T09:30:00Z"
}
```

</div>
</div>
