Hi Maria:
To get to SJPDP from Madrid, you need to go first to Pamplona, from which you then take a bus to SJPDP.
From the Madrid airport (or from central Madrid, if you’re staying over a night), you can get a bus directly to Pamplona. You will find the schedule on the Alsa bus website at
https://www.alsa.com/en/web/bus/home.
Alternatively, you can get a train from Madrid to Pamplona. With respect to the train, there’s no service directly from the airport, so you need to get into central Madrid to pick it up. You can find the train schedule on the website of Renfe, which is the Spanish national railroad.
http://www.renfe.com/EN/viajeros/index.html
The train ride is 2 hours faster, but the bus has its own advantages: you can go to Pamplona directly from the airport, plus once you get to Pamplona, you’re already at the bus station where you get the bus to SJPDP. The train station in Pamplona, by contrast, is several miles away, so you then need to get from the train station to the bus station by local bus or taxi.
Once you get to Pamplona, you then pick up the Alsa bus to SJPDP. You’ll find the scedule at the Alsa website I gave you above. Make sure you input SJPDP as Saint Jean Pied de Port, rather than St. Jean Pied de Port.