Last updatedSep 2, 2019

Archiving API

This page provides an overview of how to use API to archive your projects and issues in Jira. Project archiving is available in Jira Data Center 7.10, or later. Issue archiving was relased in Jira Data Center 8.1.

What is archiving?

You can archive any project or issue in Jira if you're no longer working on it. This helps you clean your instance of unused content and also improve performance. After you archive a project, it will be removed from the list of projects, project pickers, and search results. Both you and your users won't be able to access the project itself, but you will be able to view all issues from an archived project if they're mentioned or linked in other projects. These issues will be read-only.

All data related to an archived project will remain in the database, and you can restore the project whenever you need it again.

Archiving with REST API

Here are some examples of how to archive and restore your projects or issues with REST API. For more info about these API calls, see Jira REST API docs:

Archiving an issue:

curl -X PUT https://jira-instance1.net/rest/api/2/issue/PROJ-1/archive

Archiving a list of issues:

curl -d '["KEY-1", "KEY-2"]' -H "Content-Type: application/json" -X POST https://jira-instance1.net/rest/api/2/issue/archive

Restoring an issue:

curl -X PUT https://jira-instance1.net/rest/api/2/issue/PROJ-1/restore

Archiving a project:

curl -X PUT https://jira-instance1.net/rest/api/2/project/PROJ/archive

Restoring a project:

After restoring a project, you need to re-index it to make it appear again in the search results. You can do it in Jira by going to Project settings > Re-index.

curl -X PUT https://jira-instance1.net/rest/api/2/project/PROJ/restore


Archiving with JAVA API

Here are some examples of how to archive and restore your projects with JAVA API. For more info about these API calls, see Jira JAVA API documentation:

Archiving an issue:

1
2
3
4
5
6
ValidationResult validationResult =
        archivedIssueService.validateArchiveIssue(authContext.getLoggedInUser(), issue.getKey());

if (validationResult.isValid()) {
    archivedIssueService.archiveIssue(validationResult);
}

Retrieving the list of archived projects:

ComponentAccessor.getProjectManager().getArchivedProjects();

Checking if a project is archived:

curl -X PUT https://jira-instance1.net/rest/api/2/project/PROJ-1/restore

Archiving a project:

1
2
3
4
5
6
ValidationResult validationResult =
        archivedProjectService.validateArchiveProject(authContext.getLoggedInUser(), project.getKey());

if (validationResult.isValid()) {
    archivedProjectService.archiveProject(validationResult);
}

Restoring a project:

After restoring a project, you need to re-index it to make it appear again in the search results. You can do it in Jira by going to Project settings > Re-index.

1
2
3
4
5
6
ValidationResult validationResult =
        archivedProjectService.validateRestoreProject(authContext.getLoggedInUser(), project.getKey());

if (validationResult.isValid()) {
    archivedProjectService.restoreProject(validationResult);
}

Notifying the plugins about archived projects:

You can use the ProjectArchivedEvent and ProjectRestoredEvent event listeners to notify your plugins whenever a project is archived or restored. Here's an example implementation:

1
2
3
4
5
6
7
8
9
10
public class ArchivedProjectEventListener {
    private static final Logger log = LoggerFactory.getLogger(ArchivedProjectEventListener.class);

    @EventListener
    public void onProjectArchived(ProjectArchivedEvent event) {
        // Removing the data related to event.getProjectId()
        // e.g. cache, or plugin data.
        log.info("A project has been archived.");
    }
}

We recommend that your plugins remove any non-critical data related to archived projects. An example of that is removing data from the index, which Jira does automatically when archiving a project. This data is preserved in the database and can be easily restored later, and there's no need to store it in Jira.