Skip to content
Agentpost robot in sunglasses on a red circleAgentpost

Change ResourceShark’s config

Use this guide to change how long ResourceShark keeps change feed entries and the details of resolved holds. A project starts with both set to 30d when it adopts ResourceShark, and each environment has its own config.

Before you start

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.

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 has both operations and every field of the config.

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

On 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.

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.