SAN FRANCISCO — Amazon, T-Mobile and other companies and employment agencies are being sued for age discrimination for placing recruiting ads on Facebook that target younger workers.

The lawsuit filed Wednesday in San Francisco federal court is seeking class-action status to represent Facebook users 40 or older who may have been denied the chance to learn about open job positions. It was filed by the Communications Workers of America labor union and three workers, Linda Bradley, Maurice Anscombe, and Lura Callahan, who range in age from 45 to 67.

For example, lawyers for the plaintiffs say T-Mobile used Facebook ads to recruit applicants for retail stores and other positions, stating in its ads it wanted to reach people ages 18 to 38. T-Mobile declined comment.

Amazon also placed employment ads for warehouse and other jobs that restricted who could see them, such as people “ages 18-54,” “ages 18 to 50,” “ages 28 to 55,” and “ages 22 to 40," according to the lawsuit. In an emailed statement, Amazon said it does not comment on pending litigation, but said after a recent audit of recruiting ads on Facebook, it discovered "some had targeting that was inconsistent with our approach of searching for any candidate over the age of 18. We have corrected those ads," the company said.

The lawsuit also alleges Facebook itself placed ads to recruit job applicants to work at Facebook, using the same age filters to exclude older workers. Facebook declined to comment on the suit.

Ageism is a longstanding issue in corporate America but has worsened as recruiting ads have moved online, according to the lawsuit.

"Due to this lawsuit, older workers may finally understand why their job searches — that have migrated online in recent years-are more difficult than they ought to be," the plaintiffs wrote.

The lawsuit landed the same day The New York Times and ProPublica published a joint investigation raising fairness concerns over job ads aimed at younger age groups on Facebook, Google and LinkedIn.

Facebook defended the practice. "Simply showing certain job ads to different age groups on services like Facebook or Google may not in itself be discriminatory — just as it can be OK to run employment ads in magazines and on TV shows targeted at younger or older people. What matters is that marketing is broadly based and inclusive, not simply focused on a particular age group," Rob Goldman, Facebook vice president of ads, said in a statement posted to its website.

More:Facebook's Sheryl Sandberg says ads targeting 'Jew haters' failed users, pledges reform

More:Russia exploited race divisions on Facebook. More black staffers, diversity could have have helped.

More:Russians used Facebook the way other advertisers do: By tapping into its data-mining machine

More:Facebook political ads are coming out of the shadows — why you should care

ProPublica says it discovered the practice while reviewing data it compiled from readers for a project on political ads on Facebook. Many of the ads explained why that user was seeing the ad, including their age.

Facebook has become an increasingly popular place to recruit job applicants. A 2016 study by the Society for Human Resource Management found that 66% of employers who recruit on social media use Facebook.

The vast amounts of data Facebook has collected on its users allows advertisers to precisely target them. That targeting was used by Russia to influence the 2016 election. It also got Facebook in hot water when ProPublica discovered it could be used to target ads in offensive ways, such as to "jew haters."

Some advertisers told ProPublica that targeting specific age groups on Facebook is similar to advertising in Teen Vogue or AARP the Magazine. However, ProPublica pointed out, anyone can flip through the pages of those publications, but people who are in excluded age groups will never see these ads on Facebook.

ProPublica also bought job ads on Google and LinkedIn that excluded audiences older than 40. Google told the news organization it does not prevent advertisers from displaying ads based on a user’s age. LinkedIn told USA TODAY that it now requires advertisers to pledge they will not discriminate based on age when placing employment ads. "Only once they’ve checked this box, the option to target by age will become available," the company said in a statement.

Among the companies that placed the recruitment ads are Amazon, Goldman Sachs, AT&T and Verizon.

Goldman Sachs spokesman Andrew Williams said: "We welcome and actively recruit applicants of all ages. For some of our social media ads, we look to get the content to the people most likely to be interested, but do not exclude anyone from our recruiting activity."

AT&T says it buys ads on different platforms to appeal to "every segment of the population." Verizon did not respond to repeated requests for comment, according to ProPublica.