Handling Data Expiry
Having defined policies and sent telemetry to Metronome, the final steps in proper data handling are to delete unused PII once it has served all the many purposes your business needed it for. This is the purpose of expiry notices. You can read expiry notices for a specific date in the past or future, and when expiring data in the past, you inform Metronome that data has been correctly deleted on time. This marks the items as deleted and updates their data handling logs to prove your correct handling when you are audited for data privacy compliance.
Reading Expiry Notices
Section titled “Reading Expiry Notices”To read expiry notices, we must create an instance of the DataExpiryApi client then call the
getExpiryNotices method which has the following signature: getExpiryNotices(date). You can inspect
dates in the past or future.
import { DataExpiryApi, ItemExpiry, SubItemExpiry, PendingExpiries, CompletedExpiries, ServerConfiguration, createConfiguration } from "@privatedataservices/metronome-client";import { explainError } from "./errors";
const clientConfig = createConfiguration( { baseServer: new ServerConfiguration("https://the-flower-boutique.dev.eu-west-1.privatedataservices.com", {}), authMethods: { ApiKeyAuth: process.env.METRONOME_API_KEY }});const expiryApiClient = new DataExpiryApi(clientConfig);
try { const response = await expiryApiClient.getExpiryNotices(new Date(2026, 5, 19));
// Pending expiries may change with use before the reported date. They are advisory only. console.log("There are %d pending expiries on %s", response.pending.length, response.expiryDate); response.pending.forEach( (notice: PendingExpiries) => { if(notice instanceof ItemExpiry) { console.log("Item %s might expire on %s", notice.itemId, response.expiryDate); } else if(notice instanceof SubItemExpiry) { console.log("Sub-item %s of item %s might expire on %s", notice.subItemId, notice.parentItemId, response.expiryDate); } });
// Completed expiries indicate that the data has been deleted by you on this date after which you posted to Metronome to finalise the expiry. console.log("There are %d completed expiries on %s", response.completed.length, response.expiryDate); if (response.completed) { response.completed.forEach( (notice: CompletedExpiries) => { if(notice instanceof ItemExpiry) { console.log("Item %s did expire on %s", notice.itemId, response.expiryDate); } else if(notice instanceof SubItemExpiry) { console.log("Sub-item %s of item %s did expire on %s", notice.subItemId, notice.parentItemId, response.expiryDate); } }); }} catch (err) { explainError(err);}require 'metronome'require_relative 'errors'
# Configure client with API keyclient_config = Metronome::Configuration.newclient_config.scheme = 'https'client_config.host = 'code-examples.dev.eu-west-1.metronome.privatedataservices.com'client_config.api_key['X-API-Key'] = ENV['METRONOME_API_KEY']
expiry_api_client = Metronome::DataExpiryApi.new(Metronome::ApiClient.new(client_config))
begin response = api_client.get_expiry_notices(Date.new(2026, 6, 19))
# Pending expiries may change with use before the reported date. They are advisory only. puts "There are %d pending expiries on %s" % [response.pending.length, response.expiry_date] response.pending.each do |notice| if notice.is_a?(Metronome::ItemExpiry) puts "Item %s might expire on %s" % [notice.item_id, response.expiry_date] elsif notice.is_a?(Metronome::SubItemExpiry) puts "Sub-item %s of item %s might expire on %s" % [notice.sub_item_id, notice.parent_item_id, response.expiry_date] end end
# Completed expiries indicate that the data has been deleted by you on this date after which you posted to Metronome to finalise the expiry. puts "There are %d completed expiries on %s" % [response.completed.length, response.expiry_date] if response.completed response.completed.each do |notice| if notice.is_a?(Metronome::ItemExpiry) puts "Item %s did expire on %s" % [notice.item_id, response.expiry_date] elsif notice.is_a?(Metronome::SubItemExpiry) puts "Sub-item %s of item %s did expire on %s" % [notice.sub_item_id, notice.parent_item_id, response.expiry_date] end end endrescue => err explain_error(err)endDeleting Expired Data
Section titled “Deleting Expired Data”When data has served all of the purposes which the person authorised you to hold the data for, you
must by law delete that data. To do this, you might set a daily job which queries expiry notices
for the day before, thus being sure that the day ended and no other action extended the retention.
Each pending notice must be deleted in your PII stores by your software. Having completed all of
these expiries, you notify Metronome that all the data for that day was successfully expired by
calling the putExpiryNotices method of the DataExpiryApi client, with the only parameter being
the date in question.
import { DataExpiryApi, ServerConfiguration, createConfiguration } from "@privatedataservices/metronome-client";import { explainError } from "./errors";
const clientConfig = createConfiguration( { baseServer: new ServerConfiguration("https://the-flower-boutique.dev.eu-west-1.privatedataservices.com", {}), authMethods: { ApiKeyAuth: process.env.METRONOME_API_KEY }});const expiryApiClient = new DataExpiryApi(clientConfig);
try { await expiryApiClient.putExpiryNotices(new Date(2026, 5, 19)); console.log("Expiry notices finalised successfully");} catch (err) { explainError(err);}require 'metronome'require_relative 'errors'
# Configure client with API keyclient_config = Metronome::Configuration.newclient_config.scheme = 'https'client_config.host = 'code-examples.dev.eu-west-1.metronome.privatedataservices.com'client_config.api_key['X-API-Key'] = ENV['METRONOME_API_KEY']
expiry_api_client = Metronome::DataExpiryApi.new(Metronome::ApiClient.new(client_config))
begin api_client.put_expiry_notices(Date.new(2026, 6, 19)) puts "Expiry notices finalised successfully"rescue => err explain_error(err)end