Currently, the main part of hydrocarbons consumed both in the Russian Federation and in the world as a whole is transported through pipelines. This type of transport has many advantages, however, despite this, problems arise during operation related to ensuring the integrity of the pipelines themselves and providing settlements located along the linear part with fuel using intermediate branches to local oil depots. It is worth noting that in this case there is a problem of ensuring constant and highquality monitoring of the state of the oil product pipeline-branch pipeline system, for which constant monitoring methods based on mathematical modeling are often used to solve, which make it possible to investigate the integrity without changing the pumping mode. However, in order to improve the accuracy of these methods, it is necessary to constantly improve existing or develop new mathematical models of pipeline systems.The main aim of the research. Improvement of mathematical modeling methods for detecting leaks or unauthorized tie-ins during intermediate scheduled discharges of hydrocarbons on the linear part of the main pipeline.Mathematical modeling of the operating mode of the technological section of the main pipeline, taking into account the discharge on the linear part, the need to regulate the operating modes of pumping stations.An algorithm has been developed to determine the location of a leak or illegal tie-in on a trunk pipeline with an intermediate branch to a local oil depot. A graph of the hydraulic slope line is constructed in the presence of damage to the integrity of the pipeline. A preliminary economic assessment of the damage to the supplier company from the loss of the pumped product was carried out.