The Code of Criminal Procedure, 1973 (CrPc)
267. Power to require attendance of prisoners.
(1) Wherever, in the course of an inquiry, trial or other proceeding under this Code, it appears to a Criminal Court.
(a) That a person confined or detained in a prison should be brought before the court for answering to a charge of an offence, or for the purpose of any proceedings against him, or
(b) That it is necessary for the ends of justice to examine such person as a witness,
the court may make an order requiring the officer in charge of the prison to produce such person before the court for answering to the charge or for the purpose of such proceeding or as the case may be, for giving evidence.
(2) Where an order under sub-section (1) is made by a Magistrate of the second class, it shall not be forwarded to, or acted upon by the officer in charge of the prison unless it is countersigned by the Chief Judicial Magistrate to whom such Magistrate is subordinate.
(3) Every order submitted for countersigning under sub-section (2) shall be accompanied by a statement of the facts which, in the opinion of the Magistrate, render the order necessary, and the Chief Judicial Magistrate to whom it is submitted may, after considering such statement, decline to countersign the order.