# StudioMode auth.md

This is the StudioMode **auth.md** — it describes how an automated agent
authenticates with the StudioMode API. It follows the
[auth.md](https://workos.com/auth-md) convention.

- **Site:** https://studiomode.ai
- **API base URL:** `https://kalakaarapi.techorigins.io/api/v1`
- **OpenAPI description:** https://kalakaarapi.techorigins.io/openapi.json
- **Interactive docs:** https://kalakaarapi.techorigins.io/docs
- **Health / status:** https://kalakaarapi.techorigins.io/health

## Protected resource metadata

Published at https://studiomode.ai/.well-known/oauth-protected-resource:

- `resource`: `https://kalakaarapi.techorigins.io/api/v1`
- `authorization_servers`: `["https://studiomode.ai"]`
- `scopes_supported`: `["openid", "profile", "email", "offline_access"]`
- `bearer_methods_supported`: `["header"]`

## Authentication schemes

Two options are supported:

1. **OpenID Connect (recommended for agents)** — authorization-code flow with
   PKCE. Discover it at:
   - OIDC discovery: https://studiomode.ai/.well-known/openid-configuration
   - OAuth 2.0 metadata: https://studiomode.ai/.well-known/oauth-authorization-server
   - Protected resource: https://studiomode.ai/.well-known/oauth-protected-resource
   - JWKS: https://kalakaarapi.techorigins.io/.well-known/jwks.json

   Tokens are **RS256** JWTs verifiable via the JWKS above. The token endpoint
   is public (`token_endpoint_auth_methods: none`) and **requires PKCE (S256)**.
   Clients (`client_id` + allowed `redirect_uris`) are registered with us — see
   the `agent_auth` notes below.

2. **Direct session token** — the same bearer login the web app uses.

Send whichever token on every protected request:

```
Authorization: Bearer <access_token>
```

### agent_auth

- `registration`: static allowlist (contact sachin@techorigins.io to register a
  `client_id` and `redirect_uris`). Dynamic client registration (RFC 7591) is
  not yet enabled.
- `identity_types`: end-user (no machine/service identities yet).
- `credential_types`: OIDC authorization_code + PKCE, or direct session bearer.
- `authorization_server`: https://studiomode.ai/.well-known/oauth-authorization-server

## Obtaining a token

### Existing account — password login

```
POST https://kalakaarapi.techorigins.io/api/v1/auth/login
Content-Type: application/json

{ "email": "user@example.com", "password": "••••••••" }
```

Response:

```json
{ "access_token": "<jwt>", "user": { "id": "...", "email": "..." } }
```

### New account — email + one-time passcode

```
POST /api/v1/auth/register                 → sends an OTP challenge
POST /api/v1/auth/register/verify-otp      → returns { access_token, user }
```

## Using the token

```
GET https://kalakaarapi.techorigins.io/api/v1/users/me
Authorization: Bearer <jwt>
```

## Notes for agents

- Generation, billing, and asset endpoints require a valid bearer token **and**
  available credits on the authenticated account.
- Payments are handled via Dodo Payments and Shopify checkout flows, not via an
  agent-native payment protocol.
- Rate limits and credit costs apply per the OpenAPI description above.
