# PATCH /v1/sites/{id}

Actualizar un sitio parcialmente

Envía al menos uno de los campos `category` (`mainstream`, `adult` o `network`) y `notes`. La nota para el equipo de revisión admite hasta 500 caracteres y se devuelve en `publisher_note`. Para borrarla, envía `null` o una cadena vacía. Devuelve 200 cuando se completa la actualización. Algunos cambios de categoría de un sitio aprobado requieren revisión. La respuesta 202 incluye la categoría solicitada en `pending_category`, y el sitio mantiene su `category` actual hasta que termine la revisión. Envía la categoría actual para cancelar la solicitud pendiente. Requiere el scope `publisher:write` (clave de API o sesión web); no disponible en el modo «ver como». Nivel de límite de uso: `write`.

- Scope requerido: `publisher:write`
- Límite de uso: `write` — 20 solicitudes por ventana de 60 s por clave de API o sesión web

## Parámetros

| Nombre | En | Tipo | Requerido |
|---|---|---|---|
| `id` | path | integer | sí |

## Cuerpo petición

```
{ category?: "mainstream" | "adult" | "network"; notes?: string | null }
```

## Respuesta

```
{ category: "mainstream" | "adult" | "network"; created_at: string; deleted_at: string | null; domain: string; id: integer; notes: string | null; pending_category: "mainstream" | "adult" | "network" | null; pending_category_at: string | null; publisher_note: string | null; status: "pending" | "approved" | "rejected"; zones_count: integer }
```

## Errores

Las rutas con límite de uso devuelven `RateLimit-Limit`, `RateLimit-Remaining` y `RateLimit-Reset` (segundos hasta que termina la ventana); un 429 incluye además `Retry-After`. Los encabezados pueden faltar mientras el limitador no esté disponible temporalmente (en ese caso las solicitudes se dejan pasar).

| Estado | Significado |
|---|---|
| 401 | Clave de API ausente, no válida o revocada. |
| 403 | La clave no tiene el scope requerido, o la operación no está permitida para este actor. |
| 429 | Límite de uso superado; espera los segundos indicados en `Retry-After`. |
| 400 | Default Response |
| 404 | Default Response |
| 409 | Default Response |

## Ejemplos

### cURL

```bash
#!/usr/bin/env bash
# Request mainstream for a site. HTTP 202 means it keeps its current category while the request is reviewed.
# Needs AGIMONE_API_KEY, AGIMONE_SITE_ID, curl and jq. Optional AGIMONE_API_BASE overrides the API URL.
set -euo pipefail
BASE="${AGIMONE_API_BASE:-https://app.agimone.com}"
SITE_ID="${AGIMONE_SITE_ID:?Set AGIMONE_SITE_ID to the site ID}"
curl -fsS -X PATCH -H "Authorization: Bearer $AGIMONE_API_KEY" -H 'Content-Type: application/json' \
  --data '{"category":"mainstream"}' "$BASE/v1/sites/$SITE_ID" | jq -c '{category, pending_category}'
```

### Node.js

```js
// Request mainstream for a site. HTTP 202 means it keeps its current category while the request is reviewed.
// Needs AGIMONE_API_KEY, AGIMONE_SITE_ID and Node 18+. Optional AGIMONE_API_BASE overrides the API URL.
const base = process.env.AGIMONE_API_BASE ?? 'https://app.agimone.com';
const siteId = process.env.AGIMONE_SITE_ID;
if (!siteId) {
  console.error('Set AGIMONE_SITE_ID to the site ID.');
  process.exit(1);
}

const res = await fetch(`${base}/v1/sites/${siteId}`, {
  method: 'PATCH',
  headers: { Authorization: `Bearer ${process.env.AGIMONE_API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ category: 'mainstream' }),
});
if (!res.ok) {
  console.error(`HTTP ${res.status}: ${await res.text()}`);
  process.exit(1);
}
const { category, pending_category } = await res.json();
console.log(JSON.stringify({ category, pending_category }));
```

### PHP

```php
<?php
// Request mainstream for a site. HTTP 202 means it keeps its current category while the request is reviewed.
// Needs AGIMONE_API_KEY, AGIMONE_SITE_ID and PHP 8 with cURL. Optional AGIMONE_API_BASE overrides the API URL.
$base = getenv('AGIMONE_API_BASE') ?: 'https://app.agimone.com';
$siteId = getenv('AGIMONE_SITE_ID');
if (!$siteId) {
    fwrite(STDERR, "Set AGIMONE_SITE_ID to the site ID.\n");
    exit(1);
}

$ch = curl_init("$base/v1/sites/$siteId");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('AGIMONE_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => json_encode(['category' => 'mainstream']),
    CURLOPT_TIMEOUT => 15,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
    fwrite(STDERR, "HTTP $status: " . ($body === false ? curl_error($ch) : $body) . "\n");
    exit(1);
}
curl_close($ch);
$site = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
echo json_encode(['category' => $site['category'], 'pending_category' => $site['pending_category']]), "\n";
```

### Python

```python
# Request mainstream for a site. HTTP 202 means it keeps its current category while the request is reviewed.
# Needs AGIMONE_API_KEY, AGIMONE_SITE_ID and Python 3.8+. Optional AGIMONE_API_BASE overrides the API URL.
import json
import os
import sys
import urllib.error
import urllib.request

base = os.environ.get("AGIMONE_API_BASE", "https://app.agimone.com")
site_id = os.environ.get("AGIMONE_SITE_ID")
if not site_id:
    sys.exit("Set AGIMONE_SITE_ID to the site ID.")

req = urllib.request.Request(
    f"{base}/v1/sites/{site_id}",
    data=json.dumps({"category": "mainstream"}).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['AGIMONE_API_KEY']}",
        "Content-Type": "application/json",
    },
    method="PATCH",
)
try:
    with urllib.request.urlopen(req, timeout=15) as res:
        site = json.load(res)
        print(json.dumps({"category": site["category"], "pending_category": site["pending_category"]}))
except urllib.error.HTTPError as e:
    print(f"HTTP {e.code}: {e.read().decode()}", file=sys.stderr)
    sys.exit(1)
```

Documentación HTML: https://agimone.com/es/developers/api/#patch-site
API 2026-10
