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

# Merge Medications Route

> Merge each source medication into the keep medication.

Doses and charge items snapshot the medication's name/amount/unit at administration time, so
historical records survive the source's deletion. Live FK references (templates, care-plan
steps, item_stock, inventory_log, etc.) are rewritten to point at the kept medication before
the source is hard-deleted. The entire merge runs in one transaction.



## OpenAPI

````yaml post /medications/merge
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /medications/merge:
    post:
      tags:
        - Medications
      summary: Merge Medications Route
      description: >-
        Merge each source medication into the keep medication.


        Doses and charge items snapshot the medication's name/amount/unit at
        administration time, so

        historical records survive the source's deletion. Live FK references
        (templates, care-plan

        steps, item_stock, inventory_log, etc.) are rewritten to point at the
        kept medication before

        the source is hard-deleted. The entire merge runs in one transaction.
      operationId: merge_medications_route_medications_merge_post
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MergeMedicationsRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: boolean
                title: Response Merge Medications Route Medications Merge Post
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    MergeMedicationsRequest:
      properties:
        keepId:
          type: string
          title: Keepid
        sourceIds:
          items:
            type: string
          type: array
          maxItems: 50
          minItems: 1
          title: Sourceids
      type: object
      required:
        - keepId
        - sourceIds
      title: MergeMedicationsRequest
      description: Merge one or more source medications into a kept medication.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````