A longtime spokesman for the state court system accidentally butt-dialed a Post reporter — yukking it up about how “I barely show up to work” while pocketing a $166,000-plus salary and boosting his taxpayer-funded pension.

After speaking by cellphone with the reporter about a planned exposé on his cushy schedule, David Bookstaver butt-dialed back, and unwittingly left a four-minute voicemail while chatting with at least two other people.

On the voicemail, Bookstaver admitted lying to The Post about how he spent his weekdays and confirmed the accounts of court-system sources who said he’s been working as few as two days a week.

“I spoke to [the reporter] on the record for awhile. I said, ‘I’m in a much less visible position; that doesn’t mean I’m not doing anything,’ ” Bookstaver said.

“But, frankly, look, the bottom line: the story’s true. I’m not doing anything. I barely show up to work and I’ve been caught.”

The remark promoted laughter, after which Bookstaver explained that he didn’t need to show up “because they took away all my responsibilities and left my pay.”

At one point, he lamented over having bragged about his ability to play hooky. “They left me alone and look, I have a big mouth. I told people I’m not doing much. I do take a lot of time off,” he said.

“I kind of asked for it. You know, if you have a big mouth, you know it catches up with you.”

Bookstaver, who’s planning to retire Oct. 1, also raised the possibility he could get fired “because of a story in The Post,” but said it “would probably affect my pension check by $6 a month.”

“Look, the bottom line is, I’ll suffer through a terribly embarrassing story and then go get my f–king pension and retire,” he said.

Click for more from The New York Post