Skip to main content

Overview

All Parchment Health API endpoints follow a consistent response structure to ensure predictability and ease of integration. Our responses comply with industry standards including RFC 7807 for error handling.

Response Structure

Success Response Format

All successful API responses follow this structure:

Error Response Format (RFC 7807)

All error responses follow the RFC 7807 Problem Details standard:

HTTP Status Codes

Success Codes

Error Codes

Response Fields

Core Fields

Optional Fields

Pagination Object Fields

Error Object Fields

Error Types

Standard Error Types

Response Examples

Create Patient Success (201)

Get Patient Success (200)

List Patients Success (200)

Validation Error (422)

Unauthorized Error (401)

Partner Patient ID Conflict (409)

Patient Not Found (404)

Internal Server Error (500)

Request Tracing

Every response includes a unique requestId that can be used for:
  • Debugging: Reference this ID when reporting issues
  • Logging: Correlate requests across different systems
  • Monitoring: Track request flow through the system
Example: req_1705312200000_abc123

API Versioning

The API version information is tracked internally for compatibility purposes, allowing for:
  • Backward Compatibility: Maintain support for older integrations
  • Feature Detection: Identify available features based on version
  • Migration Planning: Plan upgrades to newer API versions

Pagination Usage

When working with paginated endpoints, use the lastKey field to navigate through pages:

Making Paginated Requests

Pagination Best Practices

  1. Always check hasNext before requesting the next page
  2. Use lastKey for cursor-based pagination when available
  3. Fall back to offset for offset-based pagination when needed
  4. URL encode lastKey values when using as query parameters
  5. Handle null lastKey as indication of no more pages

Best Practices

Error Handling

  1. Always check the success field to determine if the request succeeded
  2. Use statusCode for programmatic handling of different scenarios
  3. Display error.detail to users for human-readable error messages
  4. Log requestId for debugging and support requests
  5. Handle validation errors by checking the error.validation array

Integration Tips

  1. Store requestId in your logs for easier debugging
  2. Implement retry logic for 5xx errors with exponential backoff
  3. Cache successful responses when appropriate to reduce API calls
  4. Monitor response times for performance tracking
  5. Validate API version compatibility when integrating

Migration Guide

From Legacy Responses

If you’re migrating from the legacy response format:
  1. Update success checks: Use response.success instead of checking statusCode < 400
  2. Extract data: Access response data from response.data instead of the root
  3. Handle errors: Use response.error object instead of response.message
  4. Add request tracing: Store response.requestId for debugging

TypeScript Support