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

# Upload medicine codes

> **Permission:** `inventory.items:write` Upload up to 1,000 of a partner's own medicine codes. An exact identifier match links automatically; the rest wait for review. Idempotent by construction — Idempotency-Key optional. Unknown per-row fields are refused by name WITHOUT aborting the rest of the batch.



## OpenAPI

````yaml /openapi/ehr-api.v1.yaml post /v1/clinics/{clinic_id}/inventory/codes
openapi: 3.1.0
info:
  title: ClinikEHR API
  version: 1.0.0
  description: >-
    Server-to-server REST API for a clinic's own data, reached with a key the
    clinic (or a developer workspace) creates in the developer portal.


    Authenticate every request with `Authorization: Bearer <key>`. Test keys
    reach only your workspace's own synthetic sandbox; live keys reach the
    clinic that created them. Lists wrap their rows as `{ data, has_more,
    next_cursor }`; single resources are returned directly. Errors are
    `application/problem+json` (RFC 9457) with a stable `code`.


    Write requests accept an `Idempotency-Key` header so a retry never repeats a
    change. See the guides for authentication, permissions, pagination, rate
    limits and retries.
servers:
  - url: https://api.clinikehr.com
security:
  - ApiKey: []
paths:
  /v1/clinics/{clinic_id}/inventory/codes:
    post:
      tags:
        - Inventory
      summary: Upload medicine codes
      description: >-
        **Permission:** `inventory.items:write` Upload up to 1,000 of a
        partner's own medicine codes. An exact identifier match links
        automatically; the rest wait for review. Idempotent by construction —
        Idempotency-Key optional. Unknown per-row fields are refused by name
        WITHOUT aborting the rest of the batch.
      operationId: uploadPartnerCodes
      parameters:
        - $ref: '#/components/parameters/IdempotencyKeyOptional'
        - name: clinic_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerCodesUploadRequest'
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/PartnerCodeUploadResult'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
        - ApiKey: []
components:
  parameters:
    IdempotencyKeyOptional:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        Optional. A unique value you choose for this request, such as a UUID.
        When sent, a retry with the same key returns the first answer instead of
        applying the change twice. See Retries and idempotency.
      schema:
        type: string
        minLength: 1
  schemas:
    PartnerCodesUploadRequest:
      type: object
      additionalProperties: false
      required:
        - entries
      properties:
        entries:
          type: array
          minItems: 1
          maxItems: 1000
          items:
            $ref: '#/components/schemas/PartnerCodeUploadEntry'
    PartnerCodeUploadResult:
      type: object
      required:
        - code
        - state
      properties:
        code:
          type: string
        state:
          type:
            - string
            - 'null'
          enum:
            - linked
            - needs_review
            - unmatched
            - rejected
            - null
        reason:
          type:
            - string
            - 'null'
    PartnerCodeUploadEntry:
      type: object
      required:
        - code
      properties:
        code:
          type: string
          minLength: 1
        barcode:
          type: string
        nafdac_no:
          type: string
        ndc:
          type: string
        rxcui:
          type: string
        name:
          type: string
        strength:
          type: string
        form:
          type: string
        pack_size:
          type: string
    Problem:
      type: object
      description: RFC 9457 application/problem+json.
      required:
        - type
        - title
        - status
        - code
        - request_id
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
        status:
          type: integer
        detail:
          type: string
        code:
          type: string
        request_id:
          type: string
        errors:
          type: array
          items:
            type: object
            required:
              - pointer
              - message
            properties:
              pointer:
                type: string
              message:
                type: string
  responses:
    BadRequest:
      description: >-
        The request failed validation (unknown query parameter, limit out of
        range, malformed body).
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    Unauthorized:
      description: >-
        Missing, malformed, unknown, revoked or expired key, or the wrong
        secret.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    Forbidden:
      description: >-
        The key or connection lacks the required scope, the plan does not
        include this resource, the request came from an address this key's IP
        allow-list does not permit, a TEST-environment workspace key asked for a
        clinic_id other than its own workspace's sandbox (`sandbox_only`), or a
        LIVE workspace key asked for a real clinic while its workspace's
        verification has lapsed (`not_verified`) — the response never names
        which addresses ARE allowed, nor which clinic actually is the sandbox.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    NotFound:
      description: The record is absent, or out of the key's scope — one message for both.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
    TooManyRequests:
      description: Rate limited. See the Retry-After header.
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/Problem'
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: ehr_live_<keyId>_<secret> or ehr_test_<keyId>_<secret>

````

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