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

# Imposta flag di retention

> Segna un dataset per retention a lungo termine, oppure rimuovi il flag.

**`PUT`** `https://api-datahub.octoparse.com/v1/datasets/{dataset_id}/retention`

Autenticazione: API key obbligatoria (`Authorization: Bearer <API Key>`).

Risultati run di default 90 giorni dalla creazione. Dataset con flag retention esclusi dalla cleanup di expiry. Il flag è dichiarazione esplicita: leggere non rinnova; set/clear sono idempotenti.

Puoi marcare solo i tuoi dataset. Dataset altrui, seed pubblico o id mancante → `404`. Il gate di mark è più stretto della visibilità perché i seed non sono tuo output e non vengono puliti: marcarli non ha senso.

## Richiesta

### Parametri di percorso

<ParamField path="dataset_id" type="string" required>
  ID del dataset.
</ParamField>

### Body della richiesta

<ParamField body="retained" type="boolean" required>
  `true` per trattenere, `false` per azzerare il flag.
</ParamField>

### Esempio di richiesta

```bash theme={null}
curl -X PUT   -H "Authorization: Bearer $OCTOPARSE_API_KEY"   -H "Content-Type: application/json"   -d '{"retained": true}'   "https://api-datahub.octoparse.com/v1/datasets/ds_0bd5345d13d0/retention"
```

## Risposta

### 200 successo

```json theme={null}
{
  "data": {
    "dataset_id": "ds_0bd5345d13d0",
    "retained": true
  }
}
```

### Errori

| HTTP | `code`              | `category`  | Descrizione                                                                |
| ---- | ------------------- | ----------- | -------------------------------------------------------------------------- |
| 401  | `unauthorized`      | `forbidden` | API key mancante o non valida.                                             |
| 404  | `dataset-not-found` | `not_found` | Il dataset non esiste, non è tuo o è un seed set pubblico (non marcabile). |

Le risposte di errore usano `{"error": {code, category, message, retryable}}`. Vedi <a href="/docs/it/datahub/api/reference/introduction#errors">Errori</a>.

## Librerie client

<CodeGroup>
  ```python Python theme={null}
  client.set_dataset_retention("ds_0bd5345d13d0", retained=True)
  ```

  ```js JavaScript theme={null}
  await client.setDatasetRetention("ds_0bd5345d13d0", true);
  ```
</CodeGroup>
