# Data Object Lifecycle

For reproducibility and ease of collaboration, data objects on the DNAnexus Platform follow a lifecycle that begins in an **open** state where the underlying data can be modified, and transitions to a **closed** state where the data can be accessed and shared reliably. Some classes, such as records, can be created and closed in the same operation (see the "close" option in the [new record](https://documentation.dnanexus.com/developer/introduction-to-data-object-classes/records#api-method-record-new) method). The data object ID remains constant when shared, though [some metadata](https://documentation.dnanexus.com/developer/api/introduction-to-data-object-metadata) fields can change without affecting data interpretation. In the closed state, the object's underlying data becomes fixed. This includes content such as the contents of files. The following metadata fields are also fixed when the data object is closed:

* [Types](https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types): a list of type conventions that the data object adheres to.
* [Details and Links](https://documentation.dnanexus.com/developer/api/data-object-lifecycle/details-and-links): the **details** field stores arbitrary JSON that can contain **links** to other existing data objects.
* [Visibility](https://documentation.dnanexus.com/developer/api/data-object-lifecycle/visibility): a boolean indicating whether the object is "visible" or not. A linked hidden object is (almost) always removed or cloned with its closest visible ancestor. See the section on [cloning](https://documentation.dnanexus.com/developer/api/data-containers/cloning) for more information.

Users may [search](https://documentation.dnanexus.com/developer/api/search) through their own data with queries involving these metadata fields.

Some exceptions to this lifecycle exist. Applets are created in the "closed" state. Occasionally, it is desirable to leave a data object in the open state to have a mutable data object. However, only records are accessible in their open state. Files must be closed in order for their underlying data to be accessed. Unless specified otherwise, the following is the specification for the API method to close a data object.

## API method: `/class-xxxx/close`

### Specification

Initiates the process of closing the specified object if the object is not already in the "closing" or "closed" state.

If the object is a file or record in the "closing" or "closed" state, this call has no effect. The call reports success, and the `detail` field is set as shown in "Outputs" below.

### Inputs

* None

### Outputs

* `id` **string** ID of the manipulated object, such as "class-xxxx".
* `detail` **string** An explanatory message.
  * Only present when the object is in the `closing` or `closed` state.

### Errors

* ResourceNotFound (the specified object in the URL does not exist).
* PermissionDenied (UPLOAD access required for the project in which the object was created).
