Description: Creates a new archive policy in Artifactory using the provided policy configuration.
Note: This Cold Artifact Storage feature is available only for Artifactory Enterprise and Enterprise+ users.
Since: Artifactory 7.27.3
Security: Requires an admin user
Usage: POST /api/retention/archive/policies/{key}
Produces: application/json
Consumes: application/json
Request Parameters:
Parameters | Type | Description | Required/Optional |
---|---|---|---|
| string | Unique policy key that identifies the policy. | Required |
| boolean | Enable/disable policy. If disabled, policy execution is blocked. | Required |
| string | The Cron expression for scheduling the policy. | Required |
| string | Search for artifacts to be archived using Artifactory Query Language (AQL). This can be used instead of The AQL query can be to:
NoteYou may run AQL queries only on the Item domain. Other primary domains, such as Build, Entry, Promotion, and Release are not supported. | Required if |
| string | Search Criteria Form for retention policy. This can be used instead of | Required if |
| string | Description for the policy. | Optional |
| long | The maximum duration (in minutes) for policy execution. If policy execution exceeds this period, it is stopped. | Optional |
| long | The expiration period (in months) that it takes for archived artifacts to be cleaned up from the Cold instance. | Optional |
| boolean | Prevent the transfer of the artifacts to the trash can repository, and allow the artifacts to be deleted by a full GC cleanup. Default value is | Optional |
Search Criteria Form
Field | Type | Description |
---|---|---|
| string | Include/Exclude all properties with the specified Supports Example "properties": { "include": { "operator": "or", "values": [ { "propertyKey": "example-prop-key-1", "propertyValue": "prop-val-1" }, { "propertyKey": "example-prop-key-1", "propertyValue": "prop-val-2" } ] }, "exclude": { "operator": "or", "values": [ { "propertyKey": "example-prop-key-2", "propertyValue": "prop-val-1" } ] } } |
| string | Include/Exclude all repository keys. Supports and/or operator. ExampleExample "repositories": { "include": { "operator": "or", "values": [ "repo-1", "repo-2" ] }, "exclude": { "operator": "and", "values": [ "repo-*", "*-3" ] } } |
| string | Include/Exclude all items with specified paths Supports ExampleExample "paths": { "include": { "operator": "or", "values": [ "path-1", "path-2" ] }, "exclude": { "operator": "or", "values": [ "path-3" ] } } |
| string | Include/Exclude all items with the specified names. Supports ExampleExample "names": { "include": { "operator": "or", "values": [ "name-1", "name-2" ] }, "exclude": { "operator": "or", "values": [ "name-3" ] } } |
| long | Include all items that were created before the time provided (in months) |
| long | Include all items that were last downloaded before the time provided (in months) |
Sample Request: Using aqlQuery
parameter
POST /api/retention/archive/policies/example-policy-key
{ "key": "example-policy-key", "enabled": true, "description": "policy description", "aqlQuery": "items.find({\"type\":{\"$eq\":\"file\"}})", "cronExp": "0 15 10 L * ?", "durationInMinutes": 0, "expirationTimeInMonths": 0, "skipTrashcan": true }
Sample Response: For aqlQuery
parameter
{ "key": "example-policy-key", "enabled": true, "description": "policy description", "aqlQuery": "items.find({\"type\":{\"$eq\":\"file\"}})", "cronExp": "0 15 10 L * ?", "durationInMinutes": 0, "expirationTimeInMonths": 0, "skipTrashcan": true }
Sample Request: Using searchCriteriaForm
parameter
POST /api/retention/archive/policies/example-policy-key
{ "key": "myPolicy", "description": "Demo policy - archive using search criteria form", "enabled": true, "searchCriteriaForm": { "properties": { "include": { "values": [{ "propertyKey":"sd", "propertyValue":"sd" }] }, "exclude": { "values": [ ] } }, "repositories": { "include": { "values": [ "include-*", "*-repo" ] }, "exclude": { "values": [] } }, "paths": { "include": { "values": [] }, "exclude": { "values": [ "exclude-*", "*-path" ] } }, "createdBefore":2, "downloadedBefore":3 } }
Sample Response: Using searchCriteriaForm
parameter
{ "key": "myPolicy", "enabled": true, "description": "Demo policy - archive using search criteria form", "durationInMinutes": 0, "expirationTimeInMonths": 0, "skipTrashcan": false, "searchCriteriaForm": { "properties": { "include": { "operator": "or", "values": [ { "propertyKey": "sd", "propertyValue": "sd" } ] }, "exclude": { "operator": "or", "values": [] } }, "repositories": { "include": { "operator": "or", "values": [ "include-*", "*-repo" ] }, "exclude": { "operator": "or", "values": [] } }, "paths": { "include": { "operator": "or", "values": [] }, "exclude": { "operator": "or", "values": [ "exclude-*", "*-path" ] } }, "createdBefore": 2, "downloadedBefore": 3 } }
Status:
201: Success
409: If a policy with the specified policyKey already exists, the call fails with a 409 response.