Airbnb has agreed to turn over anonymous data of users who list New York properties on its website to the state attorney general’s office.

Under the deal, which was announced Wednesday, the company won’t have to turn over any identifying information unless a user is the subject of an investigation by the attorney general’s office over the next 12 months.

Airbnb must turn over the initial data dump within 30 days; unique identifiers will replace user names. 

“We believe this is a strong agreement that best protects our community’s data and sets us on a positive path forward,” wrote David Hantman, Airbnb’s head of global public policy, on the company’s blog.

Airbnb also agreed to notify hosts of laws that may apply to anyone in New York who lists a property on the site.

The deal was said to be the fruit of months of negotiation between the company and Eric Schneiderman’s office.

It follows a recent decision by a court to throw out a subpoena served on Airbnb by the attorney general’s office seeking much more detailed data on the website’s users in New York.

The judge had ruled the subpoena was too broad, while at the same time declaring that evidence indicated a “substantial number” of Airbnb hosts were breaking the law in New York by renting out their homes over the site.  

The attorney general’s office has been investigating whether unscrupulous operators of illegal hotels are listing properties on the Airbnb website, flouting the state’s laws prohibiting the renting of vacant apartments for short stays as well as tax laws.