
A social media calendar grows in friction daily. An API here, a status page there, a spreadsheet that only one person understands, and a copy edit that has to happen in three places. None of it is hard. All of it is repetitive.
A single repeatable script replaces the whole routine. Here is the smallest version that works, and the four things that break it.
The four-part minimum stack
Four pieces, and you can build them in an afternoon.
- A data file holding your posts: date, platform, text, link, image, status.
- A posting function that reads each due row and calls the platform API.
- A scheduled job that runs the function.
- An error log that captures what failed, so you find out from a file rather than from a client.
That is the whole design. Everything else is refinement, and most of the refinement is about the data file.
The data file is the part you will regret skipping
The data file is where people invest nothing and regret it for a year. Make it easy to edit by hand. A CSV is simpler than JSON for a human at midnight, and the human is the one who will actually be editing it.
Include a status column with explicit values: scheduled, posted, failed, skipped. Mark things clearly, so a future you, or someone else, can pick the file up without reading code.
Then build the posting function around the file's schema rather than the other way round. A good data file survives platform changes, tool upgrades and team handoffs, because it describes the intent in a form a non-programmer can read. If platform credentials live inside the function, the next person has to read code to change a password. If data and logic are separated, they edit the CSV and run the script.
One more thing: validate the file before posting. A missing image URL or an empty text column should stop that row with a clear message, not produce a half-formed post.
Never post twice
This is the failure that costs you a client, and it comes from a mundane cause. Your scheduled job runs, posts five rows, and fails on the sixth. You fix it and run the job again. Now the first five are posted twice.
The fix is idempotency: make the job safe to run repeatedly. Write the result back to the data file the moment a post succeeds, so a re-run skips it. Better still, keep a separate log keyed by post ID and check it before sending.
The same applies to retries. Retry the specific row that failed, never the batch, and give each row a stable identifier so you can tell whether it already went out. If the platform API supports one, send an idempotency key.
Timezones will bite you
Pick one timezone for the data file and write it down. If your scheduled runs are in UTC and your schedule was written in local time, posts land an hour or five hours off, and the error only shows up when someone notices a 3am post.
Store the timestamp with its offset rather than as a bare local time. Then convert once, at the point of sending.
A second trap: the scheduler will not run exactly when you told it. Cron jobs run late under load, and hosted schedulers have their own drift. So the job should ask "what is due now or earlier?" rather than "what is due at exactly this minute?" That one-word change is what stops a delayed run from silently skipping a post.
Failures should be visible, not silent
The error log is only useful if something reads it. Have the job message you when a row fails, and add a summary line for the run: how many rows posted, how many failed, how many were skipped.
Watch for the difference between a crash and a plausible wrong result. A job that posts nothing and exits cleanly looks identical to a day with nothing scheduled. If a run posts zero rows when the file says three were due, that is a failure and should be treated as one.
Handle rate limits explicitly. Most platforms will throttle a batch, and the right response is to back off and retry later rather than to hammer the endpoint or to drop the row.
Keep credentials out of the code
Tokens belong in environment variables or a secret store, never in the script and never in the data file. Platform access tokens get rotated, revoked and scoped, and you want that to be a configuration change rather than a code change.
This also makes the script shareable. A version with no secrets in it can be committed, reviewed and handed to someone else, and reviewed means the failure modes get caught before they reach production.
Separate approval from delivery
The most useful version of this system does not publish things on its own authority. It delivers things you approved.
So keep the queue as the approval step. You write the post, you set its status, and the script only ever touches rows marked as approved and due. That keeps the judgement with you and the repetition with the machine, which is the whole point of the arrangement. It also means an error in the script produces nothing at all, rather than something embarrassing.
If the text itself comes from an assistant, the constraints in keeping it in your brand voice apply to the queue as much as to anything else you publish.
When to expand
Only after one platform is reliable should you add a second. A handful of dependable automations beats a system that half-works.
Keep each platform's outputs in separate files, so a failure in one job cannot corrupt another. And keep the same discipline that got you here, described in starting with one manual workflow: run it by hand, compare, then schedule. If the queue is feeding a reporting loop, the same counting discipline from automating affiliate reports applies to the run summary.
Obligatory VPN mention: Every marketing newsletter pitches one eventually. We put ours in a dedicated piece so you can skip it on your own schedule. It is actually useful for affiliate work →