Updated

Convicted fraudster and former pharmaceuticals executive Martin Shkreli has apologized for putting up a $5,000 offer to anyone who gets Hillary Clinton’s hair -- in the wake of a hearing that could rescind his bail and put him behind bars.

“I wanted to personally apologize to this Court and my lawyers for the aggravation that my recent postings have caused,” wrote Shkreli in a letter addressed to the judge.

“I understand now, that some may have read my comments about Mrs. Clinton as threatening, when that was never my intention when making those comments. I used poor judgment but never intended to cause alarm or promote any act of violence whatsoever,” he added, pleading that the judge not revoke his $5 million bond.

The hearing on whether to revoke his bail is scheduled for Wednesday. It follows a government filing last week that suggested Shkreli’s behavior could be a reason to put him behind bars for being "a danger to the community.”

“The Clinton Foundation is willing to KILL to protect its secrets,” he wrote in a now-deleted Facebook post last week. “So on HRC’s book tour, try to grab a hair from her. I must confirm the sequences I have. Will pay $5,000 per hair obtained from Hillary Clinton.”

According to the prosecutors, “Since his conviction on August 4, 2017, Shkreli has engaged in an escalating pattern of threats and harassment that warrant his detention pending sentencing.”

They also said the Secret Service had to invest additional resources out of fear that his fans could take him up on the offer and attempt to snatch Clinton’s hair.

“That Shkreli awaits sentencing and still engages in an escalating pattern of egregious public behavior shows that he has no respect for the law and will not abide by any conditions or combination of conditions for his release,” the government motion reads.

At the time, Shkreli fired back at the accusations, writing that “Hillary Clinton's presumptive agents are hard at work. It was just a prank, bro!” and added that the Secret Service should their “resources investigating her, not me!”

Defense attorney Ben Brafman argued his client’s offer to pay money for former presidential candidate’s hair was merely a joke, comparable to certain comments made by President Donald Trump.

"Indeed, in the current political climate, dissent has unfortunately often taken the form of political satire, hyperbole, parody or sarcasm," the attorney wrote.

"There is a difference, however, between comments that are intended to threaten or harass and comments — albeit offensive ones — that are intended as political satire or strained humor."

Last month, Shkreli was found guilty on three out of eight federal charges for deceiving his investors of his hedge funds.

The Associated Press contributed to this report.