# Nephis API reference

This reference describes routes registered by the current Nephis gateway and control planes in this repository. It does not promise that every optional engine feature is enabled on every deployment. Use the live health endpoints and returned errors to confirm availability.

## Gateway

Production gateway: `https://nephis.theeducode.com`. Send a provider-issued key as `Authorization: Bearer <API_KEY>`; `X-API-Key` is also accepted by several gateway handlers. Do not put keys in URLs, source control, or client-side public configuration.

### Health and discovery

| Method | Path | Purpose |
|---|---|---|
| GET | `/healthz` or `/health` | Gateway health |
| GET | `/readyz` | Readiness |
| GET | `/v1/endpoints` | Gateway endpoint and policy discovery |
| GET | `/.well-known/mcp` | MCP discovery manifest |
| GET | `/v1/billing/rate-card` | Current provider rate card |
| GET | `/v1/metrics` or `/metrics` | Prometheus metrics; deployment configuration may restrict access |

### Eschaton code execution

| Method | Path | Notes |
|---|---|---|
| POST | `/v1/execute` | Native execution API. Send JSON with `source_code`, `language_id`, `suite`, and `test_cases`. |
| POST | `/v1/submissions?wait=true` | Judge0-compatible synchronous submission route. |
| GET | `/v1/languages` | Query the deployment for supported language IDs; do not assume IDs from old examples. |
| POST | `/v1/execute/preflight` | Preflight route; availability depends on the configured upstream. |

Example (replace `language_id` with an ID returned by `/v1/languages`):

```bash
curl -fsS https://nephis.theeducode.com/v1/execute \
  -H "Authorization: Bearer $NEPHIS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"language_id":71,"source_code":"print(1 + 1)","suite":"Apex","test_cases":[{"id":1,"stdin":"","expected_output":"2"}]}'
```

Execution is metered. Check `/v1/auth/me` for the authenticated account and the rate-card route for current pricing. Do not assume an execution is free or that a failed client connection means the server did not receive the request; use an idempotency key for safe retries where supported.

### Thanaton projects and sandboxes

The current control-plane routes `/v1/sandboxes` and `/api/v1/sandboxes` alias project listing and project creation. They are not the old standalone microVM JSON contract described in archived examples.

| Method | Path | Current behavior |
|---|---|---|
| GET | `/v1/projects` or `/v1/sandboxes` | Lists projects for the authenticated tenant |
| POST | `/v1/projects` or `/v1/sandboxes` | Creates a project. Required body includes `name`; optional fields include `slug`, `runtime`, `app_port`, and `execution_mode`. Project creation may charge credits. |
| GET | `/v1/sandboxes/{id}` | Reads a sandbox/project record when the control plane supports it |
| DELETE | `/v1/sandboxes/{id}` | Submits a release/unpin operation. Do not interpret this response as proof that a guest VM or project record was physically deleted. |
| POST | `/v1/sandboxes/{id}/wake` | Wake admission/coalescing route; response is an admission result, not a measured boot SLA |

There is no general VM freeze route matching the old docs. The registered freeze endpoint is volume-oriented and requires a `volume_id`; it does not freeze an arbitrary VM. Runtime telemetry should be read from a telemetry endpoint, not inferred from a project status.

### Mnemon database projects

Use the gateway prefix `https://nephis.theeducode.com/v1/db` (or `/db/api` in browser deployments). The gateway authenticates the API key, scopes project operations to its tenant, and forwards the remaining path to the Mnemon control plane.

| Method | Path after gateway prefix | Current control-plane route |
|---|---|---|
| GET | `/v1/projects` | List scoped projects |
| POST | `/v1/projects` | Create a project |
| GET | `/v1/projects/{id}/branches` | List branches |
| POST | `/v1/projects/{id}/branches` | Create a branch (`name`, optional `parent_branch`, `target_lsn`) |
| POST | `/v1/projects/{id}/branches/{branch}/reset` | Reset a branch |
| POST | `/v1/projects/{id}/branches/{branch}/promote` | Promote a branch |
| POST | `/v1/projects/{id}/sql` | Execute SQL |

The current local control plane returns `501 Not Implemented` for point-in-time branch creation and branch schema diff. Do not use old `/v1/tenants/branch/time-travel` or `/v1/tenants/branch/diff` examples as working routes.

### Account and billing

| Method | Path | Purpose |
|---|---|---|
| GET | `/v1/auth/me` | Authenticated account and current balance details |
| GET | `/v1/account/usage` | Account usage details |
| GET | `/v1/billing/rate-card` | Provider rate card |

Billing, wallet, invoices, and checkout capabilities vary by deployment and account. Use the documented account portal and live responses; this gateway route list does not establish a customer-facing invoice or checkout contract.

## SDK and MCP references

- [Python SDK](../sdk/python/README.md)
- [TypeScript SDK](../sdk/typescript/README.md)
- [CLI tools](../sdk/cli/README.md)
- [MCP server](../sdk/mcp/README.md)
- [Billing and credits](BILLING_AND_CREDITS.md)

Older copies of this reference used unsupported claim routes, standalone VM payloads, and retired Mnemon tenant routes. Treat those examples as obsolete.
