Environments
- Use different keys for local development, staging and production.
- Point production at https://wellfriend.dev and reject any other address in production configuration.
- Give each key only the scopes that deployment uses.
- Name keys after their service and environment, never after a secret.
Timeouts and retries
- Set a connect and request timeout on every API call.
- Retry only retryable errors, 429 responses and dropped connections.
- Wait for Retry-After and use exponential backoff with jitter.
- Reuse an idempotency key only to retry the identical request.
- Stop at a final operation state; never poll without a deadline.
Storage and monitoring
- Store your own ID with the Wellfriend document, version and operation IDs, the idempotency key, the state and timestamps.
- Measure request latency separately from the time an operation takes to finish.
- Alert on failed operations, webhook delivery backlogs, unusual request-unit use and repeated authorization failures.
- Log error codes and referenceIds, never API keys or document content.
Test cases
| Test | Expected result | What it proves |
|---|---|---|
| A valid file | An output that passes your own checks | The normal path works |
| Wrong file type | A non-retryable validation error | Bad input is rejected early |
| Oversized file | A rejection before processing | Plan and application limits hold |
| Revoked key or missing scope | 401 or 403 | Keys are limited correctly |
| Duplicate create | The same result for the same idempotency key | Retries are safe |
| Receiver outage | Webhook retries without duplicate effects | Recovery works |
Rollout and rollback
- Start with a small share of traffic or one internal workspace.
- Compare output checks, latency, request units and error codes with your test results.
- Keep the previous key and release until the new one is healthy.
- Roll back application traffic first; revoke a key only when that will not break the rollback.
Running the integration
Treat the integration as part of your application, with someone responsible for it. Your server decides which of your users may start an operation, stores the Wellfriend IDs with its own records, and shows each user only what they may see. API keys, error details and document content stay out of browser code and ordinary logs.
Decide timeouts, retries, cancellation, retention and support handling for each feature before launch. A successful response proves only what that endpoint documents: accepted work still has to finish, a finished output still has to be checked, and a link or viewer session can later expire or be revoked. Keep each request's idempotency key and referenceId so it can be investigated later without the document itself.
- Check your user's access to every document and resource before you call Wellfriend on their behalf.
- Create and store an idempotency key before each create or update call; reuse it only for the same request.
- Store IDs, states, timestamps and error codes in your database, not in process memory.
- Set connect, request and overall deadlines; when your own workflow is cancelled, stop any follow-up work.
- Redact API keys, webhook secrets, recipient codes, document content and private download URLs from logs, traces, analytics and screenshots.
Failure and recovery
Decide what kind of failure you have before you retry. A dropped connection, a timeout, a 429 or a retryable error can be retried within your budget. Validation, authentication, permission and unsupported-input errors need a change to the request, key or plan first. If the connection drops after you sent a create call, you do not know whether it succeeded: retry the identical request with the same idempotency key rather than creating a new one.
| What you see | What to do | What to record |
|---|---|---|
| No response or a client timeout | Read the current state, or repeat the identical request with the same idempotency key within your retry budget. | Idempotency key, elapsed time and the last known resource ID |
| 429 or a retryable error | Wait for Retry-After when present, add jitter, and stop at your deadline. | HTTP status, error code, referenceId, attempt number and next retry time |
| Validation or permission error | Do not retry unchanged. Fix the field, scope, permission or state named in the error. | Error code, the field details and your own record ID |
| Accepted asynchronous work | Store the returned ID and follow it until a final state or a verified webhook arrives. | Resource ID, state changes, timings and event IDs |
| Final failure or cancellation | Keep the record, decide whether to start a new operation, and use a new idempotency key only for that new request. | Error code, referenceId, your decision and the new request's ID |
Testing before launch
Test with a test key, using the same client, credential storage, database and webhook receiver that production will use. Cover small, large, malformed, unauthorized, expired, revoked, duplicated and interrupted cases that apply to your features. A mocked response or a successful build does not prove the integration works.
- Confirm each key has only the environment and scopes it needs, and that a call outside them is refused.
- Send one deliberate duplicate and one retry after a dropped connection; confirm nothing is created or charged twice.
- Check every state your UI handles, including empty results and every final state.
- Check logs and traces for API keys, document content, personal data or private download URLs.
- Measure latency, payload size, rate-limit behaviour and webhook delay against your own targets.
- Write down how to roll back, revoke a key, replay a webhook and escalate to Support, and alert on stuck or repeatedly failing work.