New York (CNN Business) Twitter "inadvertently" used phone numbers and email addresses its users provided for account security purposes to target ads, the company said Tuesday.

In July, the Federal Trade Commission (FTC) said Facebook had broken the law when it engaged in a similar practice. The FTC fined Facebook $5 billion for that and a litany of other instances where it mishandled user data.

Twitter users are asked to provide information like their phone number to help secure their account through services such as two-factor authentication.

"We cannot say with certainty how many people were impacted by this, but in an effort to be transparent, we wanted to make everyone aware," the company said in a blog post Tuesday . It said no personal data had been shared externally.

"We're very sorry this happened and are taking steps to make sure we don't make a mistake like this again," the company added.

Read More