Write a piece
Write a two-section blog post for a web-shop support scenario through the API. Every step shows the expected result.
Before you start: an organization API key (see API keys) in the PRAXIS_API_KEY environment variable, plus curl and jq. Set PRAXIS_API_BASE to target another environment; the default is https://api.deepraxis.com. The work title below carries a docs-example prefix and a timestamp, so repeated runs never hit a taken slug.
1. Create the work
A work records the goal of the piece: the reader, what that reader should get, and the one-sentence message. All three are required.
export BASE="${PRAXIS_API_BASE:-https://api.deepraxis.com}"export TAG=$(date +%s)WORK_JSON=$(curl --fail-with-body -sS -X POST "$BASE/studio/v1/works" \ -H "Authorization: Bearer $PRAXIS_API_KEY" \ -H "Content-Type: application/json" \ -d "$(jq -n --arg title "docs-example-support-$TAG" '{title: $title, goal: {reader: "Shop owners who answer customer questions by hand", outcome: "Decide whether to put an AI agent on their support inbox", message: "An agent answers the routine questions so you can handle the exceptions."}}')")export WORK=$(printf '%s' "$WORK_JSON" | jq -er '.slug')printf '%s\n' "$WORK_JSON" | jq '{id, slug, revision, drafts}'Expected: HTTP 201, revision 0 and an empty drafts array. The slug is derived from the title and every later call uses it. If the slug is already taken in your organization the call returns 409 SLUG_TAKEN.
2. Create the draft
A draft is written in one genre, and the genre decides the unit kinds. The top kind of blog_article is section; read GET /studio/v1/genres/blog_article first for the kinds, properties and checks it allows. outline gives the unit structure in one call, and key is the draft’s name in later calls.
DRAFT_JSON=$(curl --fail-with-body -sS -X POST "$BASE/studio/v1/works/$WORK/drafts" \ -H "Authorization: Bearer $PRAXIS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"genre": "blog_article", "key": "post", "outline": [{"kind": "section", "name": "Problem", "synopsis": "The same shipping question, asked nine times a day."}, {"kind": "section", "name": "Answer", "synopsis": "What an agent takes over and what stays with you."}]}')printf '%s\n' "$DRAFT_JSON" | jq '.value | {id, key, genre, revision, units: [.units[] | {number, kind, name, status}]}'Expected: HTTP 201 with the answer shaped {value, checks, next}. value.units holds two units numbered 1 and 2, both with status outlined.
3. Read the to-dos
curl --fail-with-body -sS "$BASE/studio/v1/works/$WORK/drafts/post/status" \ -H "Authorization: Bearer $PRAXIS_API_KEY" | jq '{revision, todos: [.todos[] | {kind, number, text}]}'Expected: HTTP 200 with a prop_missing to-do (the draft’s title property is empty), two body_missing to-dos (each unit has an intent and no body) and one check_failed (the total length is too short). Each to-do’s call field names the SDK method to use.
4. Write the unit bodies
Writing a whole body requires the revision you just read; if someone changed the unit first, you get 409 REVISION_CONFLICT.
for N in 1 2; do REV=$(curl --fail-with-body -sS "$BASE/studio/v1/works/$WORK/units/$N" \ -H "Authorization: Bearer $PRAXIS_API_KEY" | jq -er '.revision') if [ "$N" = 1 ]; then TEXT='Last spring a customer asked the same shipping question for the ninth time in one day.
That is when we stopped answering by hand.'; else TEXT='An agent takes the routine questions: where is my order, what is your return window.
You keep the exceptions: damaged goods, refunds, anything a person should decide.'; fi curl --fail-with-body -sS -X PATCH "$BASE/studio/v1/works/$WORK/units/$N" \ -H "Authorization: Bearer $PRAXIS_API_KEY" \ -H "Content-Type: application/json" \ -d "$(jq -n --argjson rev "$REV" --arg body "$TEXT" '{expected_revision: $rev, body: $body}')" \ | jq '{unit: .value | {number, status, chars, revision}, checks: [.checks[] | {check, ok}]}'doneExpected: HTTP 200 each time, the unit’s status becomes drafted and its revision goes up by one. checks may include heading_present (the unit has no published subheading yet); it is a warning and does not block the next steps.
5. Export the full text
curl --fail-with-body -sS "$BASE/studio/v1/works/$WORK/drafts/post/export?format=markdown" \ -H "Authorization: Bearer $PRAXIS_API_KEY" | jq -r '.content'Expected: HTTP 200 and content holds the two units joined in order as Markdown; revision is the draft’s current revision. format is required: markdown keeps headings and block anchors, text drops all markup. Leaving it out returns 400 INVALID_PARAMS.
Do the same with the SDK
The official @deepraxis/sdk methods live under praxis.studio.*.
import { Praxis } from '@deepraxis/sdk';
const praxis = new Praxis({ apiKey: process.env.PRAXIS_API_KEY!, baseUrl: process.env.PRAXIS_API_BASE ?? 'https://api.deepraxis.com',});
const tag = Date.now().toString(36);
// 1. Create the workconst work = await praxis.studio.works.create({ body: { title: `docs-example-support-${tag}`, goal: { reader: 'Shop owners who answer customer questions by hand', outcome: 'Decide whether to put an AI agent on their support inbox', message: 'An agent answers the routine questions so you can handle the exceptions.', }, },});
// 2. Create the draftconst created = await praxis.studio.works.drafts.create({ path: { work: work.slug }, body: { genre: 'blog_article', key: 'post', outline: [ { kind: 'section', name: 'Problem', synopsis: 'The same shipping question, asked nine times a day.' }, { kind: 'section', name: 'Answer', synopsis: 'What an agent takes over and what stays with you.' }, ], },});console.log(created.value.units.map(u => `${u.number} ${u.name} ${u.status}`));
// 3. Read the to-dosconst status = await praxis.studio.works.drafts.status.list({ path: { work: work.slug, draft: 'post' } });console.log(status.todos.map(t => t.kind));
// 4. Write bodies with the revision you readfor (const [number, body] of [ ['1', 'Last spring a customer asked the same shipping question for the ninth time in one day.'], ['2', 'An agent takes the routine questions. You keep the exceptions.'],] as const) { const unit = await praxis.studio.works.units.retrieve({ path: { work: work.slug, unit: number } }); const written = await praxis.studio.works.units.update({ path: { work: work.slug, unit: number }, body: { expected_revision: unit.revision, body }, }); console.log(written.value.number, written.value.status, written.value.chars);}
// 5. Exportconst exported = await praxis.studio.works.drafts.retrieveExport({ path: { work: work.slug, draft: 'post' }, query: { format: 'markdown' },});console.log(exported.content);Clean up
A work cannot be deleted. Archiving removes it from the default list and keeps its data.
curl --fail-with-body -sS -X PATCH "$BASE/studio/v1/works/$WORK" \ -H "Authorization: Bearer $PRAXIS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"update_mask": ["archived"], "archived": true}' | jq '.value | {slug, archived}'Expected: HTTP 200 with archived true. List archived works with GET /studio/v1/works?archived=true; each page lists either archived or active works, never both.