# Addie auth.md

Register an agent to read public Australian property listings on behalf of a user.
The user confirms the registration with their Addie account. Share the user's
email with WorkOS only when they authorize you to start the registration.

- [Protected resource metadata](https://www.addie.house/.well-known/oauth-protected-resource?resource=agent-research)
- [Authorization server metadata](https://auth.addie.house/.well-known/oauth-authorization-server)
- [WorkOS registration instructions](https://auth.addie.house/agent/auth.md)
- [Addie terms](https://www.addie.house/terms) and [privacy policy](https://www.addie.house/privacy)
- [Permitted use for agent research](https://www.addie.house/developers#permitted-use)

## Register with user confirmation

The protected resource and token audience is `https://www.addie.house/api/agent-research`.
The only registration method is `service_auth`. The research metadata names
the same WorkOS endpoint as `register_uri` and `identity_endpoint`.

POST `https://auth.addie.house/agent/identity` with `Content-Type: application/json`.
Set `login_hint` to the user-authorized email for their verified Addie account.

```json
{"type":"service_auth","login_hint":"user@example.com"}
```

## Complete the claim

Give the user the returned `claim.attempt.verification_uri`. The user signs in
to Addie and confirms read-only access. WorkOS withholds the identity assertion
until the claim is complete. If the attempt expires, POST to
`https://auth.addie.house/agent/identity/claim` with the same `type` and `login_hint` and
`claim_token` set to the registration's `claim.token`.

POST `https://auth.addie.house/agent/identity/claim/complete` with
`Content-Type: application/json`. Use the registration's `claim.token` and the
confirmation code the user received after approving access.

```json
{"claim_token":"<claim.token>","user_code":"<user confirmation code>"}
```

## Exchange the assertion for an access token

POST `https://auth.addie.house/oauth2/token` with these URL-encoded form fields:

- `grant_type` = `urn:ietf:params:oauth:grant-type:jwt-bearer`
- `assertion` = the confirmed `identity.assertion`
- `resource` = `https://www.addie.house/api/agent-research`

The `access_token` lasts at most 5 minutes.
Keep assertions, tokens and confirmation codes private.

## Use the credential

Send a JSON POST to `https://www.addie.house/api/agent-research` with
`Authorization: Bearer <access_token>` and the `research:read` scope.
This resource only provides place resolution and public active-listing search.

Example request body:

```json
{"operation":"resolve_location","arguments":{"query":"Newtown NSW"}}
```

See the [Addie property research skill](https://www.addie.house/.well-known/agent-skills/addie-property-research/SKILL.md)
for the structured search criteria. Search supports one suburb or postcode
and up to five listings per request.

## Revoke

Revoke the registration at `https://auth.addie.house/oauth2/revoke` using its WorkOS
refresh token with `token_type_hint=refresh_token`.
