← Newsletter Signup Form Generator
Your token

Newsletter Signup Form Generator API

Reading embed code or notes, checking the form and writing its HTML, CSS and script all run free in the browser and need no API. The API is for the one metered step: send the form's heading, promise line, incentive, button and fields by id, plus a description of the newsletter, and get back, as JSON, a heading that names the newsletter, a promise that says what people get (and how often, only when you said so), an incentive line only when you offer one, a clear button, and a label and error message for each field. The model only rewords; the page keeps every field, type and required mark, and refuses wording that adds a fact, a frequency, a gift or a promise you did not write.

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": "copy".

taskWhat it doesReply
copyRewrites a newsletter signup form's wording: heading, promise line, incentive, button, labels and error messages. It never adds, removes or reorders fields.One JSON object

Input fields

All values are strings. task and form are required.

FieldMeaning
task"copy"
aboutEmpty, or the visitor's description of the newsletter: who it is for, what is in it, how often it goes out, any gift for new subscribers. The page sends at most 900 characters; a longer description is cut in the middle, keeping the start and the end, with a marker.
formJSON text: {title, intro, bonus, button, fields}, where fields is a list of {id, label, type, required, options?} in order, ids like f2. Types: email, name, text, tel, url, date, select, radio, checkbox, consent. At most 8 fields.
form_noteEmpty, or a sentence saying how much of the description was cut.

The reply

job.output.output is text holding one JSON object (sometimes inside a ```json fence) with five keys: title, intro, bonus, button (strings; bonus may be empty) and fields, one {id, label, error} per field in input order. Before using it, check that every id is one you sent and that no new wording adds a number, name, frequency, gift or promise your text lacks; the page does this and lists what it refused. If the balance ran low, truncated is true and the object may stop early; the page keeps every entry that arrived whole.

Worked example

Input (input.json), the bike tips sample on the page (2 fields):

{
  "task": "copy",
  "about": "Short bike repair tips for people who ride to work. One tip a week, sent every Friday morning, with a photo of the fix.",
  "form": "{\"title\":\"The Friday Fix\",\"intro\":\"Bike repair tips for people who ride to work.\",\"bonus\":\"\",\"button\":\"Submit\",\"fields\":[{\"id\":\"f1\",\"label\":\"Email\",\"type\":\"email\",\"required\":true},{\"id\":\"f2\",\"label\":\"First name\",\"type\":\"name\",\"required\":false}]}",
  "form_note": ""
}

Reply:

{"title":"The Friday Fix","intro":"Short bike repair tips for people who ride to work: one tip a week, sent every Friday morning, with a photo of the fix.","bonus":"","button":"Send me the tips","fields":[{"id":"f1","label":"Email address","error":"Enter your email address"},{"id":"f2","label":"First name","error":"Enter your first name"}]}

On the page, the promise line gains "every Friday morning" (from the description), "Email" becomes "Email address", and the "Submit" button becomes "Send me the tips".

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://newsletter-signup-form.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":"newsletter-signup-form"}' | 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": "copy", "about": "", "form": "{...}", "form_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="newsletter-signup-form:copy:$(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: title, intro, bonus, button, fields
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: newsletter-signup-form:copy:$(shasum -a 256 input.json | cut -c1-16):a1" --data @input.json