---
version: "1.0.0"
issuer: "https://asesoriasem.com"
authorization_server: "https://asesoriasem.com/.well-known/oauth-authorization-server"
protected_resource: "https://asesoriasem.com/.well-known/oauth-protected-resource"
token_endpoint: "https://asesoriasem.com/api/oauth/token"
jwks_uri: "https://asesoriasem.com/.well-known/jwks.json"
scopes_supported:
  - "read:properties"
  - "write:leads"
  - "read:faq"
agent_auth:
  skill: "https://asesoriasem.com/auth.md"
  identity_endpoint: "https://asesoriasem.com/api/oauth/register-agent"
  claim_endpoint: "https://asesoriasem.com/api/oauth/claim-agent"
  events_endpoint: "https://asesoriasem.com/api/oauth/events"
  identity_types_supported:
    - "anonymous"
    - "identity_assertion"
    - "service_auth"
  identity_assertion:
    assertion_types_supported:
      - "urn:ietf:params:oauth:token-type:id-jag"
  events_supported:
    - "https://schemas.workos.com/events/agent/auth/identity/assertion/revoked"
contact: "juridico@asesoriasem.com"
---

# auth.md

You are an agent. This service supports **agentic registration**: discover → register → (claim if needed) → exchange for an access_token → call API → handle revocation. Follow the steps in order.

> **EM Asesoría Inmobiliaria y Jurídica** — Servicios inmobiliarios y legales en Hidalgo del Parral, Chihuahua, México ([asesoriasem.com](https://asesoriasem.com)).

---

## Step 1 — Discover

### 1a. Fetch the Protected Resource Metadata

```http
GET /.well-known/oauth-protected-resource
Host: asesoriasem.com
```

Response:

```json
{
  "resource": "https://asesoriasem.com/api",
  "authorization_servers": ["https://asesoriasem.com"],
  "scopes_supported": ["read:properties", "write:leads", "read:faq"],
  "bearer_methods_supported": ["header"]
}
```

### 1b. Fetch the Authorization Server metadata

```http
GET /.well-known/oauth-authorization-server
Host: asesoriasem.com
```

The response includes standard RFC 8414 fields and an `agent_auth` block with:

- `agent_auth.skill` — this document
- `agent_auth.identity_endpoint` — where you POST to register
- `agent_auth.claim_endpoint` — where you POST claim invites for anonymous registrations
- `agent_auth.identity_types_supported` — `anonymous`, `identity_assertion`, `service_auth`
- `agent_auth.identity_assertion.assertion_types_supported` — `urn:ietf:params:oauth:token-type:id-jag`

---

## Step 2 — Pick a method

| Method | When to use |
|---|---|
| `identity_assertion` (ID-JAG) | You have a session tied to a user identity and can mint an ID-JAG |
| `service_auth` | You have the user's email — claim ceremony required |
| `anonymous` | You have neither — claim is optional |

---

## Step 3 — Register

POST your chosen identity to the `identity_endpoint`:

```http
POST /api/oauth/register-agent
Host: asesoriasem.com
Content-Type: application/json

{
  "identity_type": "anonymous"
}
```

---

## Step 4 — Claim (if needed)

For `anonymous` or `service_auth`, use the `claim_endpoint` to link user identity.

---

## Step 5 — Exchange for access_token

```http
POST /api/oauth/token
Host: asesoriasem.com
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=<identity_assertion>
```

---

## Step 6 — Call the API

```http
GET /api/match-preference
Host: asesoriasem.com
Authorization: Bearer <access_token>
```

Available scopes:
- `read:properties` — Consulta del inventario inmobiliario activo en Parral, Chihuahua
- `read:faq` — Orientación legal notarial y respuestas a dudas inmobiliarias
- `write:leads` — Registro de solicitudes de compra, venta, consignación o visitas

---

## Public endpoints (no auth required)

| Endpoint | Method | Description |
|---|---|---|
| `/api/match-preference` | POST | Match semántico de preferencias con inventario |
| `/api/notify-lead` | POST | Registro de prospecto (nombre, teléfono, interés) |
| `/api/markdown/home` | GET | Homepage en markdown |
| `/api/markdown/propiedades` | GET | Listado de propiedades en markdown |
| `/api/markdown/guia` | GET | Guía inmobiliaria en markdown |
| `/api/health` | GET | Estado del servidor y capacidades |

---

## Contacto

- **Titular:** Licenciado Edgar Molina
- **Correo:** [juridico@asesoriasem.com](mailto:juridico@asesoriasem.com)
- **WhatsApp:** [+52 627 279 2964](https://wa.me/526272792964)
- **Sede:** Hidalgo del Parral, Chihuahua, México
