> ## Documentation Index
> Fetch the complete documentation index at: https://help.elationhealth.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Partner Integrations Implementation Guide

> Enable Elation practices to connect to your service in a few clicks, from inside Elation, with no support ticket or manual credential exchange.

> [!WARNING]
>
> Partner Integrations is currently in early access and is only available to a select number of partners.

This guide is for **Elation Integration Partners**: third-party companies in Elation's partner program that build a product many Elation practices connect to. It is not for Elation customers. If you are a practice building your own integration, see [Core Developer](https://help.elationhealth.com/core-developer.md) instead.

If you would like to enquire about joining our partner program, submit the [partnership request form](https://www.elationhealth.com/contact-us/developer-sandbox-partnership/) and choose **I'm a prospective Integration Partner and want to join Partner Hub**, or email [partnerships@elationhealth.com](mailto:partnerships@elationhealth.com). To see the partners already in the program, visit the [Elation Partner Hub](https://partners.elationhealth.com/).

This guide covers how partners let a practice connect to their product from inside Elation, without a support ticket. You build three HTTP endpoints. Elation drives the rest.

At the end of a successful connection, your server holds an Elation API `client_id` and `client_secret` scoped to one practice. Elation delivers them to you in a server-to-server call that you authenticate.

> [!WARNING]
>
> **Current limitations.** Elation retries credential delivery only briefly, while the practice admin waits on the redirect ([Retries](#retries)). Elation does not notify you when a practice disconnects ([After connection](#6-after-connection)). Work on both is under way. Until it ships, build your callback to be fast and reliable, and treat Elation API authentication failures as a disconnect.

## 1. How the connection works

There are three parties: the practice admin's browser, Elation, and you.

```mermaid theme={null}
sequenceDiagram
    autonumber
    participant B as Practice admin (browser)
    participant E as Elation
    participant P as Partner (you)

    B->>E: Click "Connect" on your card
    E-->>B: Navigate to your authorize URL<br>(response_type, client_id, redirect_uri, state, practice_id, practice_name)
    B->>P: GET authorize URL
    P-->>B: Sign in (if needed) and consent page
    B->>P: Approve
    P-->>B: 302/303 to redirect_uri?code=...&state=...
    B->>E: GET redirect_uri?code=...&state=...
    E->>P: POST token URL (Basic auth, authorization_code)
    P-->>E: 200 {"access_token": "..."}
    Note over E: Elation mints an API credential<br>scoped to the practice
    E->>P: POST credential callback URL<br>Authorization: Bearer access_token<br>{practice_id, request_id, client_id, client_secret, scopes, ...}
    P-->>E: 2xx
    E-->>B: Redirect to Elation status page (ACTIVE)
```

Steps 2 to 9 are a standard OAuth 2.0 authorization code grant ([RFC 6749 §4.1](https://www.rfc-editor.org/rfc/rfc6749#section-4.1)), with **Elation as the client and you as the authorization server**. The access token you issue has exactly one job: it proves to your credential callback that the delivery belongs to the account that consented. Elation does not call any other API of yours with it.

Steps 10 to 12 are specific to Elation. Everything from step 8 onwards happens inside the single browser request in step 7, so the admin is waiting on your token and callback endpoints.

## 2. Onboarding: what you exchange with Elation

| You give Elation | Notes |
| - | - |
| Authorize URL | Browser-facing. May already contain a query string; Elation appends with `&`. |
| Token URL | Server-to-server. |
| Credential callback URL | Server-to-server. |
| `client_id` you issue to Elation | Must not contain `:`. |
| `client_secret` you issue to Elation | Use only `A-Z a-z 0-9 - . _ ~`. See [Client secret encoding](#4-2-client-secret-encoding). Share it through a secure channel. |
| Display name, short description, logo URL | Shown to practice admins on your card. The logo must be a public `https` URL. |

| Elation gives you | Notes |
| - | - |
| `redirect_uri` | Exact string, e.g. `https://<elation-host>/oauth/callback`. Register it and compare it exactly. |
| Scopes | The API access the delivered credential carries. Elation decides these. They are disclosed to the practice admin before they click **Connect**, and echoed to you in the delivery body. |
| `partner_id` | Identifies your card in Elation. Used for [deep links](#appendix-a-linking-a-practice-to-your-card). |

All three of your URLs must be absolute `https` URLs on a hostname (no IP literals, no `localhost`), served with a certificate from a publicly trusted CA. Register the final URL: Elation does **not** follow redirects on server-to-server calls, so a `301` that adds a trailing slash fails the connection.

## 3. Endpoint 1: Authorization (browser)

`GET {authorize_url}`

### Request

Elation sends the admin's browser here with these query parameters, all percent-encoded:

| Parameter | Value |
| - | - |
| `response_type` | Always `code`. |
| `client_id` | The client id you issued to Elation. |
| `redirect_uri` | The exact URI you registered for Elation. |
| `state` | Opaque string, roughly 300 to 500 characters. |
| `practice_id` | The Elation practice that is connecting. |
| `practice_name` | The practice's display name. |

`practice_id` and `practice_name` let your consent page show which Elation practice is being connected, and let you turn away a connection you will not accept (for example, a practice already linked to a different account) with `error=access_denied` before any credential exists. They are informational: they are not signed, so do not use them to decide which of your accounts receives the credential. The access token does that ([Endpoint 3](#5-endpoint-3-credential-callback)).

Elation does **not** send `scope`, `code_challenge` (PKCE), `nonce`, or `prompt`. Do not require them. The access being granted is fixed at onboarding.

### What you must do

1. Reject an unknown `client_id` and any `redirect_uri` that is not an exact match for the one registered to that client. Show an error page; do **not** redirect to an unregistered URI.
2. Reject a `response_type` other than `code` (redirect with `error=unsupported_response_type` once the redirect URI is validated).
3. Sign the user in if needed. Preserve every original query parameter across your login flow, including `state` byte-for-byte.
4. Show a consent page naming Elation and the practice-data access.
5. On approval, issue an authorization code and redirect the browser.

### Response: approved

```http theme={null}
HTTP/1.1 302 Found
Location: {redirect_uri}?code={code}&state={state}
```

* Put `code` and `state` in the **query string**. Not the fragment, and not `response_mode=form_post`.
* Return `state` exactly as received. Elation verifies its signature; one changed character fails the connection.
* If your consent page submits a `POST` form, redirect with **`302` or `303`**. A `307` or `308` makes the browser re-`POST` to Elation's callback, which only accepts `GET`.
* Percent-encode both values.

### Response: denied or failed

```http theme={null}
HTTP/1.1 302 Found
Location: {redirect_uri}?error=access_denied&state={state}
```

Always include `state` so Elation can attribute the outcome to the right attempt. Elation records only these `error` values verbatim and maps anything else to `unknown_error`: `invalid_request`, `unauthorized_client`, `access_denied`, `unsupported_response_type`, `invalid_scope`, `server_error`, `temporarily_unavailable`. `error_description` is ignored.

### Timing

The `state` value expires **10 minutes** after the admin clicks **Connect**. If they take longer at your consent page, Elation rejects the redirect and they start over from Elation.

## 4. Endpoint 2: Token

`POST {token_url}`

### Request

```http theme={null}
POST /oauth/token HTTP/1.1
Authorization: Basic base64({client_id}:{client_secret})
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code={code}&redirect_uri={redirect_uri}
```

Elation authenticates with HTTP Basic (`client_secret_basic`). The client id and secret are never in the body.

### 4.1 What you must validate

1. The Basic credentials match the client. Otherwise `401` with `{"error": "invalid_client"}`.
2. `grant_type` is `authorization_code`. Otherwise `400` with `{"error": "unsupported_grant_type"}`.
3. `code` exists, was issued to this client, has not expired, and has not been used. Otherwise `400` with `{"error": "invalid_grant"}`.
4. `redirect_uri` equals the one the code was issued for. Otherwise `400` with `{"error": "invalid_grant"}`.
5. Mark the code used **atomically** before responding.

Authorization codes should be single-use and short-lived. Elation redeems the code within a second or two of the redirect, so a 60-second lifetime is ample.

### 4.2 Client secret encoding

As [RFC 6749 §2.3.1](https://www.rfc-editor.org/rfc/rfc6749#section-2.3.1) requires, Elation form-urlencodes the client id and secret before base64-encoding `client_id:client_secret`. URL-decode each half after splitting on the first `:`. If your server compares the raw decoded values, a secret containing `+`, `%`, `/` or other reserved characters will not match. Issue a secret made only of unreserved characters (`A-Z a-z 0-9 - . _ ~`) and the two encodings are identical, so either server behavior works.

### Response

```http theme={null}
HTTP/1.1 200 OK
Content-Type: application/json

{"access_token": "...", "token_type": "Bearer", "expires_in": 600}
```

* The status must be exactly **`200`**. A `201` fails the connection.
* `access_token` must be a non-empty string. Every other field is ignored, including `refresh_token`.
* The token must remain valid for at least **5 minutes**. Between issuing it and presenting it at your callback, Elation mints the credential, which can take over a minute in the worst case.
* Bind the token to the partner-side account that consented. Your credential callback uses it to decide where the credential belongs.
* Respond within **10 seconds**, including connection setup.

## 5. Endpoint 3: Credential callback

`POST {credential_callback_url}`

### Request

```http theme={null}
POST /api/elation/credentials HTTP/1.1
Authorization: Bearer {access_token}
Content-Type: application/json

{
  "practice_id": 140754680234010,
  "practice_name": "Example Family Medicine",
  "request_id": "0f5e3c2a9b7d4e1f8a6c5b4d3e2f1a0b",
  "client_id": "...",
  "client_secret": "...",
  "scopes": ["system/patients.read"],
  "environment": "production",
  "api_base_url": "https://<elation-api-host>/api/2.0",
  "linked_at": "2026-11-12T17:04:31.512000+00:00"
}
```

| Field | Type | Meaning |
| - | - | - |
| `practice_id` | integer (store as 64-bit) | The Elation practice that connected. |
| `practice_name` | string or null | The practice's display name, as sent on the authorize request. |
| `request_id` | string | Identifies this connection attempt. |
| `client_id`, `client_secret` | string | The Elation API credential. Treat the secret like a password. |
| `scopes` | array of strings | The access the credential carries. |
| `environment` | string | The Elation environment the credential was minted in, e.g. `production` or `sandbox`. |
| `api_base_url` | string | Absolute `https` URL of the Elation API the credential is valid against. |
| `linked_at` | string (ISO 8601, UTC) | When Elation minted the credential. |

A `practice_id` is only meaningful within its `environment`. If you integrate with more than one Elation environment, key stored credentials by `(environment, practice_id)`.

Elation may add fields. Ignore ones you do not recognize.

### What you must do

1. Authenticate the bearer token: it must be one you issued from the token endpoint and unexpired. Otherwise `401`. Elation may present the same token more than once for the same `request_id` (see [Retries](#retries)), so do not consume it on a failed delivery, and answer `2xx` to a repeat of a delivery you already stored.
2. Attach the credential to the account the **token** belongs to. Do not use `practice_id` to find the account: it is informational, and the token is what proves the delivery is for that user.
3. Store `client_secret` encrypted. Never log it, and never echo it in a response body.
4. If the account already holds a credential for the same `environment` and `practice_id`, replace it. A practice that disconnects and reconnects gets a new credential; the old one has been revoked.
5. Respond `2xx` within **10 seconds**. The body is ignored. Do any slow follow-up work (first sync, emails) after responding.

### Retries

Elation makes up to **three** delivery attempts, a second or two apart, while the practice admin waits on the redirect. It retries only when your endpoint is unreachable, takes longer than 10 seconds, or answers `408`, `425`, `429`, `500`, `502`, `503` or `504`. Elation sets the retry timing and ignores `Retry-After`. Every attempt carries the same `request_id`, credential and bearer token. Treat `request_id` as an idempotency key: if you already stored that delivery, answer `2xx` again.

Any other status, a redirect, or a third failure is final. Elation records the connection as failed, and Elation Support has to clean up the credential before the practice can try again. Your callback is the reliability-critical endpoint in this integration.

If your handler stores the credential after Elation has stopped waiting on the last attempt, you hold a credential that Elation has already recorded as failed. Elation Support revokes it during cleanup, and the practice sees the connection as failed. Store the credential and respond first; do everything else afterwards.

## 6. After connection

* **Using the credential.** The `client_id` and `client_secret` are Elation API client credentials for the API at `api_base_url`. Exchange them for an access token with the client credentials grant; no username or password is needed. See [Authentication](https://help.elationhealth.com/articles/rest/overview/oauth.md) and [Get Token](https://help.elationhealth.com/articles/rest/overview/get-token.md).
* **Disconnects.** A practice admin or Elation Support can disconnect at any time. Elation revokes the credential. **You are not notified.** Treat an authentication failure from the Elation API as a disconnect and stop syncing for that practice.
* **Reconnects.** After a disconnect or a declined attempt, the admin can connect again. You receive a new delivery with a new `request_id` and a new credential.
* **One connection per practice.** Elation allows a single active connection between a practice and your product. While a connection is active, or a failed delivery is waiting on Elation Support, Elation refuses a new **Connect** and the existing credential is untouched.

## 7. What Elation records for each outcome

Practice admins see these on Elation's status page. Use the table to reason about what your endpoints' behavior does to the practice.

| Your behavior | Elation status | Practice can retry? |
| - | - | - |
| Callback returns `2xx` | `ACTIVE` | n/a |
| Redirect with `error=...` and `state` | `DECLINED` | Yes |
| Redirect without `code` or `error` | `DECLINED` | Yes |
| Token endpoint non-`200`, slow, unreachable, or missing `access_token` | `DECLINED` | Yes |
| Callback non-`2xx`, slow, unreachable, or redirects (after any [retries](#retries)) | `DELIVERY_FAILED` | Only after Elation Support reconciles |
| `state` missing, altered, or older than 10 minutes | Raw `400` response in the browser, no status page; attempt stays pending | Yes, from Elation |
| Callback stores the credential but answers after 10 seconds on the last attempt | `DELIVERY_FAILED`; you hold a credential Elation Support will revoke | Only after Elation Support reconciles |

`DECLINED` means no credential was created. `DELIVERY_FAILED` means a credential may exist that nobody holds, which is why it needs a person to resolve it.

### Testing your integration

While you build against a sandbox practice, ask Elation to turn on debug mode for it. With debug mode on, the practice admin:

* Can **Disconnect** from `DELIVERY_FAILED`, and from an attempt stuck connecting, not only from `ACTIVE`, once Elation has recorded the attempt's credential. Elation revokes that credential, so you can reconnect without waiting for Elation Support. An attempt that failed before a credential was recorded still needs Elation Support.
* Sees the recorded failure reason on the integration card: a short description and a status code, never your response body.

> [!NOTE]
>
> Only disconnect a stuck attempt after its callback has finished or timed out. If your callback is still running, it can still mark the connection `ACTIVE`, leaving you holding a credential that has already been revoked.

## 8. Checklist

* Exact-match `client_id` and `redirect_uri` on the authorize request.
* Do not require `scope` or PKCE.
* Preserve `state` byte-for-byte through login and consent.
* Redirect with `302` or `303`, with `code` and `state` in the query string.
* Include `state` on error redirects, and use standard `error` codes.
* Token endpoint: Basic auth, single-use codes, `redirect_uri` match, `200` JSON with `access_token`.
* The client secret uses only unreserved characters.
* The access token is valid for at least 5 minutes and bound to the consenting account.
* Callback: authenticate the bearer token, bind by token not `practice_id`, store the secret encrypted, never log or echo it.
* Callback replaces an existing credential for the same `environment` and practice.
* Callback treats a repeated `request_id` as already stored and answers `2xx`; a failed delivery does not consume the bearer token.
* Every endpoint answers within 10 seconds, with no redirects on server-to-server URLs.
* Treat Elation API authentication failures as a disconnect.

## Appendix A: Linking a practice to your card

To send a practice admin straight to your integration, for example from your own onboarding flow or an email, link to Elation's partner integrations settings page with your `partner_id` as `vendor_id`:

```text theme={null}
https://<elation-host>/settings/partner-integrations/?vendor_id={partner_id}
```

The page opens scrolled to your card, where the admin clicks **Connect**. Your `partner_id` is the identifier Elation assigns at onboarding; ask Elation if you do not have it. It is case-sensitive.

* The link only scrolls. It does not start a connection: the admin still clicks **Connect** and confirms the access shown in the Connect dialog.
* If the practice cannot see your card, for example because your integration is not yet available to it, the page opens at the top with no error.

## Change history

| Version | Date | Changes |
| - | - | - |
| 1.0 | 2026-10-09 | Initial version. |
| 1.1 | 2026-11-12 | Elation now sends `practice_id` and `practice_name` on the authorize request. Credential delivery is retried on transient failures ([Retries](#retries)). Added deep links to your card in practice settings ([Appendix A](#appendix-a-linking-a-practice-to-your-card)). |

## Related Articles

* [Authentication](https://help.elationhealth.com/articles/rest/overview/oauth.md)
* [Get Token](https://help.elationhealth.com/articles/rest/overview/get-token.md)
* [Token Scopes](https://help.elationhealth.com/articles/rest/overview/scopes.md)
* [REST API introduction](https://help.elationhealth.com/articles/rest/overview/introduction.md)
