On this page

Resource $resend

The $resend operation manually triggers subscription notifications for a specific resource. This is invaluable for debugging subscription workflows, recovering from failed notifications, and replaying events during development or after system issues.

When a subscription notification fails or you need to reprocess a resource through your subscription pipeline, $resend lets you re-trigger the workflow without modifying the underlying resource—ensuring your integrations stay synchronized.

Use Cases​

  • Failed Notification Recovery: Retry subscription notifications that failed due to temporary network issues or downstream service outages
  • Debugging Subscriptions: Test subscription logic during development by manually triggering notifications
  • Data Synchronization: Force re-sync of specific resources to external systems after fixing integration issues
  • Selective Replay: Re-trigger a specific subscription for a resource instead of all subscriptions
  • Integration Testing: Verify that subscriptions fire correctly without creating new test data
Admin Required

The User, Bot, or ClientApplication invoking this operation must have project admin credentials.

Parameters​

The operation takes an optional request body, which is an object containing the following fields:

OptionDescriptionData TypeDefault Value
verboseIndicates if verbose logging should be enabled.booleanfalse
interactionSubscriptions can be configured to trigger only when a resource is created or deleted as opposed to any update. This option allows you to specify which interaction type will be sent. For delete, the resource must currently be deleted, and the last version before the delete is sent.update | create | deleteupdate
subscriptionA specific Subscription to trigger, formatted as Subscription/<id>. If left undefined, all Subscriptions will be triggered.stringundefined

By default, $resend sends the current version of the resource. With the update interaction, the resource must not have changed since the version being resent, and the previous version in the resource history is used when evaluating subscription criteria.

Invoke the $resend operation​

const medplum = new MedplumClient();
// auth...
await medplum.post(medplum.fhirUrl(<resourceType>, <id>, '$resend'), {
  verbose: true,
  interaction: 'update',
  subscription: 'Subscription/123'
});
medplum login
medplum post '<resourceType>/<id>/$resend' {"verbose":"true","interaction":"update","subscription":"Subscription/123"}
curl 'https://api.medplum.com/fhir/R4/<resourceType>/<resourceId>/$resend' \
-X 'POST' \
-H 'authorization: Bearer MY_ACCESS_TOKEN' \
-H 'content-type: application/fhir+json' \
--data-raw '{"verbose":"true","interaction":"update","subscription":"Subscription/123"}'

Resend a specific version​

To replay the original event for a historical version of a resource, for example after a webhook endpoint outage, invoke $resend on the version URL:

POST /fhir/R4/<resourceType>/<id>/_history/<versionId>/$resend

The subscription criteria are evaluated against that version, and that version is delivered, even if the resource has changed since. The version before it in the resource history is used as the previous version (%previous), so the same subscriptions match as for the original event.

  • Create: pass "interaction": "create" to replay the event for the version that was created.
  • Update: pass "interaction": "update" (the default).
  • Delete: pass "interaction": "delete". The resource must currently be deleted. The server sends the last version before the delete, so the version can be omitted by using the instance URL (/<resourceType>/<id>/$resend). If a version is specified, it must be the last version before the delete.
await medplum.post(medplum.fhirUrl(<resourceType>, <id>, '_history', <versionId>, '$resend'), {
  interaction: 'update',
  subscription: 'Subscription/123'
});
curl 'https://api.medplum.com/fhir/R4/<resourceType>/<resourceId>/_history/<versionId>/$resend' \
-X 'POST' \
-H 'authorization: Bearer MY_ACCESS_TOKEN' \
-H 'content-type: application/fhir+json' \
--data-raw '{"interaction":"update","subscription":"Subscription/123"}'
Limitations
  • A historical version is delivered with a single attempt. Retries are skipped once the resource has changed since that version, so check the subscription's AuditEvents after a replay and resend again if needed.
  • A create or update replay is not delivered if the resource has been deleted since.

Output​

If successful, you will receive the following OperationOutcome

{
  "resourceType": "OperationOutcome",
  "id": "ok",
  "issue": [
    {
      "severity": "information",
      "code": "informational",
      "details": {
        "text": "All OK"
      }
    }
  ]
}