Of course.
As mentioned, former president Castillo attempted a coup d'état. It was considered a criminal act, typified in our criminal laws as a crime of rebellion. After giving a message to the nation where he declared the constitutional closing of Congress and the intervention of the whole judiciary, he decided to rule by himself through decrees.
He was detained in flagrant delicto of his crime by the Peruvian National Police and placed at the disposal of the corresponding judicial authorities.
Given the seriousness of the act and the position Mr. Castillo held, the Peruvian Supreme Court of Justice ordered Mr. Castillo to be held in preventive detention for 18 months. This period of detention is being executed in strict respect of his fundamental rights. He is not in a common prison. He's in a special prison. The former president has a legal defence and receives daily visits. He has even been visited by the Inter-American Commission on Human Rights. He is not isolated and actively coordinates the management of his Twitter account, among other rights.
The situation of former president Castillo is a matter of strict competence of the public prosecutor's office and the judiciary, which are institutions that have been following his judicial case in strict compliance with the rules of due process. I have to emphasize that they work under the constitutional principle of the separation of powers and are autonomous in their responsibilities and decisions in each specific place.