# User-Agent Policy

## Overview

The Arizona Court of Appeals Division Two API logs User-Agent headers for abuse detection and monitoring. This policy applies to all API endpoints.

## Logging

- All requests to `/api/*` and `/serveFile.php` have their User-Agent logged
- Logs are stored in `/var/log/nginx/api_access.log` and `/var/log/nginx/file_access.log`
- Log format includes: timestamp, remote user, request, status, bytes sent, User-Agent, request time

## Allowed User-Agents

### Automatically Allowed

- **Browsers**: Mozilla Firefox, Chrome, Safari, Edge, etc.
- **Common bots**: Googlebot, Bingbot, DuckDuckBot, BaiduSpider
- **Official crawlers**: Any bot identifying itself clearly with a standard User-Agent string

### Recommended for AI Assistants

AI assistants should identify themselves clearly:

```
Mozilla/5.0 (compatible; YourBot/1.0; +https://yourdomain.com/bot)
```

### Required Elements

1. **Standard prefix**: `Mozilla/5.0` or `curl` / `python-requests` etc.
2. **Bot identifier**: `YourBot/1.0` or similar
3. **Contact URL**: `+https://yourdomain.com/bot` (required for search engines)

## Rate Limiting

- **Standard limit**: 100 requests per hour per IP
- **Burst allowance**: 20 requests
- **Exceeded limit**: Returns HTTP 429 Too Many Requests

## Abuse Detection

The following patterns may be flagged:

- **No User-Agent header**: Request may be blocked or rate-limited
- **Empty User-Agent**: Treated as suspicious
- **Rapid succession requests**: May trigger rate limiting
- **Scripted access without identification**: Logged for review

## Best Practices

### For AI Assistants and Bots

1. **Always include a User-Agent header**
2. **Identify yourself clearly**
3. **Respect rate limits**
4. **Include a contact URL**

### Example User-Agents

```
# Browser
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

# Python script
python-requests/2.31.0

# Custom bot
Mozilla/5.0 (compatible; MyAIAssistant/1.0; +https://example.com/bot)

# curl
curl/8.4.0
```

## Contact

If you need to discuss rate limits or access policies, please contact:
- Court of Appeals Division Two
- Email: [public@appeals2.az.gov](mailto:public@appeals2.az.gov)

## Security

- User-Agent logging helps identify automated access patterns
- Suspicious patterns are reviewed by system administrators
- No personal information is stored in logs
- Logs are retained for 90 days

---

*Last updated: 2025-11-20*
