NHS Service Discovery: Dynamically Resolving Healthcare Endpoints Using SDS and ODS

Written by Technical Team Last updated 27.11.2026 19 minute read

Home>Insights>NHS Service Discovery: Dynamically Resolving Healthcare Endpoints Using SDS and ODS

Integrating with multiple NHS clinical systems requires an application to establish not only which organisation holds a particular patient’s records, but also where the relevant service is hosted, which interfaces it supports and how connections to those interfaces should be established. In a distributed healthcare environment, these details cannot reliably be maintained through static configuration alone. GP practices change clinical system suppliers, organisations merge, service endpoints are migrated and messaging arrangements are reconfigured.

The Spine Directory Service (SDS) and Organisation Data Service (ODS) provide different parts of the information required to resolve these dependencies. ODS supplies organisational reference data, including organisation identifiers, operational status, relationships and organisational roles. SDS provides directory information associated with Spine-connected systems, including registered messaging endpoints and accredited systems.

A properly engineered service discovery layer combines these sources with integration-specific routing rules, patient registration information where required, and the security configuration necessary to establish a connection. The resulting architecture allows healthcare applications to resolve destinations dynamically without embedding supplier-specific endpoint addresses throughout the application code.

Neither directory should be treated as a universal registry of every NHS API or clinical system. Some services expose nationally managed endpoints, others use centrally mediated routing, and some require direct communication with an organisation-specific system. The discovery mechanism must reflect the particular integration specification rather than assuming that every service can be resolved through the same directory query.

Understanding the relationship between ODS, SDS and PDS

The ODS code is the organisational identifier around which much of NHS service discovery is structured. It identifies an organisation or organisational entity independently of the clinical systems installed within it. A GP practice can change its principal clinical system without necessarily changing its ODS code, while the technical identifiers and endpoint addresses associated with that practice may change substantially.

ODS maintains reference data covering GP practices, NHS trusts, pharmacies, independent healthcare providers, organisational sites and commissioning bodies, amongst other entities. An organisation record can contain primary and secondary roles, operational dates, addresses, organisational relationships and succession information.

For new integrations, the Organisation Data Terminology FHIR R4 API is the preferred interface for accessing this data. Existing applications may also use the Organisation Reference Data (ORD) API, which exposes organisation records through a bespoke REST schema. The older ODS FHIR STU3 API has been retired.

Within an integration platform, ODS data is particularly useful for validating destination organisations, maintaining local organisation directories and supporting workflows where healthcare professionals select the organisation with which they wish to interact.

Organisation selection should be driven by identifiers and role codes rather than names. Organisation names are subject to change, are not necessarily unique and may be represented differently across clinical systems. Similarly, an organisation’s primary role alone may not fully describe the services it provides.

SDS operates at a different level of abstraction. Its system-related records describe technical systems registered with Spine and the interfaces associated with those systems.

Two record types are particularly relevant to endpoint discovery:

  • Accredited System (AS) records: Identify registered systems through an Accredited System Identifier (ASID), together with information about their organisation and supported interactions.
  • Message Handling System (MHS) records: Contain messaging configuration associated with registered systems, including party keys, interaction identifiers and endpoint addresses.

The relationship between organisations and accredited systems is not necessarily one-to-one. A single NHS organisation can operate several accredited systems, each supporting different interfaces. A software supplier deploying the same product across several hundred GP practices may have separate accredited system registrations associated with those practices, despite operating a shared hosting infrastructure.

The ASID must therefore be treated as a system identifier rather than an organisation identifier. Storing an ASID directly against an ODS record without retaining the associated interaction and system context produces an insufficiently expressive data model.

The Personal Demographics Service (PDS) supplies another component of the discovery process where routing depends on a patient’s registered GP practice. In a GP Connect record access workflow, PDS is used to verify patient identity and establish the ODS code of the registered practice. SDS can subsequently resolve the technical destination for the requested interaction.

ODS cannot establish where an individual patient is registered, and SDS cannot establish whether a particular clinical system holds that patient’s record. Combining directory information with patient registration data is the responsibility of the consuming application.

There are also workflows where the destination organisation is not the patient’s registered practice. Appointment management integrations, for example, may need to interact with another practice or an extended access service. The target organisation must be established through the rules of the relevant workflow rather than universally derived from PDS.

Resolving healthcare endpoints through the SDS FHIR API

Historically, applications accessed SDS through Lightweight Directory Access Protocol (LDAP). The SDS directory contained objects and attributes that could be queried using organisation codes, system identifiers and supported interaction identifiers.

The SDS LDAP API is deprecated and unavailable to new integrations. Its modern replacement for system and endpoint discovery is the Spine Directory Service FHIR API, which represents messaging endpoints and accredited systems using FHIR R4 resources.

The relevant resources are Endpoint and Device. Although Device is commonly associated with physical medical devices in other FHIR implementations, within SDS it is used to represent accredited systems.

Consider an application that needs to retrieve a patient’s structured GP record using GP Connect. Once the destination practice has been established, the application has two inputs required for endpoint discovery: the practice’s ODS code and the Spine interaction identifier corresponding to the requested operation.

For GP Connect Access Record: Structured, the interaction identifier is:


urn:nhs:names:services:gpconnect:fhir:operation:gpc.getstructuredrecord-1

The interaction identifier describes the specific service interaction. It is not interchangeable with the FHIR operation name and should be maintained in a version-controlled integration configuration or capability registry.

The first SDS request searches for an Endpoint resource. Using an illustrative practice code of T99999, the decoded search parameters would be:

GET /spine-directory/FHIR/R4/Endpoint
    ?organization=https://fhir.nhs.uk/Id/ods-organization-code|T99999
    &identifier=https://fhir.nhs.uk/Id/nhsServiceInteractionId|urn:nhs:names:services:gpconnect:fhir:operation:gpc.getstructuredrecord-1

The request has been formatted across multiple lines for readability. In an implementation, the query parameters should be constructed and URL-encoded using the HTTP client’s parameter handling facilities. Manually concatenating FHIR token search parameters into URLs introduces avoidable encoding problems, particularly around pipe characters and reserved URI characters.

The production SDS FHIR API is hosted at https://api.service.nhs.uk/spine-directory/FHIR/R4. Authentication, application registration and environment-specific configuration must be implemented in accordance with the API’s access requirements.

The response is a FHIR search Bundle containing the matching endpoint resources. The application extracts the service root from Endpoint.address and obtains the party key from the identifier whose system is: https://fhir.nhs.uk/Id/nhsMhsPartyKey.

An illustrative endpoint resource, with unrelated fields omitted, might resemble:

{
  "resourceType": "Endpoint",
  "identifier": [
    {
      "system": "https://fhir.nhs.uk/Id/nhsMhsPartyKey",
      "value": "T99999-1234567"
    }
  ],
  "address": "https://provider.example.org/T99999/STU3/1/gpconnect/structured"
}

The party key associates the messaging configuration with the accredited system. It provides the connection between the endpoint lookup and the subsequent system lookup.

The application then searches the Device resource using the same ODS code, the interaction identifier and the party key returned by the first request.

GET /spine-directory/FHIR/R4/Device
    ?organization=https://fhir.nhs.uk/Id/ods-organization-code|T99999
    &identifier=https://fhir.nhs.uk/Id/nhsMhsPartyKey|T99999-1234567
    &identifier=https://fhir.nhs.uk/Id/nhsServiceInteractionId|urn:nhs:names:services:gpconnect:fhir:operation:gpc.getstructuredrecord-1

Both identifier parameters must be preserved when constructing the request. Some HTTP client libraries represent query parameters internally as dictionaries or maps, which can inadvertently overwrite repeated parameter names. Using a collection of key-value pairs or the library’s multi-value parameter support avoids silently removing one of the search constraints.

The provider’s ASID is extracted from the returned Device resource by finding the identifier with the system: https://fhir.nhs.uk/Id/nhsSpineASID.

Identifiers should always be selected by their system URI rather than their position in an array. FHIR identifier ordering carries no reliable semantic meaning, and additional identifiers may appear as the underlying directory representation evolves.

At the end of the discovery process, the application has the provider’s service root, party key and ASID, associated with the destination organisation and requested interaction.

A practice offering both structured record access and appointment management may have different registered service roots for those capabilities. Resolving an endpoint for one capability and reusing it for another is not a valid optimisation, even when both services are provided by the same clinical system supplier.

There is also a distinction between the FHIR version used for discovery and the FHIR version implemented by the discovered service. An R4 SDS response can identify a GP Connect endpoint implementing STU3. The discovery client must not infer the destination API’s resource schemas, media types or supported operations from the FHIR version of the directory itself.

Constructing requests through the Spine Secure Proxy

For GP Connect, discovering a provider’s endpoint does not mean that the consuming application should establish a direct HTTP connection to that endpoint. The request is routed through the Spine Secure Proxy (SSP), which mediates communication between consuming and providing systems.

The application constructs the request URL using the environment-specific SSP address, the discovered provider service root and the relative path of the required FHIR interaction.

For structured record retrieval, an illustrative request might take the following form:

POST https://ssp.example.org/https://provider.example.org/T99999/STU3/1/gpconnect/structured/Patient/$gpc.getstructuredrecord

The embedded provider URL is part of the proxy request path. It must retain the registered service root accurately. Seemingly harmless transformations, such as replacing a hostname with its resolved IP address or introducing an explicit default HTTPS port, can cause the proxy to reject the request because the supplied destination no longer matches its registered configuration.

Care is also needed when using standard URI resolution libraries. Resolving a relative path beginning with a forward slash can discard the existing path component of the service root. Middleware that automatically normalises repeated forward slashes can similarly damage the embedded https:// portion of an SSP request.

The SSP request requires several Spine-specific HTTP headers.

Ssp-From: 200000000001
Ssp-To: 200000000002
Ssp-InteractionID: urn:nhs:names:services:gpconnect:fhir:operation:gpc.getstructuredrecord-1
Ssp-TraceID: 550e8400-e29b-41d4-a716-446655440000

The identifiers above are illustrative. Ssp-From identifies the consuming accredited system, while Ssp-To identifies the provider resolved through SDS. The interaction header specifies the operation being requested, and the trace identifier provides a means of correlating the transaction across participating systems.

Other request headers, clinical context, authentication material and the FHIR request body must be supplied according to the specification of the particular GP Connect capability. The security arrangements for communication with the SSP are separate from those used to access the SDS FHIR API.

Resolving the consumer’s own ASID deserves particular attention in multi-tenant healthcare applications. A centrally hosted platform serving several NHS organisations cannot simply use the hosting organisation’s ASID for every outbound request. The consuming system identity must correspond to the organisation originating the clinical interaction.

Consumer ASIDs can be provisioned during organisation onboarding and maintained as controlled configuration. Alternatively, they can be discovered dynamically through an SDS Device search using the consuming organisation’s ODS code, the interaction identifier and the manufacturer’s organisation code.

The manufacturer’s ODS code is supplied through the manufacturing-organization search parameter. This helps distinguish systems supplied by different manufacturers within the same consuming organisation. If multiple candidate systems remain, further disambiguation or corrected provisioning is necessary.

A multi-tenant application should derive the originating organisation from its authenticated server-side session and organisational authorisation model. Accepting an arbitrary consumer ODS code or ASID from a browser request would allow the client to influence the identity under which the platform communicates with national infrastructure.

Service discovery establishes how a request should be routed; it does not establish that the request is authorised. The consuming application remains responsible for enforcing appropriate user permissions, clinical access controls and the applicable information-sharing arrangements before initiating the interaction.

Designing a reusable service discovery architecture

Applications supporting several NHS integrations benefit from separating discovery logic from clinical workflow implementation. Otherwise, individual components tend to accumulate their own SDS clients, ODS lookups, endpoint caches and error-handling behaviour, making changes to national interfaces unnecessarily expensive.

A service discovery component can expose an internal operation that accepts an originating organisation, destination organisation, requested interaction, deployment environment and clinical session context. Its output is a resolved route containing the technical information required by the downstream integration client.

A possible internal representation is:

interface ResolvedHealthcareRoute {
  environment: string;
  consumerOdsCode: string;
  consumerAsid: string;
  providerOdsCode: string;
  providerAsid: string;
  interactionId: string;
  partyKey: string;
  serviceRoot: string;
  resolvedAt: string;
}

This is an application-level data structure rather than an NHS-defined resource. Keeping it independent of the SDS response schema means the remainder of the application does not need to understand FHIR directory resources or legacy LDAP attributes.

The route should be constructed only after all required lookups have completed successfully. Storing endpoint addresses, party keys and provider ASIDs independently creates the possibility of assembling inconsistent combinations during a directory update or clinical system migration.

An internal integration registry can associate each supported operation with its interaction identifier, discovery strategy, authentication requirements, transport mechanism and expected API version. GP Connect operations would use an SDS-backed resolver, whereas nationally hosted NHS APIs could use environment-specific gateway configuration. Other messaging services may require their own address lookup mechanism.

This avoids introducing an architectural assumption that all NHS connectivity must ultimately pass through SDS.

For example, MESH mailbox discovery is governed by the addressing and lookup mechanisms defined for MESH. Likewise, discovering a healthcare service that accepts referrals or provides a particular treatment is not necessarily equivalent to discovering a technical endpoint. Such workflows may require a Directory of Services integration or a dedicated referral service.

A common resolver interface can accommodate these differences without forcing unrelated services into a GP Connect routing model.

The component also needs clearly defined behaviour when directory records cannot produce an unambiguous route. A successful HTTP response from SDS containing an empty Bundle is not equivalent to an upstream outage. It may indicate that the organisation does not provide the requested interaction, has not completed its technical provisioning or has been queried using an incorrect identifier.

Similarly, multiple matching records should not be handled by selecting the first result. Where the integration contract expects a unique destination, the resolver should reject ambiguous matches and provide sufficient diagnostic information for investigation. If the API supports paginated results, uniqueness checks must account for the complete result set rather than the first page alone.

The distinction between technical failure and absence of a registered service should be retained in the application’s internal error model. A clinical workflow may need to present an alternative access mechanism when a service is unavailable, whereas a temporary directory outage may justify a bounded retry.

Caching and synchronisation require different policies for ODS and SDS.

ODS reference data is relatively well suited to a synchronised local read model. Organisation data published through the current ODS API products is generally refreshed overnight. Repeatedly retrieving identical organisation records during individual clinical transactions therefore provides little benefit.

A local organisation directory can be populated from an initial dataset and subsequently refreshed using supported incremental retrieval mechanisms. The synchronisation process should persist source modification information, use idempotent updates and retain inactive organisations rather than deleting them.

Where incremental synchronisation is based on modification timestamps, an overlapping retrieval window can protect against records being missed around checkpoint boundaries. The checkpoint should advance only after the corresponding updates have been committed successfully.

Historical organisation records remain necessary for interpreting previous clinical interactions, audit entries and referral activity. A practice closure or organisational merger should not cause historic records to become detached from their originating organisation.

Succession information requires equally careful handling. An organisational successor is not automatically the correct technical or clinical destination for every patient associated with a former organisation. Patient registrations and clinical system migrations may progress according to different operational schedules. Where routing is patient-dependent, the current registration and applicable workflow rules should determine the destination.

SDS caching has tighter constraints. GP Connect specifies session-based caching of discovered provider endpoint and capability information, with fresh discovery for new patient encounters. A shared Redis cache keyed only by ODS code and interaction identifier, retained across clinical sessions, would not satisfy those requirements.

Within an encounter, however, the resolver can reuse an already established route for subsequent requests involving the same organisation and capability. A session-scoped cache key could incorporate the environment, originating organisation, destination organisation, interaction identifier and clinical session identifier.

Concurrent requests within the same session may also benefit from request coalescing. When several application components attempt to resolve the same route simultaneously, the resolver can share an in-flight lookup rather than issuing duplicate requests to SDS. Failed lookups should not become indefinitely cached failures.

Because the endpoint and accredited system queries are dependent on one another, the two provider discovery requests cannot ordinarily be executed in parallel. Independent operations, such as resolving the consumer’s own system identity, may be performed concurrently once their inputs are available.

All outbound directory requests should have explicit connection and response timeouts, bounded retry policies and an overall discovery deadline. Retrying every failure indiscriminately can amplify an upstream incident, particularly when hundreds of clinical sessions are attempting to resolve destinations at the same time. Transient network errors and eligible server-side failures may justify retries with exponential backoff and jitter; missing records and malformed requests generally require a different response.

Diagnosing discovery failures and operating the integration in production

Production failures involving NHS service discovery frequently occur at the boundaries between organisational data, registered system configuration, transport security and clinical application behaviour.

An application may successfully resolve an ODS code, retrieve an endpoint and obtain an ASID, yet still receive a rejection from the Spine Secure Proxy. The directory queries may have succeeded independently while the assembled request contains an inconsistent combination of provider identity, interaction identifier or service root.

Troubleshooting is considerably easier when discovery and request execution are instrumented as separate stages. Each outbound clinical interaction should have an internal correlation identifier linking the directory lookups, route construction, proxy request and downstream response.

Operational telemetry should capture the environment, requested interaction, relevant organisational and system identifiers, lookup duration, result cardinality, cache behaviour and failure category. The SSP trace identifier should also be retained in appropriately controlled diagnostic records.

Patient NHS numbers, clinical request bodies, demographic details and authentication credentials should not be written to general-purpose application logs. Where patient-level auditing is required, it should be implemented through the application’s controlled clinical audit infrastructure rather than ordinary observability tooling.

Common failure conditions include:

  • No matching endpoint: The organisation may not support the requested capability, the interaction identifier may be incorrect or the necessary SDS registration may be incomplete.
  • Endpoint found but no matching accredited system: The party key, interaction identifier and organisation combination should be checked for registration inconsistencies.
  • Multiple matching systems: Search constraints may be insufficient, or duplicate or overlapping registrations may require investigation.
  • Proxy destination mismatch: The discovered service root may have been altered during URL construction or combined with an incorrect provider ASID.
  • Proxy interaction rejection: The consumer or provider system may not be registered for the requested interaction, or the request may contain inconsistent routing information.
  • TLS or authentication failure: Certificate validity, trust chains, application credentials, network connectivity and environment configuration should be investigated separately from directory data.

FHIR OperationOutcome responses should be parsed rather than reduced to an HTTP status code. The structured issue details can help distinguish a proxy rejection from a provider-side clinical or validation error, allowing the application to categorise failures more accurately.

The route resolver should expose metrics for lookup success rates, missing registrations, ambiguous matches, upstream response times and discovery-related proxy rejections. Metrics grouped by interaction identifier can reveal capability-specific problems, while controlled diagnostic logs provide the organisational detail necessary for individual investigations.

Care should be taken when adding ODS codes, ASIDs or session identifiers as time-series metric labels. In a large deployment, high-cardinality labels can significantly increase observability infrastructure costs. Organisational identifiers are generally better suited to structured logs or trace attributes unless the monitoring platform has been designed to accommodate the resulting cardinality.

Testing the discovery layer requires more than confirming that an endpoint can be retrieved from an NHS integration environment. Contract tests should cover realistic FHIR Bundles, empty responses, multiple identifiers, unexpected resource types and incomplete system registrations. The test fixtures should also exercise provider changes between clinical encounters, ensuring that the application does not retain an obsolete destination.

One particularly useful regression test involves simulating a GP practice migration between clinical system suppliers. The practice retains its ODS code, but the SDS response changes to identify a different endpoint, party key and ASID. The application should resolve the new route on the next encounter without requiring a software deployment or manual replacement of supplier-specific configuration.

Environment isolation must be tested explicitly. Integration and production directory endpoints, system identifiers, credentials and SSP configuration should never be interchangeable. Including the deployment environment in the route representation and cache namespace helps prevent configuration leakage, but the outbound integration client should also enforce environment-specific destination policies.

Security testing should cover the treatment of discovered URLs. A directory response should not give an application unrestricted permission to initiate arbitrary outbound connections. The service root should be validated against the expected URI scheme and integration-specific routing policy, and the request should be sent using the prescribed transport. For GP Connect, this means constructing the mediated request to the configured Spine Secure Proxy rather than using the directory result as an unrestricted HTTP destination.

Finally, retry behaviour following a routing failure needs to account for the clinical operation being performed. Refreshing discovery information and retrying a read-only interaction may be appropriate under controlled circumstances. Automatically resubmitting an appointment booking, clinical record update or other state-changing operation is substantially more complicated. If the first request reached the provider but its response was lost, a second submission could duplicate the clinical action. Recovery must therefore follow the operation’s supported idempotency or reconciliation mechanisms.

A well-designed NHS service discovery layer allows organisational reference data, accredited system registrations and clinical application configuration to evolve independently. Its reliability depends less on the complexity of the directory queries themselves than on how their results are interpreted, correlated, validated and retained. Keeping those responsibilities within a dedicated integration component makes supplier migrations, new capability onboarding and national infrastructure changes manageable without embedding routing assumptions throughout the clinical application.

Need help with NHS API integration?

Is your team looking for help with NHS API integration? Click the button below.

Get in touch