GUIDES

Integration Guides

Step-by-step tutorials for connecting EHR systems, syncing billing data, automating compliance, and embedding ORIS.

Common Patterns

Patterns used across all integrations — authentication, error handling, pagination, and webhook processing.

Authentication Flow

All API requests require a bearer token. Obtain tokens via the OAuth2 client credentials flow.

bash
1# 1. Exchange client credentials for access token
2curl -X POST https://auth.rymeda.com/oauth2/token \
3 -H "Content-Type: application/x-www-form-urlencoded" \
4 -d "grant_type=client_credentials" \
5 -d "client_id=YOUR_CLIENT_ID" \
6 -d "client_secret=YOUR_CLIENT_SECRET" \
7 -d "scope=care:read care:write revenue:read"
8
9# Response:
10# {
11# "access_token": "eyJhbGci...",
12# "token_type": "Bearer",
13# "expires_in": 3600,
14# "scope": "care:read care:write revenue:read"
15# }
16
17# 2. Use the token in subsequent requests
18curl https://api.rymeda.com/v1/care/sessions \
19 -H "Authorization: Bearer eyJhbGci..."

Error Handling

All errors follow a consistent shape. Always check the error object for machine-readable codes.

javascript
1try {
2 const session = await rymeda.care.sessions.create({
3 clientId: 'client_123',
4 serviceType: 'behavioral_health',
5 })
6} catch (err) {
7 if (err.status === 422) {
8 // Validation error — check field-level details
9 console.error('Validation failed:', err.error.details)
10 } else if (err.status === 429) {
11 // Rate limited — retry after delay
12 const retryAfter = err.headers['retry-after']
13 await sleep(retryAfter * 1000)
14 } else {
15 // Unexpected error — log request ID for support
16 console.error('Request failed:', err.error.requestId)
17 }
18}

Pagination

All list endpoints use cursor-based pagination. Use the cursor from the response to fetch the next page.

javascript
1async function fetchAllClaims() {
2 const allClaims = []
3 let cursor = undefined
4
5 do {
6 const response = await rymeda.revenue.claims.list({
7 status: 'submitted',
8 limit: 100,
9 cursor,
10 })
11
12 allClaims.push(...response.data)
13 cursor = response.pagination.hasMore
14 ? response.pagination.cursor
15 : undefined
16 } while (cursor)
17
18 return allClaims
19}

Webhook Processing

Verify webhook signatures before processing. Rymeda signs every payload with your webhook secret.

javascript
1import crypto from 'crypto'
2
3function verifyWebhookSignature(payload, signature, secret) {
4 const expected = crypto
5 .createHmac('sha256', secret)
6 .update(payload)
7 .digest('hex')
8
9 return crypto.timingSafeEqual(
10 Buffer.from(signature),
11 Buffer.from(expected),
12 )
13}
14
15// Express.js example
16app.post('/webhooks/rymeda', (req, res) => {
17 const signature = req.headers['x-rymeda-signature']
18 const isValid = verifyWebhookSignature(
19 JSON.stringify(req.body),
20 signature,
21 process.env.RYMEDA_WEBHOOK_SECRET,
22 )
23
24 if (!isValid) return res.status(401).send('Invalid signature')
25
26 // Process the event
27 const { event, data } = req.body
28 console.log('Received event:', event, data)
29 res.status(200).send('OK')
30})

Need more help?

Our engineering team is available to help with custom integrations and architecture reviews.