I was publishing a post to X through DotShare when I noticed that X now needs prepaid credits for every post. That's how X's API works now: pay per use, with credits bought in advance. The obvious question followed. Every DotShare user who signs in to X goes through my X app. Whose credits pay for their posts?
Mine. That one question turned into DotShare 3.8.0 and dotshare-cli 3.2.0: X posts now go through DotSuite, each plan includes a monthly X budget, and every post is charged what it actually cost. On the way there, writing a privacy policy found three things in DotShare that didn't do what the README said they did.
This follows the 3.7 post, where sign-in moved to dotsuite.dev.
What X's terms allow
Before writing any code I read X's developer agreement, the pay-per-use agreement and the developer policy. Three things shaped the design.
The app owner pays. Credits are bought in the Developer Console and deducted "from your account based on your usage". The terms don't spell out who pays for a post a user authorized through your app. But the user isn't a party to the agreement, and the credits are yours, so that leaves you.
You can't resell credits. They are non-transferable and non-refundable. "Buy X credits from me" was never an option. "Your plan includes this much X usage" is a different thing: that's selling my own service.
You can't spread the load across apps. The policy is direct: "You may not register multiple applications for a single use case." I had wondered about running two or three X apps to split the traffic. That's out. The way to scale is X's Enterprise plan.
At X's current list prices, a post costs $0.015 and a post containing a link costs $0.200, about thirteen times more. For a tool that announces releases, links are the whole point.
The rule: never under-charge
Update since 3.8.1: DotSuite now holds the most a post can cost, then charges exactly what X deducted and releases the rest, and previews say "up to $X will be held". The first real thread showed that the rule below charged five times what X took. The next post covers the change.
A price mistake only hurts in one direction. If a post costs 20 cents and I charge 25, nobody notices. If it costs 10 and I charge 5, I pay the difference on every post. So every decision leans toward charging slightly more rather than less.
Integer micro-dollars. Every amount is an integer number of millionths of a dollar. Nothing gets lost to floating-point rounding, and a ledger total matches the budget to the micro-dollar.
Assume it's a link. X auto-links bare domains, so dotsuite.dev costs the same as https://dotsuite.dev. My detector treats any name.tld token as a link. That means README.md is charged as a link too, because .md is a real top-level domain and X really might link it. Overcharging a filename is the cheaper mistake.
Measure what X actually took. The price table is an estimate, and X can change its prices. So DotSuite reads its own X credit balance right before and right after each post, and charges the user the larger of the estimate and the difference:
// Never charge less than X took or than the price table says.
let charged = plan.estimated.max(seen.unwrap_or(0));
That only works if each balance change belongs to exactly one post. So X posts across all DotSuite servers go out one at a time, under a PostgreSQL advisory lock scoped to a transaction. The lock releases however the function exits, including an early error return. I'd written it as a session lock first, and an error path would have left it held on a pooled connection forever.
A balance change is only trusted when it's plausible: a top-up between the two readings, or a drop of more than a dollar from something unrelated, is ignored rather than billed. Every post's estimate, the amount X actually took, and the charge are all recorded. An admin report compares them per day. If X ever charges more than the table says, it shows up there, and the fix is an environment variable.
Reserve first, then post
Nothing reaches X without a reservation. One PostgreSQL transaction checks the monthly budget, the user's daily post limit and an app-wide daily spend cap, then reserves the whole request:
UPDATE x_budget_months SET reserved_micros = reserved_micros + $3
WHERE user_id = $1 AND month = $2
AND spent_micros + reserved_micros + $3 <= budget_micros
RETURNING 1
The condition lives in the UPDATE, so concurrent requests can't both pass a check and then both spend. To prove it, a test fires ten simultaneous 20-cent requests at a user with 77 cents left, on a real PostgreSQL running in Docker. Exactly three succeed.
After posting, each part of a thread settles to one of three outcomes:
- Published: charged as described above.
- Rejected by X: nothing was posted, so it's free, apart from images X had already accepted. The remaining parts of the thread aren't sent.
- No answer from X: X may have published it, so it's charged and never resent automatically. Retrying could post it twice.
Every request has an idempotency key, so repeating it returns the recorded outcome without posting or charging again. A reservation orphaned by a crash is settled after 30 minutes as "uncertain", charged, and never resent.
Writing this exposed an older bug. When a scheduled post failed on one platform, the scheduler retried the whole post, X included. One flaky Mastodon instance could have posted the same thing to X twice. X now has its own ledger entry per scheduled post, and a retry never sends it again.
Closing the leak
Metering is useless if tokens can post without it. Until 3.8, signing in to X put an access token and a refresh token on the user's machine, and nothing stopped that token from posting directly.
Two changes closed it:
- X became a confidential client. Refreshing a token now needs the app's client secret, which lives only on DotSuite's servers. Tokens already in the wild expire within two hours and can't be renewed.
-
Tokens stay on the server. With
X_SERVER_ONLYon, an X sign-in is saved to the user's DotSuite account. The editor or CLI is only told that X is connected, and X posts go throughPOST /v1/x/posts. The old refresh endpoint returns410 Gone.
There was a cost. DotShare 3.7, which had shipped hours earlier, can't post to X until it's updated. I accepted that, rather than leave a window where anyone with a token could post on my balance.
People who would rather pay X directly can still do that. The CLI accepts an access token from their own X developer app, and then DotSuite isn't involved at all.
Showing the cost
A budget only feels fair if you can see it. Before a post goes out, an agent's preview now says exactly what it will cost:
x-cloud: X will charge $0.215 for 2 post(s), 1 with a link; $4.785 of this month's X budget will be left.
A post the budget can't cover is refused before anything is sent. The extension shows the charge and what's left after each post. The DotSuite dashboard lists recent charges in three columns: the estimate, what X actually deducted, and what you paid. The defaults are $1 a month on Free (roughly 66 text posts, or 5 with links), $5 on Pro and $15 on Max. All of them, and the prices, are environment variables.
The privacy policy found three bugs
LinkedIn and X want a privacy policy URL, so DotShare got its own page. I wrote every sentence against the code rather than from memory, and three sentences turned out to be false.
- "Clear All Credentials" didn't exist. The README mentioned it, and the cleanup function existed, but no button or command called it. It's now a button in Settings and a command, behind a native confirmation, so a webview message alone can't trigger it.
-
The live CodeSnap link pointed at a domain that never existed. "Copy Dynamic CodeSnap Markdown" produced
codesnap.dotsuite.devlinks, which didn't resolve. DotSuite now draws a gist as a syntax-highlighted image at/api/codesnap/gist/{id}, and refreshes it within ten minutes of an edit. - Deleting your DotSuite account left your data behind. It removed the account record and nothing else: connected platform tokens, scheduled posts and their images, API keys and licence data all stayed. Now Core deletes all of it first, including the images in object storage. If any of that fails, the account is kept so the user can retry, instead of leaving data no account can reach. The dashboard also gained a Disconnect button for every connected platform.
The policy is fully written in English, Arabic, German, French and Russian. It has a section on X costs that says what's recorded for each post: the time, whether it counted as a link post, the image count, the estimate, the measured cost, the charge and the post ID. Post text isn't recorded.
How it was tested
- Core: 58 tests. With a test database configured, two more run against real PostgreSQL in Docker. One covers reservations, limits, concurrency, settlement and deletion. The other runs the full publish flow against a mock X API built from axum: chained thread replies, a replay that posts nothing, an X overcharge billed at the real amount, a rejection mid-thread, and a request that times out.
- DotShare: 405 Jest tests, plus the end-to-end MCP, library and security scripts.
-
Live: real LinkedIn and X sign-ins through dotsuite.dev, a real X token refresh with rotation, and the switch-over confirmed on production with the refresh endpoint returning
410.
What I haven't seen yet is a month of real usage. The admin report comparing charged and measured costs is the first thing I'll check.
Try it
DotShare 3.8.0 is on the Marketplace and Open VSX, and the CLI is on npm:
npm install -g dotshare-cli
dotshare-agent cloud login
dotshare-agent accounts connect my-x --platform x
The changelog, the agent guide and the privacy policy have the details.
I used AI assistance (Claude) to build, test and write up this release. The numbers and behavior described come from the shipped code and its tests.



Top comments (0)