{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/affinityrx-com/json-schema/affinityrx-com-medication-schema.json",
  "title": "Medication",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/affinityrx-com-openapi.json#/components/schemas/Medication",
  "type": "object",
  "properties": {
    "category": {
      "type": "string",
      "description": "What the medication is prescribed for. Every strength, form and pharmacy of one medication has the same category.",
      "x-extensible-enum": [
        "weight_loss",
        "hormones",
        "sexual_health",
        "hair",
        "skin",
        "wellness",
        "peptides",
        "pain",
        "other",
        "supplies"
      ]
    },
    "coldChainRequired": {
      "type": "boolean",
      "description": "Whether the medication requires refrigerated shipping."
    },
    "compoundingReasons": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The accepted compounding reasons when the pharmacy limits them."
    },
    "defaultDirections": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The catalog's default directions, or null when none are supplied."
    },
    "fill": {
      "anyOf": [
        {
          "$ref": "#/$defs/Fill"
        },
        {
          "type": "null"
        }
      ],
      "description": "What the pharmacy dispenses for one price, or null when the complete fill is unknown."
    },
    "form": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The dosage form, or null when it is unknown."
    },
    "fullName": {
      "type": "string",
      "description": "The name with each ingredient: its salt where the catalog records one, such as Enclomiphene Citrate, or the ingredients of a blend named for what prescribers call it, such as Myers' Cocktail. Equals name otherwise."
    },
    "id": {
      "type": "string",
      "pattern": "^med_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "description": "The public record identifier."
    },
    "kit": {
      "anyOf": [
        {
          "$ref": "#/$defs/Kit"
        },
        {
          "type": "null"
        }
      ],
      "description": "The vials or bottles a kit holds, in the order they are used; null for anything that is not a kit."
    },
    "name": {
      "type": "string",
      "description": "The name."
    },
    "pharmacy": {
      "$ref": "#/$defs/PharmacyReference"
    },
    "pharmacyRank": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "Affinity's preference for the dispensing pharmacy, from 0 for the most preferred. When two pharmacies have the same item at the same price, choose the lower rank. Absent when Affinity has no preference for the pharmacy."
    },
    "price": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "The price in integer cents."
    },
    "researchUseOnly": {
      "type": "boolean",
      "description": "Whether the medication is for research use only (RUO). Only an organization with RUO access sees one."
    },
    "maxRefills": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "The most refills a prescription of this medication takes, or null when any count within the request limits is accepted. 0 means the pharmacy takes no refills: send a new order for each fill."
    },
    "quantities": {
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 1,
        "maximum": 9007199254740991
      },
      "description": "The accepted quantities, counted in quantityUnit; an empty list permits any quantity within the request limits."
    },
    "quantityUnit": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The unit used to count the prescribed quantity, or null when it is unknown."
    },
    "requirements": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "The optional prescription field paths that this medication requires."
    },
    "restrictedStates": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Every state where this medication cannot ship, including states the pharmacy does not cover. It can ship to every other state."
    },
    "shippingOptions": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ShippingOption"
      },
      "description": "The shipping options available for this medication."
    },
    "shippingSuppliesPrice": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "Always 0. Each shipping option price is the complete shipping price."
    },
    "strength": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "The pharmacy's strength text, or null when it is unknown."
    },
    "unsupportedFields": {
      "type": "array",
      "items": {
        "type": "string",
        "x-extensible-enum": [
          "notes",
          "substitutionPermitted"
        ]
      },
      "description": "The prescription fields this medication's pharmacy cannot receive: notes (send none) and substitutionPermitted (send true). An order that sets one is still accepted; in Live mode Affinity staff handle it, and in Test mode it fails when sent. Absent when the pharmacy receives them all."
    }
  },
  "required": [
    "category",
    "coldChainRequired",
    "compoundingReasons",
    "defaultDirections",
    "fill",
    "form",
    "fullName",
    "id",
    "kit",
    "name",
    "pharmacy",
    "price",
    "researchUseOnly",
    "maxRefills",
    "quantities",
    "quantityUnit",
    "requirements",
    "restrictedStates",
    "shippingOptions",
    "shippingSuppliesPrice",
    "strength"
  ],
  "additionalProperties": {
    "description": "A field that this API version can add. Ignore fields that you do not know."
  },
  "$defs": {
    "Fill": {
      "type": "object",
      "properties": {
        "amount": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991,
          "description": "How much one fill holds, in `unit`."
        },
        "container": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "description": "What holds one fill, such as `vial`. Null when the pharmacy does not say."
        },
        "ingredients": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "amount": {
                "type": "number",
                "description": "The amount in the specified unit."
              },
              "name": {
                "type": "string",
                "description": "The name."
              },
              "unit": {
                "type": "string",
                "description": "The unit used to measure the amount."
              }
            },
            "required": [
              "amount",
              "name",
              "unit"
            ],
            "additionalProperties": {
              "description": "A field that this API version can add. Ignore fields that you do not know."
            }
          },
          "description": "Each active ingredient's total in one fill: a 2 mL vial of 30 mg/mL is 60 mg."
        },
        "unit": {
          "type": "string",
          "description": "The unit of `amount`, the same as `quantityUnit`: `vial` for a vial product."
        },
        "volume": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "amount": {
                  "type": "number",
                  "description": "The amount in the specified unit."
                },
                "unit": {
                  "type": "string",
                  "description": "The unit used to measure the amount."
                }
              },
              "required": [
                "amount",
                "unit"
              ],
              "additionalProperties": {
                "description": "A field that this API version can add. Ignore fields that you do not know."
              }
            },
            {
              "type": "null"
            }
          ],
          "description": "What one vial holds, such as 2 mL. Null for a product that is not a vial."
        }
      },
      "required": [
        "amount",
        "container",
        "ingredients",
        "unit",
        "volume"
      ],
      "description": "What the pharmacy dispenses for one price. A quantity counts `unit`, not fills, and is a whole number of fills: for a fill of 30 tablets, quantity 60 is two fills and costs twice the price. For a vial product, one fill is one vial and quantity counts vials.",
      "additionalProperties": {
        "description": "A field that this API version can add. Ignore fields that you do not know."
      }
    },
    "Kit": {
      "type": "object",
      "properties": {
        "days": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991,
          "description": "How many days the kit lasts."
        },
        "vials": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "ingredients": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "amount": {
                      "type": "number",
                      "description": "The amount in the specified unit."
                    },
                    "name": {
                      "type": "string",
                      "description": "The name."
                    },
                    "unit": {
                      "type": "string",
                      "description": "The unit used to measure the amount."
                    }
                  },
                  "required": [
                    "amount",
                    "name",
                    "unit"
                  ],
                  "additionalProperties": {
                    "description": "A field that this API version can add. Ignore fields that you do not know."
                  }
                },
                "description": "Each active ingredient's total in this vial."
              },
              "strength": {
                "type": "string",
                "description": "This vial's strength, such as 5 mg/mL."
              }
            },
            "required": [
              "ingredients",
              "strength"
            ],
            "additionalProperties": {
              "description": "A field that this API version can add. Ignore fields that you do not know."
            }
          },
          "description": "Each vial or bottle in the order it is used. `fill.volume` is what one holds."
        }
      },
      "required": [
        "days",
        "vials"
      ],
      "description": "Vials or bottles shipped together as one product and used in order.",
      "additionalProperties": {
        "description": "A field that this API version can add. Ignore fields that you do not know."
      }
    },
    "PharmacyReference": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^pharm_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "description": "The public record identifier."
        },
        "name": {
          "type": "string",
          "description": "The name."
        }
      },
      "required": [
        "id",
        "name"
      ],
      "description": "The dispensing pharmacy.",
      "additionalProperties": {
        "description": "A field that this API version can add. Ignore fields that you do not know."
      }
    },
    "ShippingOption": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^shp_[0-7][0-9a-hjkmnp-tv-z]{25}$",
          "description": "Shared across Test and Live. Old Test shipping IDs remain valid in Test."
        },
        "name": {
          "type": "string",
          "description": "The name."
        },
        "price": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "The price in integer cents."
        }
      },
      "required": [
        "id",
        "name",
        "price"
      ],
      "additionalProperties": {
        "description": "A field that this API version can add. Ignore fields that you do not know."
      }
    }
  }
}