The first recorded Marian apparition occurred while the Blessed Virgin Mary was still on earth. According to tradition, the Apostle Saint James the Greater (brother of Saint John the Evangelist) was sent by Saint Peter to Spain to evangelize the Gentiles of that province. While praying by the banks of the Ebro at Saragossa, the Holy Mother of God bilocated and appeared to the Apostle. She instructed him to build a church there, which he did.
When did this miracule occur? Tradition places Saint James in Spain for about 5 years in the latter half of the AD 30s. Local tradition identifies the date as Saturday January 2, AD 40 on the Julian Calendar. It's an established fact that Saint James the Greater was martyred in Jerusalem around AD 44. This entails that the traditional date is within a reasonable range both for Saint James to travel to Spain and to return to Jerusalem by AD 44.
Why did Saint James the Greater receive this great privilege of the first Marian apparition? Christ chose Saint James to be His first Apostolic martyr. It seems then that this vision was meant to strengthen and console Saint James. In fact, Maria Agreda states that Saint James was allowed a vision of the Blessed Virgin Mary as he was being martyred and that she personally escorted Saint James' soul to the judgment seat of Christ.
In this light, Saint James the Greater is very much like the 20th century martyr Saint Maximilian Maria Kolbe who consecrated his life to Jesus through Mary and found strength there to offer his body in the oblation of martyrdom.