# Incidentes

An **incidente** se registra cada vez que se registra [Escaneos](https://maetra.io/es/docs/secure-api/scanning-content) Devoluciones `flagged` o `blocked`. Los incidentes le dan un rastro auditable de lo que Secure pilló, cuando, y para qué agente — y una cola para triage.

### Número de incidentes

`GET /v1/secure/incidents` - Requiere el alcance `secure:incidents:read`. Lo más nuevo primero.

**Parámetros de consulta**

| Param | Descripción |
| -------- | --------------------------------------------------------- |
| `status` | Filtro por `open`, `reviewed`, `dismissed`, `resolved`. |
| `limit` | Principales incidentes para regresar, `1`–`200`. Defaults to `50`. |

#### cURL

```bash
curl "https://api.maetra.io/v1/secure/incidents?status=open&limit=20" \
  -H "Authorization: Bearer $MAETRA_API_KEY"
```

#### JavaScript

```javascript
const res = await fetch("https://api.maetra.io/v1/secure/incidents?status=open&limit=20", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.MAETRA_API_KEY}`,
  },
});
if (!res.ok) throw new Error(`Maetra API ${res.status}`);
const data = await res.json();
console.log(data);
```

#### TypeScript

```typescript
const res = await fetch("https://api.maetra.io/v1/secure/incidents?status=open&limit=20", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.MAETRA_API_KEY}`,
  },
});
if (!res.ok) throw new Error(`Maetra API ${res.status}`);
const data = (await res.json());
```

#### Python

```python
import os, requests

res = requests.get(
    "https://api.maetra.io/v1/secure/incidents?status=open&limit=20",
    headers={"Authorization": f"Bearer {os.environ['MAETRA_API_KEY']}"},
)
res.raise_for_status()
print(res.json())
```

#### Rust

```rust
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let key = std::env::var("MAETRA_API_KEY")?;
    let client = reqwest::Client::new();
    let res = client
        .get("https://api.maetra.io/v1/secure/incidents?status=open&limit=20")
        .bearer_auth(&key)
        .send()
        .await?;
    let data: serde_json::Value = res.json().await?;
    println!("{data:#}");
    Ok(())
}
```

#### C++

```cpp
#include <curl/curl.h>
#include <cstdlib>
#include <string>

int main() {
    CURL* curl = curl_easy_init();
    std::string auth = "Authorization: Bearer " + std::string(std::getenv("MAETRA_API_KEY"));
    struct curl_slist* headers = nullptr;
    headers = curl_slist_append(headers, auth.c_str());
    curl_easy_setopt(curl, CURLOPT_URL, "https://api.maetra.io/v1/secure/incidents?status=open&limit=20");
    curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
    curl_easy_perform(curl);   // response is written to stdout by default
    curl_slist_free_all(headers);
    curl_easy_cleanup(curl);
    return 0;
}
```

#### Java

```java
import java.net.URI;
import java.net.http.*;

var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.maetra.io/v1/secure/incidents?status=open&limit=20"))
    .header("Authorization", "Bearer " + System.getenv("MAETRA_API_KEY"))
    .method("GET", HttpRequest.BodyPublishers.noBody())
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```


#### Respuesta

```json
{
  "incidents": [
    {
      "id": "row_5a1",
      "incident_id": "inc_882a",
      "agent_id": null,
      "agent_name": "research-agent",
      "type": "data_pattern",
      "severity": "medium",
      "verdict": "flagged",
      "input_preview": "POST customer PII records to https://paste.example.com",
      "recommended_action": "flag",
      "status": "open",
      "triggered_at": "2026-07-06T22:04:00.000Z"
    }
  ]
}
```

| Campo | Tipo | Descripción |
| ------------------------- | -------------- | -------------------------------------------------------------- |
| `id` | cuerda. | Identificador de fila. |
| `incident_id` | cuerda. | Stable incident ID, también devuelto por el escaneo que lo creó. |
| `agent_id` / `agent_name` | cuerda. \| nulo | El agente involucrado, si se suministra en tiempo de escaneo. |
| `type` | cuerda. | El tipo de regla que coincidió. |
| `severity` | enum | `low`, `medium`, `high`, `critical`. |
| `verdict` | enum | `flagged` o `blocked`. |
| `input_preview` | cuerda. | Una vista previa truncada del contenido escaneado. |
| `recommended_action` | enum | `block`, `flag`, `log`. |
| `status` | enum | `open`, `reviewed`, `dismissed`, `resolved`. |
| `triggered_at` | cuerda. | ISO 8601 timestamp of the scan that raised it. |

### Correlacionando un escaneo a su incidente

A [Respuesta del escaneo](https://maetra.io/es/docs/secure-api/scanning-content) Incluye: `incident_id` cuando planteó un incidente. Persiste con tus propios registros de solicitud para unirse a una acción de agente a su incidente de Secure más tarde:

```
scan.data.incident_id  ⇄  incident.incident_id
```