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

# Search the pharmacy directory

> Searches the EHR's Surescripts pharmacy directory. `patientId` selects the EHR instance; the directory is national. At least one of `name`, `zip`, `city` or `ncpdpId` is required. ModMed searches retail pharmacies only until a search without a directory type is proven; EZDerm requires `zip` and cannot look up an NCPDP id.



## OpenAPI

````yaml /openapi-v4.json get /pharmacies/search
openapi: 3.0.0
info:
  title: Max AI Public API
  description: API for third-party marketplace apps
  version: '4.0'
  contact: {}
servers:
  - url: https://api.maxcare.ai/v4
security: []
tags: []
paths:
  /pharmacies/search:
    get:
      tags:
        - Pharmacies
      summary: Search the pharmacy directory
      description: >-
        Searches the EHR's Surescripts pharmacy directory. `patientId` selects
        the EHR instance; the directory is national. At least one of `name`,
        `zip`, `city` or `ncpdpId` is required. ModMed searches retail
        pharmacies only until a search without a directory type is proven;
        EZDerm requires `zip` and cannot look up an NCPDP id.
      operationId: PharmaciesPublicController_searchPharmacies
      parameters:
        - name: patientId
          required: true
          in: query
          description: >-
            Any patient in the EHR instance to search through. The directory
            itself is national.
          schema:
            type: string
            example: pat_8de0303900004000a000000000000001
        - name: name
          required: false
          in: query
          description: Store name (substring)
          schema:
            example: Example Pharmacy
            type: string
        - name: zip
          required: false
          in: query
          description: Five-digit ZIP code. Required on EZDerm.
          schema:
            type: string
            example: '48500'
        - name: city
          required: false
          in: query
          schema:
            type: string
            example: Example
        - name: state
          required: false
          in: query
          description: Two-letter state code
          schema:
            type: string
            example: MI
        - name: ncpdpId
          required: false
          in: query
          description: >-
            Exact NCPDP lookup (7 digits). ModMed only: EZDerm's directory
            exposes no NCPDP.
          schema:
            type: string
            example: '0000001'
        - name: page
          required: false
          in: query
          description: Page number (1-indexed)
          schema:
            default: 1
            example: 1
        - name: pageSize
          required: false
          in: query
          description: Number of items per page (max 50)
          schema:
            default: 10
            example: 10
        - name: X-Organization-Id
          in: header
          required: true
          schema:
            type: string
          description: Target clinic organization ID
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchPharmaciesSuccessResponse'
        '400':
          description: Missing or invalid request parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadRequestResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiUnauthorizedResponse'
        '403':
          description: Insufficient scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiForbiddenResponse'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiNotFoundResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiRateLimitResponse'
        '502':
          description: EHR sync failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicApiBadGatewayResponse'
      security:
        - api-key: []
components:
  schemas:
    SearchPharmaciesSuccessResponse:
      type: object
      properties:
        code:
          type: string
          description: Response code
          example: success
        data:
          $ref: '#/components/schemas/SearchPharmaciesResponseData'
      required:
        - code
        - data
    PublicApiBadRequestResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: bad_request
        message:
          type: string
          description: Human-readable error message
          example: '''id'' must be a valid UUID'
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiUnauthorizedResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unauthorized
        message:
          type: string
          description: Human-readable error message
          example: Invalid or missing API key
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiForbiddenResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: forbidden
        message:
          type: string
          description: Human-readable error message
          example: Insufficient scope
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiNotFoundResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: not_found
        message:
          type: string
          description: Human-readable error message
          example: Resource not found
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiRateLimitResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: rate_limit_exceeded
        message:
          type: string
          description: Human-readable error message
          example: Rate limit exceeded. Maximum 1000 requests per 60 seconds.
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    PublicApiBadGatewayResponse:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: unexpected_integration_error
        message:
          type: string
          description: Human-readable error message
          example: EHR sync failed
        trace_id:
          type: string
          description: Trace ID for debugging
          example: 550e8400-e29b-41d4-a716-446655440000
      required:
        - code
        - message
        - trace_id
    SearchPharmaciesResponseData:
      type: object
      properties:
        pharmacies:
          type: array
          items:
            $ref: '#/components/schemas/ExternalDirectoryPharmacyResponse'
        pagination:
          $ref: '#/components/schemas/PharmacySearchPaginationResponse'
      required:
        - pharmacies
        - pagination
    ExternalDirectoryPharmacyResponse:
      type: object
      properties:
        ncpdpId:
          type: string
          nullable: true
          description: National NCPDP id. Null on EZDerm, whose directory exposes none.
          example: '0000001'
        name:
          type: string
          example: Example Clinic Pharmacy
        type:
          type: string
          nullable: true
          description: Directory type, lower-cased as the EHR reports it (e.g. `retail`)
          example: retail
        address:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/PharmacyAddressResponse'
        phone:
          type: string
          nullable: true
          example: '8105550100'
        fax:
          type: string
          nullable: true
          example: '8105550101'
        open24h:
          type: boolean
          nullable: true
          example: false
        refillEnabled:
          type: boolean
          nullable: true
          example: true
        epcsEnabled:
          type: boolean
          nullable: true
          description: Accepts electronic controlled-substance scripts
          example: true
      required:
        - ncpdpId
        - name
        - type
        - address
        - phone
        - fax
        - open24h
        - refillEnabled
        - epcsEnabled
    PharmacySearchPaginationResponse:
      type: object
      properties:
        page:
          type: number
          example: 1
        pageSize:
          type: number
          example: 10
        totalCount:
          type: number
          nullable: true
          description: Null when the EHR reported no total
          example: 1
        totalPages:
          type: number
          nullable: true
          example: 1
      required:
        - page
        - pageSize
        - totalCount
        - totalPages
    PharmacyAddressResponse:
      type: object
      properties:
        line1:
          type: string
          example: 100 Example St
        line2:
          type: string
          nullable: true
          example: null
        city:
          type: string
          example: Example
        state:
          type: string
          example: MI
        zip:
          type: string
          example: '48500'
      required:
        - line1
        - city
        - state
        - zip
  securitySchemes:
    api-key:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: Marketplace API key

````

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