# Document Management



Overview [#overview]

Documents are managed, rendered, and associated in several areas within Socotra:

* **Configuration**: See the [Document Resources Configuration Guide](/configuration/resources/documents) for an overview, along with the <ApiLink name="DocumentConfigRef" /> configuration entity.
* **Policy Data**: As managed by the policy system and using the [Document Selection](/configuration/plugins/document-selection) and [Document Data Snapshot](/configuration/plugins/document-data-snapshot) plugin configuration guides.
* **Invoice Documents**: See the [Invoicing Feature Guide](/features/billing/invoicing).
* **Direct Attachment and Modification**: Described below.

Document Retrieval [#document-retrieval]

Documents can be retrieved by locator with the <ApiLink name="fetchDocument">Fetch Document</ApiLink> endpoint. To retrieve all the documents for a given entity, you can use any of these endpoints:

* <ApiLink name="fetchDocumentsForTerm">
    Fetch Documents for a Policy Term
  </ApiLink>
* <ApiLink name="fetchDocumentsForSegment">
    Fetch Documents for a Policy Segment
  </ApiLink>
* <ApiLink name="fetchDocumentsForTransaction">
    Fetch Documents for a Policy Transaction
  </ApiLink>
* <ApiLink name="fetchDocumentsForQuote">
    Fetch Documents for a Quote
  </ApiLink>

Direct Document Attachment and Modification [#direct-document-attachment-and-modification]

Most document creation and updates are configured and then managed automatically, as described in the *Overview*, above. You can extend this functionality with direct actions as described here.

This can be useful for managing "trailing documents," which require information that isn't known at the time of policy or transaction bound time or issue time.

Attaching New Documents [#attaching-new-documents]

The <ApiLink name="attachDocument">Attach Document</ApiLink> endpoint can be used to inject a new document directly into Socotra and associate it with any of the following types of entities:

* Quotes
* Policies
* Policy Transactions
* Policy Terms
* Policy Segments

<ApiLink name="DocumentInstanceResponse">Documents added this way</ApiLink> will
have their `external` property set to `true` to indicate that they weren't
created through normal system behavior.

Documents added this way must be fully rendered before upload, such as a full PDF file. Socotra document templates are not used for producing these documents.

Updating Documents [#updating-documents]

Documents that already exist in the system can be updated with the <ApiLink name="replaceDocument">Replace Document</ApiLink> endpoint. You can change the following:

* The `metadata` for the document
* The document `category`
* The document itself

<span id="DeletingDocuments" />

Deleting Documents [#deleting-documents]

External documents, which are documents manually attached through the <ApiLink name="attachDocument">Attach Document</ApiLink> endpoint, can be deleted using the <ApiLink name="deleteDocument">Delete Document</ApiLink> API endpoint.

Documents generated by the platform cannot be deleted via API requests.

See Also [#see-also]

* [Document Resources Overview](/configuration/resources/documents)
* [Document Selection Plugin](/configuration/plugins/document-selection)
* [Document Data Snapshot Plugin](/configuration/plugins/document-data-snapshot)
* [Documents API](/api/documents)
* [Document Resources API](/api/resources/document-resources)
