← Case Study Generator
Your token

Case Study Generator API

Reading your notes, checking them and writing the case study HTML, the CSS, the Article JSON-LD and the stories-page card all run free in the browser and need no API. The API is for the one metered step: send your story split into numbered sentences (each with its section) and your numbered result lines, and get back, as JSON, the id of the sentence that should sit under the heading, the result ids to show big at the top, sentences that sit in the wrong section, and sentences to leave out with a reason word. The model never writes new text; the page checks every id and refuses any choice it cannot check.

Base URL: https://api.skillsafe.ai/v1/app-api. Every response is {"data": ...} or {"error": {"code", "message"}}; read error.code and error.message rather than the HTTP status alone.

The task field

This app has one task. Always send "task": "tighten".

taskWhat it doesReply
tightenPicks the story sentence for the line under the heading, up to three results to lead the page, sentences to move to another section, and sentences to leave out (empty claims, repeats, sales lines or contact details). It never writes new words.One JSON object

Input fields

All values are strings. task and parts are required.

FieldMeaning
task"tighten"
customerThe customer's name, or "".
productThe product or service they used, or "".
given"summary" when you wrote the line under the heading yourself (it is kept), otherwise "".
summaryYour own line under the heading, or "".
partsJSON text: the story in order as [{id, section, text, list?}], one sentence or list item each, ids like s3, section one of background, challenge, solution, results. At most 90 parts.
resultsJSON text: the result lines as [{id, figure, text}], ids like r2; figure may be empty. "[]" when there are none.
parts_noteEmpty, or a sentence saying what was cut.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence) with four keys: summary, one part id or ""; highlights, a list of 0 to 3 result ids, strongest first; move, a list of {id, to} where to is a section; and cut, a list of {id, why} where why is vague, repeat or off_topic. Before using it, check that every id is one you sent, that the summary is at most 35 words and not a list item, that a summary you wrote was not replaced, that each highlight has a figure, that no move or cut empties the challenge or solution, that a vague cut holds no number, and that at least 2 story sentences remain; the page does all of this and lists what it refused. If the balance ran low, truncated is true and the object may stop early; the page keeps every choice that arrived whole.

Worked example

Input (input.json), the software notes sample on the page:

{
  "task": "tighten",
  "customer": "Harbor Freight Co.",
  "product": "Ledgerline",
  "given": "",
  "summary": "",
  "parts": "[{\"id\":\"s1\",\"section\":\"background\",\"text\":\"Harbor Freight Co. moves containers between the Port of Tacoma and 60 warehouses across the Pacific Northwest.\"},{\"id\":\"s2\",\"section\":\"background\",\"text\":\"Its finance team of four handles about 9,000 carrier invoices a month.\"},{\"id\":\"s3\",\"section\":\"challenge\",\"text\":\"Every invoice was keyed into spreadsheets by hand and matched against delivery records one at a time.\"},{\"id\":\"s4\",\"section\":\"challenge\",\"text\":\"Month-end close took nine days, and the team worked most weekends in the last week of each month.\"},{\"id\":\"s5\",\"section\":\"challenge\",\"text\":\"Duplicate payments slipped through: an audit in 2025 found $41,000 paid twice.\"},{\"id\":\"s6\",\"section\":\"challenge\",\"text\":\"Harbor Freight is a world-class logistics company that deserves world-class tools.\"},{\"id\":\"s7\",\"section\":\"solution\",\"text\":\"In September 2025 Harbor Freight rolled out Ledgerline for invoice matching.\"},{\"id\":\"s8\",\"section\":\"solution\",\"text\":\"Controller Dana Ruiz ran the setup with one Ledgerline specialist, and the team connected its bank feeds and the warehouse system in three weeks.\"},{\"id\":\"s9\",\"section\":\"solution\",\"text\":\"Ledgerline now reads each carrier invoice, matches it to the delivery record and flags anything that does not line up.\"},{\"id\":\"s10\",\"section\":\"solution\",\"text\":\"Invoices are now matched 62% faster.\"},{\"id\":\"s11\",\"section\":\"solution\",\"text\":\"Book a demo today to see how Ledgerline can work for you.\"},{\"id\":\"s12\",\"section\":\"results\",\"text\":\"The team has not worked a month-end weekend since November.\"}]",
  "results": "[{\"id\":\"r1\",\"figure\":\"62%\",\"text\":\"faster invoice processing\"},{\"id\":\"r2\",\"figure\":\"9 days -> 4 days\",\"text\":\"Month-end close\"},{\"id\":\"r3\",\"figure\":\"$0\",\"text\":\"duplicate payments since go-live\"},{\"id\":\"r4\",\"figure\":\"3x\",\"text\":\"more invoices handled per person\"}]",
  "parts_note": ""
}

Reply:

{"summary":"s7","highlights":["r2","r3","r1"],"move":[{"id":"s10","to":"results"}],"cut":[{"id":"s6","why":"vague"},{"id":"s11","why":"off_topic"}]}

On the page, the chosen sentence moves under the heading, the month-end close, duplicate-payment and speed results lead the page in that order, the "62% faster" sentence moves from the solution to the results, and the empty claim and the sales line leave the story.

Errors

HTTPWhat to do
401The token is missing, expired or a guest token on a run. Get a personal token on the token page.
402The balance is below what the run reserves. Top up at skillsafe.ai/account/billing.
400The body is not a JSON object of the fields above.
429Wait and retry with the same Idempotency-Key.

Step 1 — a tiny client helper

One function that sends JSON and unwraps the {data, error} envelope.

BASE="https://api.skillsafe.ai/v1/app-api"
TOKEN="paste-your-token-here"   # from https://case-study-generator.skillsafe.ai/tokens.html
api() { # api METHOD PATH [JSON-BODY]
  curl -s -X "$1" "$BASE$2" -H "Content-Type: application/json" \
    ${TOKEN:+-H "Authorization: Bearer $TOKEN"} ${3:+--data "$3"}
}

Step 2 — a token

A guest token is enough for /me and /estimate. A run is metered, so it needs your personal token: sign in on the token page and copy it.

# a guest token (enough for /me and /estimate); a run needs your personal token from /tokens.html
TOKEN=$(curl -s -X POST "$BASE/guest" -H "Content-Type: application/json" -d '{"slug":"case-study-generator"}' | jq -r '.data.token')

Step 3 — who am I, and my balance

subject_type is guest or user; credits is the balance (1 credit = $0.0001).

api GET /me | jq '.data | {subject_type, credits}' 

Step 4 — price a run for free

/estimate charges nothing and starts no job. hold_credits is the amount reserved while a run is in flight, not the price; the run is charged what it uses.

# input.json: the run input object - {"task": "tighten", "customer": "...", "product": "...", "given": "", "summary": "", "parts": "[...]", "results": "[...]", "parts_note": ""}
api POST /estimate "$(cat input.json)" | jq '.data | {hold_credits, min_credits, model, model_alias, markup_bps, warnings}' 

Step 5 — run it and wait for the job

Send an Idempotency-Key derived from the input: a retry with the same key is never billed twice.

KEY="case-study-generator:tighten:$(shasum -a 256 input.json | cut -c1-16):a1"
JOB=$(curl -s -X POST "$BASE/run" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: $KEY" --data @input.json | jq -r '.data.job_id')
while :; do
  J=$(api GET "/jobs/$JOB"); S=$(echo "$J" | jq -r '.data.status')
  case "$S" in succeeded|failed|cancelled) break;; esac; sleep 2
done
echo "$J" | jq -r '.data.output.output' > reply.json   # one JSON object: summary, highlights, move, cut
echo "$J" | jq '.data | {charged_credits, truncated}' 

Step 6 — or stream it

/run-stream sends Server-Sent Events while the job runs and the finished job at the end.

# Server-Sent Events: tick/delta events while the job runs, then a final event with the job
curl -N -s -X POST "$BASE/run-stream" -H "Content-Type: application/json" -H "Authorization: Bearer $TOKEN" \
  -H "Idempotency-Key: case-study-generator:tighten:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json