After the async export completes, parse the JSON response body; extract the output array (successfully exported files) and the error array (files containing OperationOutcome resources for failed resources)
For each entry in output[], record the type (resource type) and url; download each file via GET with Authorization: Bearer {token}; stream large files to avoid memory exhaustion
For each line in each downloaded NDJSON file, parse the JSON object and validate it is the expected resourceType before processing
For each entry in error[], download the error NDJSON file and parse each OperationOutcome to identify which resources failed export and why; log for remediation
Verify total resource counts in the manifest (if provided by the server) against the count of NDJSON lines downloaded to detect truncated files or download failures
Known gotchas
NDJSON files may not have a .ndjson extension and content-type headers may vary; rely on the manifest output[].type field to determine resource type rather than file extension or content-type
Error files contain OperationOutcome resources, not the failed FHIR resources themselves; you cannot recover the content of failed resources from the error file alone
Bulk Data output file URLs may require the same Bearer token used for the export kick-off; attempting to download files without a valid token (or with an expired token from a long-running export) results in 401 errors
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp