---
title: "Change ResourceShark's config"
description: "Read a project's ResourceShark config and replace its retention settings, using the version you read."
url: "https://agentpost.tools/docs/resourceshark/guides/config"
kind: guide
needs:
  - what: "The `api` helper"
    from: "https://agentpost.tools/docs/platform/quickstart.md"
  - what: "A `dev` secret key, `key`, for a project that adopted ResourceShark"
    from: "https://agentpost.tools/docs/platform/guides/keys.md"
---

# Change ResourceShark’s config

Use this guide to change how long ResourceShark keeps [change feed entries](/docs/resourceshark/concepts/change-feed.md) and the details of resolved [holds](/docs/resourceshark/concepts/holds.md). A project starts with both set to `30d` when it adopts ResourceShark, and each environment has its own config.

## Before you start

-   The `api` helper, from [Platform quickstart](/docs/platform/quickstart.md).
-   A `dev` secret key, `key`, for a project that adopted ResourceShark, from [Create a project and issue a key](/docs/platform/guides/keys.md).

This page's code continues the script of the pages above: run its blocks after theirs, in the same file. To run them as a script of their own, first copy each helper from the page that defines it, and set each other value, such as a key or an ID, to one you already have.

## 1\. Read the config in `dev`

Use the project’s `dev` secret key, `key`, to read the settings and their version. The key selects the environment.

```ts
const resourceConfigPath = '/v1/resources/config';
const { config: resourceConfig } = await api('GET', resourceConfigPath, key);
```

## 2\. Send both retention settings with `If-Match`

Set retention for new change feed entries to 60 days and send back the existing resolved hold retention. Send every setting and put the version you read in `If-Match`. The answer’s fields `version`, `updatedAt`, and `updatedBy` stay out of the request body. [Config](/docs/resourceshark/reference/config.md) has both operations and every field of the config.

```ts
const resourceRetention = {
  events: '60d',
  resolvedHolds: resourceConfig.retention.resolvedHolds,
};
await api(
  'PUT',
  resourceConfigPath,
  key,
  { retention: resourceRetention },
  { 'If-Match': String(resourceConfig.version) },
);
```

On [`stale_version`](/docs/resourceshark/errors.md#stale_version), read the config again and apply your change to the new settings before retrying.

## Check it worked

Read the config again and check both settings.

```ts
const { config: savedResourceConfig } = await api(
  'GET',
  resourceConfigPath,
  key,
);
console.log(
  savedResourceConfig.retention.events === resourceRetention.events,
  savedResourceConfig.retention.resolvedHolds ===
    resourceRetention.resolvedHolds,
); // true true
```

Use the same `dev` key to [sell prepaid credits](/docs/resourceshark/guides/prepaid-credits.md).
