# Echomark API Path Finder

**Purpose**: Help determine the correct API endpoint path for your Echomark server

---

## Quick Test Script

Run this in your browser console to test different API paths:

```javascript
// Copy and paste this entire block into browser console
const BASE = 'https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345';

const paths = [
  '/api/v2/health',
  '/api/health',
  '/echomark/api/v2/health',
  '/echomark/health',
  '/health',
  '/v2/health'
];

console.log('🔍 Testing Echomark API paths...\n');

for (const path of paths) {
  const url = BASE + path;
  fetch(url, { method: 'GET' })
    .then(r => {
      if (r.ok) {
        console.log(`✅ FOUND: ${path} - Status ${r.status}`);
        return r.text().then(text => {
          console.log(`   Response: ${text.substring(0, 100)}`);
        });
      } else {
        console.log(`❌ ${path} - Status ${r.status}`);
      }
    })
    .catch(e => console.log(`❌ ${path} - Error: ${e.message}`));
}

console.log('\nWaiting for responses...');
```

---

## Method 1: Check Administration Portal

1. Open in browser: https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345
2. Log in to EchoMark Administration Portal
3. Look for:
   - **API Documentation** link
   - **Settings** or **Configuration** page
   - **API Keys** or **Integration** section
4. The correct API base URL should be listed there

---

## Method 2: Check Echomark Documentation

Look in your Echomark setup documentation or the PDF provided:
- [Echomark API Documentation.pdf](../Echomark%20API%20Documentation%20(1).pdf)
- Check the "Base URL" or "Endpoint" section
- Common patterns:
  - `https://hostname:port/api/v2/`
  - `https://hostname:port/echomark/api/v2/`
  - `https://hostname:port/v2/`

---

## Method 3: Contact Echomark Support

If the above methods don't work:

1. Contact Echomark support with your server details
2. Provide: `ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345`
3. Ask for:
   - Correct API base URL
   - Whether authentication is required
   - How to generate API token

---

## Common API Endpoint Patterns

Once you find the base URL, the full endpoints should be:

| Endpoint | Purpose |
|----------|---------|
| `{BASE_URL}/health` | Health check |
| `{BASE_URL}/document/mark/pdf` | Mark PDF documents |
| `{BASE_URL}/document/mark/image` | Mark image files |
| `{BASE_URL}/detect/` | Detect leaked documents |

Where `{BASE_URL}` might be:
- `https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/api/v2`
- `https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/echomark/api/v2`

---

## How to Update Configuration

Once you know the correct path:

### Update echomark-client.js

**File**: [src/lib/echomark-client.js](../src/lib/echomark-client.js#L11)

```javascript
// Line 11 - Update this line:
this.apiUrl = apiUrl || 'https://ec2-52-8-108-29.us-west-1.compute.amazonaws.com:5345/YOUR_CORRECT_PATH';
```

### Test the Connection

1. Reload the extension in Chrome
2. Open [test-echomark-connection.html](../test-echomark-connection.html)
3. Click "Run Health Check"
4. Should see: ✅ Health check passed!

---

## Expected Responses

### Health Check Success
```json
{
  "status": "ok",
  "version": "2.0.3"
}
```

### Document Marking Endpoints (GET request)
Should return `405 Method Not Allowed` - this is correct!
- These endpoints only accept POST requests
- Getting 405 means the endpoint exists

### Common Errors

| Status | Meaning | Solution |
|--------|---------|----------|
| 404 | Path not found | Try different base URL |
| 401 | Unauthorized | Add bearer token |
| 403 | Forbidden | Check permissions/CORS |
| 405 | Method not allowed | OK for marking endpoints with GET |
| 500 | Server error | Check Echomark logs |

---

## Need Help?

Create an issue with:
1. Output from the browser console test
2. Screenshot from Echomark admin portal
3. Any error messages you're seeing

We'll help you find the correct API path!
