# Tityra auth.md

The website, Markdown resources and GET /api/site.json require no account or credentials. The public information API grants anonymous read access only; it isn't a protected account API and doesn't issue OAuth tokens. Google sign-in and external workspace integrations aren't credentials for this website API. For delegated customer-account access, use the separate OAuth-protected workspace resource below.

## Connected customer accounts

Connect an OAuth-capable Streamable HTTP MCP client to `https://app.tityra.com/mcp`. The account holder signs in to Tityra, reviews the connecting application and scopes, and selects the projects the connection may access. Customer accounts are supported; staff operations aren't delegated through this resource.

| Resource | URL |
| --- | --- |
| MCP protected resource / OAuth audience | `https://app.tityra.com/mcp` |
| Authorization server metadata | `https://app.tityra.com/.well-known/oauth-authorization-server` |
| Protected resource metadata | `https://app.tityra.com/.well-known/oauth-protected-resource/mcp` |
| Client registration | `https://app.tityra.com/api/oauth/register` |
| User authorization | `https://app.tityra.com/oauth/authorize` |
| Token exchange and refresh | `https://app.tityra.com/api/oauth/token` |
| Token revocation | `https://app.tityra.com/api/oauth/revoke` |
| Manage / revoke connections | `https://app.tityra.com/connected-agents` |

Use authorization code flow with PKCE `S256`. Include the canonical MCP resource in authorization and token requests. Register exact redirect URIs and use the returned client identifier. Access tokens are short-lived; refresh tokens rotate. Keep tokens in the client's credential store and send access tokens only in `Authorization: Bearer ...`, never in URLs or public website requests. Discover the supported scopes from the protected-resource metadata rather than treating this documentation as a grant.

| Scope | Granted operation |
| --- | --- |
| `projects:read` | Read selected projects and their weekly monitoring settings |
| `monitoring:write` | Pause weekly monitoring for selected projects you can manage. Enabling paid monitoring and approving recurring credit budgets require the Tityra application. |
| `audits:read` | Read audit requests and their status |
| `audits:create` | Request an audit under existing eligibility and review rules |
| `reports:read` | Read released reports the user is allowed to access |
| `findings:read` | Read findings, evidence and recommendations |
| `findings:challenge` | Use Mark as incorrect for a finding with the customer's reason |
| `discussions:read` | Read customer-visible finding discussions and replies |
| `discussions:write` | Start a Discuss finding thread or reply on the customer's behalf |
| `remediation:write` | Update customer-reported remediation, without independently verifying a fix |
| `billing:read` | Read available report-payment requirements and status |
| `checkout:create` | Create a checkout link for the user to review and pay |

Scopes and selected projects restrict each other. A scope alone doesn't expand the account holder's current rights, bypass a report payment gate, approve an audit or expose another customer's data. Monitoring requires the website and assessment scope to be selected in Tityra, with recurring budget approval as described below. A revoked connection or removed membership stops subsequent access. Never request payment-card details; the user completes Stripe Checkout and verified payment results determine access. Automatic spending isn't supported.

Existing connections retain their original scope grant. To use `findings:challenge`, `discussions:read`, `discussions:write` or `monitoring:write`, the client must request those scopes in a new connection and the account holder must review fresh consent. Refreshing an existing token doesn't add permissions. Finding challenges and discussions use customer-visible feedback only; they don't expose private staff notes, change report evidence, verify a correction or promise a staff reply.

Use a stable idempotency key when retrying a mutation with the same input. For remediation, read the current version before updating; refresh after a conflict rather than overwriting a newer edit. MCP tools publish their argument schemas through `tools/list`. The [account connection guide](/connected-agents) explains the user flow and the [MCP reference](/mcp.md) distinguishes public preparation from authenticated operations.

### Project monitoring API

`GET /api/agent/projects/{projectId}/monitoring` uses `projects:read` and returns the selected project's current settings, website, revision and report history. `PATCH` on the same endpoint requires the separate `monitoring:write` grant and current project management rights. `audits:create` doesn't authorise recurring monitoring.

Read the selected project monitoring settings first. To pause, send `action: "disable"`, the current `revision` as `expectedRevision` and a stable UUIDv4 `idempotencyKey`. Omit scope and authority fields. Keep the exact input and key after an uncertain write; refresh on a revision conflict. `monitoring:write` doesn't authorise spending.

The server rechecks the selected project and current management rights when pausing. Enable or resume monitoring in Tityra by selecting the website and assessment scope and approving the recurring credit budget. The organisation owner or a member with credit-spending permission must approve that budget. Existing consent to free monitoring doesn't authorise paid runs. This API can't enable recurring charges, change the payer or alter a subscription.

<!-- tityra-content:monitoring-policy:start -->
Weekly monitoring is available on Starter, Pro and Enterprise for enabled projects, using included monthly audits first and then 19 organisation credits per run once you've approved recurring spending. Expert Review is priced separately.

The first weekly run is due seven days after the earliest non-cancelled audit request for that project and website, or seven days after monitoring consent if there is no earlier request. Enabling or resuming an overdue eligible project queues one due run when its approved budget can be reserved. Each new scheduled request sets the next due date seven days later. Missed weeks aren't queued as a backlog.

Monitoring uses the organisation's own billing account and its monthly allowance or credit balance, with recurring credit approval. It pauses when neither can cover the next audit and notifies the person who authorised it in the app and by email. Adding credits requires an explicit resume.

Scheduled website content audit reports are delivered automatically after the required checks and funding settlement. Existing reports remain available when monitoring is paused.
<!-- tityra-content:monitoring-policy:end -->

## Customer OAuth walkthrough

The examples below use placeholders, not live credentials. A client implementation or OAuth-capable MCP SDK normally performs these steps.

### 1. Discover

Start with the protected MCP resource, `https://app.tityra.com/mcp`. An unauthenticated request receives HTTP 401 and a `WWW-Authenticate: Bearer` challenge whose `resource_metadata` URL points to the RFC 9728 document. It's also linked from the website's [AI Catalog](/.well-known/ai-catalog.json), [API Catalog](/.well-known/api-catalog) and descriptive [account MCP Server Card](/.well-known/mcp-account-server-card.json).

```sh
curl -i https://app.tityra.com/mcp
curl https://app.tityra.com/.well-known/oauth-protected-resource/mcp
curl https://app.tityra.com/.well-known/oauth-authorization-server
```

Check that the metadata's `resource` is the intended `https://app.tityra.com/mcp` and that the authorization server is the expected Tityra application origin. Follow its published authorization, registration, token and revocation endpoints. Metadata is public information; fetching it doesn't grant account access.

### 2. Pick the access method

Public website information and the read-only `get_audit_options` MCP tool at `https://tityra.com/mcp` use no credentials. Customer projects and reports use the separate app MCP resource and OAuth. This flow supports registered public clients with authorisation code, PKCE `S256` and refresh tokens. It doesn't offer API keys, client-secret authentication, client-credentials grants, a public execution sandbox or automatic payment authority.

### 3. Register the client

Register an application name and exact callback URLs. HTTPS callbacks are supported, as are HTTP loopback callbacks for native clients. Callback URLs can't contain credentials or fragments.

```sh
curl https://app.tityra.com/api/oauth/register \
  -H 'Content-Type: application/json' \
  --data '{"client_name":"Example agent app","redirect_uris":["https://client.example/callback"],"token_endpoint_auth_method":"none","grant_types":["authorization_code","refresh_token"],"response_types":["code"]}'
```

A successful registration returns HTTP 201 with `client_id`, `client_name`, `redirect_uris`, `client_id_issued_at`, `token_endpoint_auth_method: "none"`, `grant_types` and `response_types`. Save the returned client ID. Registration creates no customer grant and returns no client secret or access token.

### 4. Claim access through user consent

Generate a fresh random PKCE verifier and `state`. Derive `code_challenge` as the base64url-encoded SHA-256 hash of the verifier. Store the verifier and state in the client until the callback is validated. Open the authorization endpoint in the user's browser with the values below, URL-encoding each value:

```text
https://app.tityra.com/oauth/authorize
  ?response_type=code
  &client_id=<registered-client-id>
  &redirect_uri=https%3A%2F%2Fclient.example%2Fcallback
  &resource=https%3A%2F%2Fapp.tityra.com%2Fmcp
  &scope=projects%3Aread%20reports%3Aread%20findings%3Aread
  &code_challenge=<base64url-sha256-challenge>
  &code_challenge_method=S256
  &state=<fresh-random-state>
```

This is one URL; the line breaks above are for readability. There's no separate claim API. The user signs in to Tityra, checks the connecting application, reviews the requested scopes and selects projects. A new connection requires explicit approval; existing connections don't automatically gain new permissions.

On approval, the registered callback receives `code`, the original `state` and `iss`. Check `state` against the saved value and `iss` against the expected Tityra issuer before exchanging the code. A denial returns `error=access_denied` instead of a code. An authorization code is single-use and expires after five minutes.

### 5. Exchange the code and refresh credentials

Send form-encoded fields to the token endpoint. The callback must match registration and authorization exactly; `resource` must remain the canonical MCP resource. Don't add HTTP Basic/Bearer client authentication or a `client_secret` to this public-client token request.

```sh
curl https://app.tityra.com/api/oauth/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'grant_type=authorization_code' \
  --data-urlencode 'client_id=<registered-client-id>' \
  --data-urlencode 'code=<callback-code>' \
  --data-urlencode 'redirect_uri=https://client.example/callback' \
  --data-urlencode 'resource=https://app.tityra.com/mcp' \
  --data-urlencode 'code_verifier=<saved-pkce-verifier>'
```

The JSON response contains `access_token`, `token_type: "Bearer"`, `expires_in`, `refresh_token` and the approved `scope`. Access lasts at most 15 minutes; the connection lasts at most 30 days. Use the returned lifetime rather than assuming the maximum.

To refresh, POST `grant_type=refresh_token`, `client_id`, the latest `refresh_token` and the same `resource` as form-encoded fields. Store the replacement access and refresh tokens together. Refresh tokens rotate and are single-use; replaying a used grant revokes the connection. If the credential outcome is uncertain or an `invalid_grant` is returned, reconnect instead of replaying old credentials. Omit `scope` on refresh, or send exactly the original grant; scope changes require fresh consent.

### 6. Use the credential

Send the access token only in the HTTP Authorization header to the app resource or its account REST API:

```sh
curl https://app.tityra.com/api/agent/projects \
  -H 'Authorization: Bearer <access-token>'
```

That example requires `projects:read`. For MCP, initialize with a supported protocol version, then use `tools/list` and `tools/call` with the same Bearer header and negotiated `MCP-Protocol-Version`. Send `Accept: application/json, text/event-stream` and JSON request bodies. See the [MCP reference](/mcp.md) for the transport and available tools. Each request rechecks the connection, selected projects and current account rights. The website's public MCP server doesn't accept this token as account authority.

### 7. Handle errors

OAuth registration and token failures return a JSON `error` and `error_description`. Examples include `invalid_client_metadata`, `invalid_redirect_uri`, `invalid_client`, `invalid_request`, `invalid_scope`, `invalid_grant`, `invalid_target` and `unsupported_grant_type`. Correct invalid input; don't retry an invalid or reused grant indefinitely.

Account resource failures retain HTTP status and a Bearer challenge: 401 means missing, invalid, expired or revoked credentials; 403 means insufficient scope, account/project access or a disallowed browser Origin. Add permissions only through a new user-approved connection. A 409 on a domain mutation requires reading the current revisions before deciding on a new change. Respect rate limits and back off on HTTP 429. Error details don't grant additional access.

### 8. Revoke access

The account holder can revoke a connection from [Connected agents](https://app.tityra.com/connected-agents). A client can also revoke by sending its client ID and token to the published revocation endpoint, without client-secret or Authorization-header authentication:

```sh
curl https://app.tityra.com/api/oauth/revoke \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'client_id=<registered-client-id>' \
  --data-urlencode 'token=<access-or-refresh-token>'
```

A known token revokes its connection, preventing subsequent requests. Unknown or already revoked tokens produce the same empty HTTP 200 response. Deleting locally stored credentials alone doesn't revoke a live server connection.

## Public website access

Public GET and HEAD endpoints, anonymous MCP and A2A provide read-only information. They don't accept audit submissions or grant customer account permissions. [Create an account](https://app.tityra.com/signup) or [sign in](https://app.tityra.com/login) to request an audit from your project in Tityra.

## Machine-readable permissions

Read [the public permission document](/api/v1/permissions) and [OpenAPI](/openapi.json). The anonymous get_audit_options tool reads packages and account entry links. The separate customer resource requires OAuth consent, selected projects and current account permissions.

## Onboarding and test boundaries

Use the [public quick start](/docs#quick-start) to read permissions and current packages without credentials. Use isolated fixtures for write tests. Never submit customer tokens to the public website API or anonymous agent interfaces.
