The Catechism in Questions & Answers

205. How does one receive the gift of the Holy Spirit?

The gift of the Holy Spirit is granted by God through the laying on of hands and prayer of an Apostle. This is shown, for example, in the events that transpired in Samaria.

“Now when the Apostles who were at Jerusalem heard that Samaria had received the word of God, they sent Peter and John to them, who, when they had come down, prayed for them that they might receive the Holy Spirit. For as yet He had fallen upon none of them. They had only been baptised in the name of the Lord Jesus. Then they laid hands on them, and they received the Holy Spirit.”
Acts 8: 14-17