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

# Get a user's linked record

> Returns the link for a `user_id` + `link_type` pair.

A service token may look up any `user_id` in your organization. A **user token** may only fetch its own link — `user_id` must match the caller's own id — and gets the same 404 for "no such link" and "not yours", so it can't distinguish the two.

**Permissions:** `user-links:read`



## OpenAPI

````yaml /openapi.json get /iam/users/links
openapi: 3.1.0
info:
  title: OpenLoop API
  version: 0.1.0
  description: >-
    Unified reference for the OpenLoop Patient (clinical) and Payments & Revenue
    APIs.
servers:
  - url: https://api.openloophealth.com/v0.1
    description: Production partner edge
  - url: https://api-staging.openloophealth.com/v0.1
    description: Staging partner edge (sandbox credentials)
security: []
paths:
  /iam/users/links:
    get:
      tags:
        - Users
      summary: Get a user's linked record
      description: >-
        Returns the link for a `user_id` + `link_type` pair.


        A service token may look up any `user_id` in your organization. A **user
        token** may only fetch its own link — `user_id` must match the caller's
        own id — and gets the same 404 for "no such link" and "not yours", so it
        can't distinguish the two.


        **Permissions:** `user-links:read`
      parameters:
        - name: user_id
          in: query
          required: true
          schema:
            type: string
        - name: link_type
          in: query
          required: true
          schema:
            type: string
            enum:
              - ehr_patient_id
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/PrincipalLink'
                  request_id:
                    type: string
                required:
                  - data
                  - request_id
        '400':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Bearer token is missing the user-links:read permission
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: >-
            No matching link found, the user_id is not in your organization, or
            (for a user token) the user_id is not your own
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - serviceToken:
            - user-links:read
        - userToken:
            - user-links:read
components:
  schemas:
    PrincipalLink:
      type: object
      properties:
        user_id:
          type: string
        link_type:
          type: string
          enum:
            - ehr_patient_id
        link_source:
          type: string
        link_value:
          type: string
      required:
        - user_id
        - link_type
        - link_value
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            error_code:
              type: string
          required:
            - message
            - error_code
        request_id:
          type: string
      required:
        - error
        - request_id
  securitySchemes:
    serviceToken:
      type: oauth2
      description: >-
        Service (M2M) access token issued by POST /auth/token using the
        client_credentials grant. Required scopes, where known, are listed on
        each operation below.
      flows:
        clientCredentials:
          tokenUrl: https://api.openloophealth.com/v0.1/auth/token
          scopes: {}
    userToken:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        User access token issued by POST /auth/token via the verification-code
        grant (after Verify a one-time code) or the refresh_token grant.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.