Write Your First Entry Programmatically
Mint a management key and use the Atlas SDK to create and publish an entry from a script, CI job, or AI agent — no dashboard clicking required.
Write Your First Entry Programmatically
The Quickstart shows how to read published content. This guide shows the other half: writing content — creating and publishing an entry from code, using the Management API via the SDK's management client.
This is the workflow behind CI-driven content pipelines, migration scripts, and AI agents that draft and publish content on your behalf.
1. Mint a management key
Programmatic writes require a management key (atlas_mgmt_...), not the
delivery key (atlas_live_...) used for reads.
- Open the Atlas dashboard: https://cms.atlas.latellu.com
- Go to Settings → API Keys.
- Click New, choose the Management key type.
- Select scopes — for this walkthrough,
content:writeandcontent:publish. - Set an expiry and copy the key. It's shown only once.
export ATLAS_MGMT_KEY="atlas_mgmt_abc123xyz"See Management API authentication for the full scopes table and the RBAC/service-actor model — a management key acts as the user who created it, so it can never do more than that user could from the dashboard.
2. Install the SDK
pnpm add @latellu/atlas-sdk@^0.2.03. Create a management client
import { createManagementClient } from '@latellu/atlas-sdk/management';
export const atlasMgmt = createManagementClient({
url: 'https://api.atlas.latellu.com',
token: process.env.ATLAS_MGMT_KEY!,
});createManagementClient throws immediately if the token doesn't start with
atlas_mgmt_ — you'll know right away if you accidentally passed a delivery key.
4. Create and publish an entry
import { AtlasError } from '@latellu/atlas-sdk/management';
import { atlasMgmt } from '../src/atlas-mgmt';
async function main() {
try {
const entry = await atlasMgmt.entries('article').create(
{
slug: 'hello-world',
data: {
title: 'Hello, world',
body: 'My first entry, created without opening the dashboard.',
},
},
{ idempotencyKey: crypto.randomUUID() }
);
await atlasMgmt.entries('article').publish(entry.slug);
console.log(`Published: ${entry.slug}`);
} catch (err) {
if (err instanceof AtlasError) {
console.error(`Atlas write failed (${err.status} ${err.code}): ${err.message}`);
process.exit(1);
}
throw err;
}
}
main();npx tsx scripts/publish-first-post.ts
# Published: hello-world5. Verify in the dashboard
Open the entry in the Atlas dashboard. It appears exactly as if you'd created it by hand — same content type, same fields, same Published status — with one difference: its activity log attributes the create and publish actions to the user who owns the management key (the "service actor"), not to a script or bot user.
AI agents and retry safety
Because writes accept { idempotencyKey } and 429 responses are retried
automatically with backoff, an AI agent (or any automation) can safely re-run a
failed step without risking duplicate entries — send the same idempotencyKey on
a retry and Atlas returns the original result instead of creating a second entry.
See Idempotency in the SDK management guide.
Next steps
- SDK management guide — full entries/pages/media CRUD, lifecycle methods, and the Effect-native surface.
- Management API reference — every write endpoint, required scope, and error code.
- Management API authentication — scopes, key security, and the service-actor model.