The AP was with "notified" in a letter...
From the article, "News organizations normally are notified in advance that the government wants phone records and enter into negotiations over the desired information. In this case, however, the government, in its letter to the AP, cited an exemption to those rules..."
and then,
"It is unknown whether a judge or a grand jury signed off on the subpoenas."