Polling Interval
A poll interval of 1 second works well for most operations. Cobalt typically processes operations within a few seconds to a couple of minutes depending on the EHR system. If you want to reduce API calls, you can increase the interval to 2-3 seconds with minimal impact on perceived latency.Timeout
Set a timeout based on the operation type:
Processing times vary by EHR system. If you experience frequent timeouts, increase the timeout rather than reducing the poll interval.
Request Expiration
Pass an optionalexpires_at with any asynchronous EHR create, update, delete, action, or live-fetch request. This also includes on-demand forms and org-settings refreshes. Use an ISO 8601 timestamp with an explicit timezone offset, in the future when you submit the request:
reasons[].code: "EXPIRED"; live-fetch completion events retain success: false. Forms and org-settings use their existing .synced event with status: "failed" and success: false. Omitting the field, or sending JSON null, keeps the existing retry behavior.
This is not cancellation. An attempt already in progress, including checking whether an uncertain write succeeded, may finish after the deadline. A late success still means the write succeeded. Continue tracking the original result; do not submit a replacement write merely because your local wait timed out. Set the deadline before your local timeout if you want time to receive the terminal outcome.
Send the field in the JSON body, including for DELETE /v1/appointments/{appointment_id}/codes. For multipart document uploads, send an expires_at form field. Synchronous cache edits and scheduled background syncs do not acquire a deadline. Editing a patient whose create is still pending does not start a new EHR operation and cannot replace that create’s deadline; such an edit rejects a supplied deadline.
Handle Timeouts Gracefully
A timeout does not mean the operation failed. It means the result wasn’t available within your wait window. The operation may still complete successfully in the background. If a timeout occurs:- Log the
job_idso you can look it up later. - Check back later by calling
GET /v1/webhook-events?job_id={job_id}at any point in the future. - Don’t retry the original operation unless you’ve confirmed it failed. Creating a duplicate appointment or patient is worse than waiting a bit longer.
When to Use Webhooks Instead
Polling works well for low-volume, on-demand operations. For high-volume or background processing, webhooks are more efficient:- Use polling when a user is waiting for an immediate result (e.g., a “Schedule Appointment” button in your UI).
- Use webhooks when processing records in bulk or when operations happen in the background without a user waiting.
- Use both for the best of both worlds: webhooks for production event processing, polling for ad-hoc operations and debugging.
You do not need to register a webhook URL to use the polling approach. Cobalt tracks all operation results internally regardless of whether you have webhooks configured.
Supported Operations
Any Cobalt API operation that returns ajob_id in its response supports this polling pattern. This includes:
- Appointments - Create and update
- Patients - Create
- Notes - Create
- Documents - Upload
- Tasks - Create
- Messages - Create
- Insurance - Add to patient
- Referring Providers - Create
- Telephone Encounters - Create