---
schema_version: "1"
id: c0e32919c524a1daefbfe0598235c5c50eff3a4bd8e3e0c36a5bdeb236a8f8bf
title: ArchivePolicyDefinition
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/object_reference/sforce_api_objects_archivepolicydefinition.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_archivepolicydefinition.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1d133d5efd5396ade8365687b327db76f6eabfebc12f187b99734313e52a4e13
description: Represents a data lifecycle policy in Salesforce. Each record defines the scope, frequency, and rules that govern automated archiving or purging of records from a root entity, such as Contact or Lead. This object is available in API version 65.0 and later.
---
# ArchivePolicyDefinition

Represents a data lifecycle policy in Salesforce. Each record defines the scope, frequency, and rules that govern automated archiving or purging of records from a root entity, such as Contact or Lead. This object is available in API version 65.0 and later.

## Supported Calls

create(), delete(), describeSObjects(), query(), retrieve(), update(), upsert()

## Special Access Rules

Create, update, and delete operations are restricted to the Archive Admin profile. All other profiles have read-only access to this object.

![Important](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note_important.png)

#### Important

In API version 68.0, changes to ArchivePolicyDefinition records through the API don't affect policy execution. This object provides a representation of each policy for auditing and reporting. Archiving and purging behavior is controlled solely through the policy setup flow on the Archive Policies tab.

![Important](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/images/icon_note_important.png)

#### Important

Archive policies created before API version 68.0 can show incomplete field values on the ArchivePolicyDefinition object. The Archive back end is the source of truth for these policies, and their field values aren't copied to this object in version 68.0. Policies created in version 68.0 or later show complete field values.

## Fields

| Field | Details |
| --- | --- |
| ArchivePolicyRelObjSelection | 
Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

Determines the policy object selection method. Available in API version 68.0 and later.

Valid values are:

- CompleteHierarchy—Archives all related objects.
- CustomSelection—Specifies which related objects to include using the RelatedObjects field.
- SingleLevel—Archives only the root entity records without related objects.





 |
| ContentDocumentObject | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The API name of the Salesforce content object to include when IsArchiveRelatedFiles is enabled. If the root object is ContentDocument, this field specifies the secondary object used to filter which content documents to archive. For example, archive only content documents attached to Cases or Accounts. Available in API version 68.0 and later.



 |
| DataProtectionThreshold | 

Type

int

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Specifies a retention buffer, in days, during which recently updated or sensitive records aren't archived or deleted.



 |
| Description | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The purpose or scope of the policy.



 |
| DeveloperName | 

Type

string

Properties

Create, Filter, Group, Sort, Update

Description

The API name of the policy. This name must be unique in Salesforce, begin with a letter, and contain only underscores and alphanumeric characters.



 |
| FilterConditions | 

Type

textarea

Properties

Create, Nillable, Update

Description

Additional Salesforce Object Query Language (SOQL) filter conditions that refine which records are eligible for archiving or purging. These conditions are appended to the Query field using AND logic. Available in API version 68.0 and later.



 |
| IsActive | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates whether the policy is active and eligible for execution. Only active policies can run through scheduled or manual processes. The default value is false.



 |
| IsAnalyzed | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates whether the policy has been analyzed by the Archive Storage Analyzer. The default value is false. When set to true, the policy has undergone analysis to optimize storage and performance. Available in API version 68.0 and later.



 |
| IsArchiveRelatedFiles | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Specifies whether to archive related files along with the root entity records. When set to true, any attached files or attachments are archived when a root record or any of its child records are archived. When set to false, files aren't archived. The default value is false. Available in API version 68.0 and later.



 |
| IsBoostEnabled | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates whether performance boosting is enabled for this policy. When set to true, the policy runs eight parallel activities to improve execution speed. The default value is false. Available in API version 68.0 and later.



 |
| IsLogFailuresAndContinue | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Specifies whether to log individual record failures and continue processing or to roll back the entire transaction on error. When set to true, if a deletion fails, the archived record remains in production. A duplicate record then exists in both the archive and production environments. This option is recommended when archive jobs involve root records with more than 800 related objects. When set to false, any failure rolls back the entire transaction. The default value is false. Available in API version 68.0 and later.



 |
| IsSoftDeleted | 

Type

boolean

Properties

Create, Defaulted on create, Filter, Group, Sort, Update

Description

Indicates whether the policy has been soft deleted. Soft deleted policies are marked for deletion but not removed permanently. The default value is false.



 |
| MasterLabel | 

Type

string

Properties

Create, Filter, Group, Sort, Update

Description

The label for this policy. This value is the policy name that you enter.



 |
| NamespacePrefix | 

Type

string

Properties

Filter, Group, Nillable, Sort

Description

Reserved for internal use. This field is null for Archive policies in core Salesforce. It's populated only if the policy is part of an installed managed package, enabling policy deployment and copying to other orgs. Available in API version 68.0 and later.



 |
| PreviewFields | 

Type

textarea

Properties

Create, Nillable, Update

Description

Semicolon-separated list of field API names displayed in the Preview Table. The Preview feature runs the policy's SOQL query and shows matching records with the fields specified here. For example, Id;Description;Name. Available in API version 68.0 and later.



 |
| Query | 

Type

textarea

Properties

Create, Nillable, Update

Description

A complete SOQL query that defines the set of records to archive or purge based on the policy rules. Determines which records are eligible for processing.



 |
| QueryLimit | 

Type

int

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The maximum number of root records this policy can process in a single run.



 |
| RelatedObjects | 

Type

textarea

Properties

Create, Nillable, Update

Description

JSON object that specifies which related objects to include in archive operations when ArchivePolicyRelObjSelection is set to CustomSelection. The relationships array lists each parent-to-child relationship to archive. In each entry, childName is the child object to archive, parentObject is the object it's related to, and fieldName is the lookup or master-detail field on the child object that references the parent. For example: {"relationships":\[{"parentObject":"Account","childName":"Case","fieldName":"AccountId"},{"parentObject":"FeedItem","childName":"FeedAttachment","fieldName":"RecordId"}\]}. Leave empty when using the CompleteHierarchy selection method. To identify valid relationship fields, query the object metadata to find lookup or master-detail fields that reference the parent object. Available in API version 68.0 and later.



 |
| RetentionMonths | 

Type

int

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The number of months to retain archived records before they are eligible for permanent deletion. This value is added to RetentionYears to calculate the total retention period. For example, if RetentionYears is 3 and RetentionMonths is 6, records are retained for 3 years and 6 months (42 months total). Valid values are 0 through 11. Available in API version 68.0 and later.



 |
| RetentionSource | 

Type

string

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

Specifies the source date used to calculate the retention period for archived records. Available in API version 68.0 and later.

Accepted values are:

- ArchivedDate—Retention period starts from when the record was archived. This value is the default.
- CreatedDate—Retention period starts from when the record was originally created.
- LastModifiedDate—Retention period starts from when the record was last modified.





 |
| RetentionYears | 

Type

int

Properties

Create, Filter, Group, Nillable, Sort, Update

Description

The number of years to retain archived records before they are eligible for permanent deletion. This value is added to RetentionMonths to calculate the total retention period. For example, if RetentionYears is 3 and RetentionMonths is 6, records are retained for 3 years and 6 months (42 months total). Valid values are 0 or greater. Available in API version 68.0 and later.



 |
| RootEntityName | 

Type

string

Properties

Create, Filter, Group, Sort, Update

Description

The API name of the Salesforce object targeted by the policy.



 |
| RunFrequency | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

Specifies how often the policy runs—manually or on a regular interval. Enables automation for recurring data lifecycle operations.

Valid values are:

- Daily
- Monthly
- None—For manual policy runs.
- Weekly





 |
| Schedule | 

Type

textarea

Properties

Create, Nillable, Update

Description

JSON object that represents when the policy runs, based on the RunFrequency setting. It specifies the frequency, the day of the week or month, and the time of day in UTC (Coordinated Universal Time). The Archive UI displays this time translated to the time zone of your Salesforce org. For example, this schedule represents a policy that runs on the second day of every month at 01:00 UTC: {"frequency":"Monthly","day\_of\_month":2,"time\_to\_schedule":"01:00"}. For a weekly schedule, the day of the week is a number from 0 through 6, where 0 represents Sunday. This field is null when RunFrequency is set to None. Available in API version 68.0 and later.



 |
| Type | 

Type

picklist

Properties

Create, Filter, Group, Nillable, Restricted picklist, Sort, Update

Description

Process type that the policy executes.

Valid values are:

- Archiving
- Import
- None
- Purge





 |