# auth.md

This service publishes agent registration metadata for Akhirah Projects at `https://akhirahprojects.com`. Public endpoints remain readable without OAuth today, but protected partner access and future write-capable integrations use the discovery documents below as the source of truth.

## 1. Discover

1. Read the Protected Resource Metadata at `https://akhirahprojects.com/.well-known/oauth-protected-resource`.
2. Confirm the resource is `https://akhirahprojects.com`, the authorization server is `https://akhirahprojects.com`, and the advertised scopes are `videos.read` and `health.read`.
3. Fetch the authorization server metadata at `https://akhirahprojects.com/.well-known/oauth-authorization-server`.
4. Read the `agent_auth` block in full, including `register_uri`, `claim_uri`, `revocation_uri`, supported identity types, and credential types.

## 2. Pick A Method

- Use `anonymous` when you need a partner-access request started without a verified user identity.
- Use `identity_assertion` with `assertion_type: verified_email` when you already have the user's verified email and want the request tied to that person from the start.
- Request `api_key` credentials for now. Akhirah Projects does not currently mint OAuth bearer tokens for public read-only routes.

## 3. Register

Send a `POST` request to `https://akhirahprojects.com/agent/auth` with JSON.

Anonymous request:

```http
POST /agent/auth HTTP/1.1
Host: akhirahprojects.com
Content-Type: application/json

{
  "type": "anonymous",
  "agent_name": "Example Agent",
  "developer_contact": "agent@example.com",
  "requested_scopes": ["health.read"],
  "requested_credential_type": "api_key"
}
```

Verified email request:

```http
POST /agent/auth HTTP/1.1
Host: akhirahprojects.com
Content-Type: application/json

{
  "type": "identity_assertion",
  "assertion_type": "verified_email",
  "assertion": "user@example.com",
  "agent_name": "Example Agent",
  "developer_contact": "agent@example.com",
  "requested_scopes": ["videos.read"],
  "requested_credential_type": "api_key"
}
```

Successful requests return a review record and next steps. Current registrations are reviewed manually and do not issue an immediate credential.

## 4. Claim

If the registration response includes a `claim_token`, send it to `https://akhirahprojects.com/agent/auth/claim` together with the email that should own the request.

```http
POST /agent/auth/claim HTTP/1.1
Host: akhirahprojects.com
Content-Type: application/json

{
  "claim_token": "clm_example",
  "email": "user@example.com"
}
```

The service responds with claim status and human follow-up instructions.

## 5. Refresh And Token Use

- Public read-only routes do not require OAuth tokens today.
- `https://akhirahprojects.com/agent/token` is published for discovery compatibility and currently returns a structured `unsupported_grant_type` or `temporarily_unavailable` response when automated token minting is unavailable.
- If a future protected integration issues an API key, treat it as the active credential until revoked or rotated by Akhirah Projects.

## 6. Revoke

To revoke a registration or issued partner credential, send a `POST` request to `https://akhirahprojects.com/agent/auth/revoke`.

```http
POST /agent/auth/revoke HTTP/1.1
Host: akhirahprojects.com
Content-Type: application/json

{
  "registration_id": "areg_example",
  "reason": "User requested revocation"
}
```

## 7. Human Contact

- Contact email: `contact@akhirahprojects.com`
- Site docs: `https://akhirahprojects.com/docs/api/`
- OpenAPI: `https://akhirahprojects.com/.well-known/openapi.json`
