> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hadoseo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Purge Cache

> Re-render a specific page and refresh its cached HTML

```
POST /functions/v1/purge-cache
```

Triggers a fresh re-render of a single page and updates the cached HTML. The re-render happens asynchronously — the endpoint returns immediately once the job is queued. This also works for new pages that aren't cached yet — use it to pre-warm cache so the page is ready before a bot visits.

<Warning>
  Always call this endpoint from a **server-side environment** (backend API, serverless function, build script, etc.). Never include your API key in client-side code — it will be visible to anyone inspecting your frontend.
</Warning>

## Request

### Headers

| Header          | Required | Description                    |
| --------------- | -------- | ------------------------------ |
| `Authorization` | Yes      | `Bearer hado_sk_your_key_here` |
| `Content-Type`  | Yes      | `application/json`             |

### Body Parameters

| Parameter | Type   | Required | Description                                                                        |
| --------- | ------ | -------- | ---------------------------------------------------------------------------------- |
| `domain`  | string | Yes      | The domain to purge (e.g., `"example.com"`). Must be a domain you own in Hado SEO. |
| `path`    | string | Yes      | The URL path to purge (e.g., `"/about"` or `"/blog/my-post"`).                     |

### Example Request

```bash theme={null}
curl -X POST https://api.hadoseo.com/functions/v1/purge-cache \
  -H "Authorization: Bearer hado_sk_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "example.com",
    "path": "/about"
  }'
```

## Response

### Success (200)

```json theme={null}
{
  "queued": true,
  "path": "/about",
  "message": "Re-render job queued"
}
```

The page will be re-rendered in the background. Fresh cached HTML is typically available within seconds.

### Error Responses

| Status | Body                                                             | Description                                               |
| ------ | ---------------------------------------------------------------- | --------------------------------------------------------- |
| 400    | `{ "error": "invalid_request" }`                                 | Missing or invalid `domain` or `path` parameter           |
| 401    | `{ "error": "invalid_api_key" }`                                 | API key is missing, invalid, or revoked                   |
| 403    | `{ "error": "domain_not_authorized" }`                           | The API key's owner does not have this domain in Hado SEO |
| 429    | `{ "error": "rate_limit_exceeded", "usage": 300, "limit": 300 }` | Monthly or per-minute rate limit exceeded                 |

<Info>
  When you receive a **429**, the `usage` and `limit` fields tell you where you stand against your monthly quota. Per-minute limits (60 req/min) reset automatically after 60 seconds.
</Info>

## Examples

### JavaScript / Node.js

```javascript theme={null}
const response = await fetch("https://api.hadoseo.com/functions/v1/purge-cache", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.HADOSEO_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    domain: "yourapp.com",
    path: "/about",
  }),
});

const data = await response.json();
console.log(data); // { queued: true, path: "/about", message: "Re-render job queued" }
```
