Scenario: Delete, Purge Deleted, and Hard Delete

How to use logical delete, collection-level purge of deleted resources, and instance-level hard delete operations.

Before you begin

DDFS does not support SMART on FHIR authorization or launch workflows. Use an OAuth 2.0 access token issued by OCI Identity Domains with the DDFS resource scopes required for the request. Configure the client and token by following Create an Integrated Application and DDFS Authentication Reference.

  • For a standard delete, use an access token with matching delete authority for the target FHIR resource.
  • For $hardDelete or $purgeDeleted, use an access token with both matching delete authority and the custom hard-delete scope. See Configure Custom Hard-Delete Authorization.

Overview

This API supports three different operations to delete FHIR resources:

  • Standard Delete (instance): Logically deletes a specific resource instance.
  • Purge Deleted (collection): Permanently removes previously deleted resources in a collection.
  • Hard Delete (instance): Permanently removes a specific deleted resource instance and returns an OperationOutcome describing the result.

Standard Delete (Instance)

Use standard delete when you need to logically delete a specific resource instance.

DELETE /api/fhir/{r4|r6-ballot4}/<Resource>/{rid}

R4 Endpoints

R6 Endpoints

Purge Deleted (Collection)

Use collection purge only if defined for the resource. This operation permanently removes resources already in a standard deleted state within the specific collection.

POST /api/fhir/{r4|r6-ballot4}/<Resource>/$purgeDeleted

Server-side behavior

Send before and optional limit in a FHIR Parameters request body:

POST /api/fhir/{r4|r6-ballot4}/<Resource>/$purgeDeleted
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    { "name": "before", "valueDateTime": "2026-01-01T00:00:00Z" },
    { "name": "limit", "valueInteger": 25 }
  ]
}
  • Requires elevated authorization.
  • Restricts purging to resources already in a deleted state.
  • Requires before as a FHIR dateTime cutoff; resources deleted before that instant are eligible for the purge.
  • Accepts an optional limit integer from 1 through 50.
  • Returns an OperationOutcome describing the result.

R4 Endpoints

R6 Endpoints

Hard Delete (Instance)

Use hard delete to permanently remove a specific deleted resource instance and return an OperationOutcome describing the result. This operation is modeled as POST /{rid}/$hardDelete for supported resources.

POST /api/fhir/{r4|r6-ballot4}/<Resource>/{rid}/$hardDelete

R4 Endpoints

R6 Endpoints

Request and response

  • Authentication and authorization are required. Ensure the user has privileges to perform an administrative delete.
  • Requests target either the resource collection endpoint ($purgeDeleted) or a specific resource instance {rid} with $hardDelete.
  • Responses return an OperationOutcome body describing the result.

For the complete list of endpoints, see FHIR Endpoints.

Status Codes

CodeMeaning
200The purge-deleted or hard-delete operation completed and returned an OperationOutcome.
204The standard delete request completed successfully and the response has no body.