Copy-paste walkthroughs for every job type. Replace $KEY with your API key; responses are real codexdev outputs, trimmed.
Upload and pre-analyze a source
Every job starts from a source. Uploading is free: the server counts characters, detects the source language and checks input quality, then keeps the staged file for 7 days so you can quote and run several jobs on it without uploading again.
1. Upload a file and wait up to 30 seconds
Supported formats: .txt, .epub, .docx (≤ 50 MiB). `?wait=30` holds the request until analysis finishes (201) or the wait expires (202, status `analyzing`). `target_language` is optional and does not affect the analysis.
curl -X POST "https://xsfyj.com/api/b2b/v1/sources?wait=30" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-F "[email protected]" \
-F "target_language=en"
{
"id": "src_0mvri8g568XfrxRhqf6Az4C",
"object": "source",
"status": "ready",
"filename": "novel.epub",
"format": "epub",
"size_bytes": 2794,
"sha256": "74ce50caa62b3d258611dbd62d5a71ac6ad3044528b5ea97e3b2b829817bd1fd",
"characters": 328,
"words": null,
"detected_language": { "code": "zh-CN", "confidence": 0.8333, "low_confidence": false },
"input_quality": null,
"error": null,
"expires_at": "2026-11-04T02:37:55Z",
"created_at": "2026-10-28T02:37:56Z"
}
2. Or send plain text as JSON
Without `wait` the call returns 202 immediately while the source is `analyzing`. `filename` is optional; `.txt` is appended when missing. Text sources are limited to 2,000,000 characters.
curl -X POST "https://xsfyj.com/api/b2b/v1/sources" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"text": "第一章 雾港\n\n雾港的钟声在黄昏时响了七下……", "filename": "chapter-01.txt"}'
{
"id": "src_0mvri8s1fNYJdJ4MDpr8QxB",
"object": "source",
"status": "analyzing",
"filename": "chapter-01.txt",
"format": "txt",
"size_bytes": 974,
"sha256": null,
"characters": null,
"words": null,
"detected_language": null,
"input_quality": null,
"error": null,
"expires_at": null,
"created_at": "2026-10-28T02:38:11Z"
}
3. Poll the source until it is ready
GET also accepts `?wait=` (max 30 s). Final states are `ready` or `failed` (see `error.code`, e.g. NO_TRANSLATABLE_CONTENT). `words` is only filled for space-delimited languages — an English source returns e.g. `"words": 41`.
curl "https://xsfyj.com/api/b2b/v1/sources/src_0mvri8s1fNYJdJ4MDpr8QxB?wait=20" \
-H "Authorization: Bearer $KEY"
{
"id": "src_0mvri8s1fNYJdJ4MDpr8QxB",
"object": "source",
"status": "ready",
"filename": "chapter-01.txt",
"format": "txt",
"size_bytes": 974,
"sha256": "9aeb9b5e0433de21778daf2b3bdae694cdf0c0fc320733b085b7ac0a6208b66d",
"characters": 321,
"words": null,
"detected_language": { "code": "zh-CN", "confidence": 0.8333, "low_confidence": false },
"input_quality": null,
"error": null,
"expires_at": "2026-11-04T02:38:11Z",
"created_at": "2026-10-28T02:38:11Z"
}
- Reuse the same source_id for quotes and jobs until expires_at (7 days); upload again only after it expires (SOURCE_EXPIRED).
- `characters` is the authoritative count used for billing — quote and charge are computed from it, not from your local count.
- Creating a job on an `analyzing` source returns SOURCE_NOT_READY with Retry-After: 2.
Quote several jobs at once
A quote prices up to 4 jobs on one source and shows your balance. It reserves nothing and is valid for 30 minutes. Rules: translation = 1 credit per character of the selected scope; a custom style guide adds 30% of the full text (waived on Plus); glossary = 0.5 credit/char; worldview = 0.1 credit/char; preview_translation is free (10 per day, ≤ 10,000 characters).
1. Quote glossary + translation (first half, with style guide) + worldview
Top-level `options` / `glossary` apply to every job; per-job values override them. Here the translation covers 0–50% (164 of 328 chars) but the style-guide surcharge is computed on the full text: ceil(328 × 0.3) = 99.
curl -X POST "https://xsfyj.com/api/b2b/v1/quotes" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"source_id": "src_0mvri8g568XfrxRhqf6Az4C",
"source_language": "zh",
"target_language": "en",
"jobs": [
{ "type": "glossary" },
{ "type": "translation", "options": {
"style_guide": "Keep a restrained literary tone; romanize names in pinyin.",
"scope": { "start_percent": 0, "end_percent": 50 } } },
{ "type": "worldview" }
]
}'
{
"id": "quo_0mvri9ezlgx1T4CTCRglnh1",
"object": "quote",
"source_id": "src_0mvri8g568XfrxRhqf6Az4C",
"target_language": "en",
"items": [
{ "type": "glossary", "characters": 328, "credits": 164,
"breakdown": { "base_credits": 164, "style_guide_credits": 0, "style_guide_waived": false, "scope": null } },
{ "type": "translation", "characters": 164, "credits": 263,
"breakdown": { "base_credits": 164, "style_guide_credits": 99, "style_guide_waived": false,
"scope": { "start": 0, "end_exclusive": 164 } } },
{ "type": "worldview", "characters": 328, "credits": 33,
"breakdown": { "base_credits": 33, "style_guide_credits": 0, "style_guide_waived": false, "scope": null } }
],
"total_credits": 460,
"balance": 199521,
"sufficient": true,
"warnings": [],
"expires_at": "2026-10-28T03:08:41Z",
"created_at": "2026-10-28T02:38:41Z"
}
2. Lock the price with quote_id
Pass `quote_id` when creating a job. If the job's price differs from the matching quote item (different options, expired quote, other source), the job is rejected instead of charging an unexpected amount — here the style guide was dropped:
curl -X POST "https://xsfyj.com/api/b2b/v1/jobs" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"type": "translation", "source_id": "src_0mvri8g568XfrxRhqf6Az4C", "source_language": "zh",
"target_language": "en", "quote_id": "quo_0mvri9ezlgx1T4CTCRglnh1",
"options": {"scope": {"start_percent": 0, "end_percent": 50}}}'
HTTP/1.1 409 Conflict
Content-Type: application/problem+json
{
"type": "…/api-docs#error-QUOTE_EXPIRED_OR_CHANGED",
"title": "Quote expired or changed",
"status": 409,
"code": "QUOTE_EXPIRED_OR_CHANGED",
"detail": "The price changed since the quote; create a new quote.",
"param": "quote_id",
"request_id": "req_0mvribqvn2vUvxz5TCEPeuo",
"doc_url": "…/api-docs#error-QUOTE_EXPIRED_OR_CHANGED",
"meta": { "quoted_credits": 263, "current_credits": 164 }
}
- Quotes are free and need no Idempotency-Key; create a fresh one whenever options change.
- Check `sufficient` before creating jobs — a job is charged (held) when it is created and settled when it finishes.
- `warnings` contains SOURCE_LANGUAGE_MISMATCH when the declared source_language differs from detection (see below).
Extract a worldview and reuse it
A worldview job reads the whole source and writes a translator's brief: genre, setting, register, narrator identity, key names and terminology guidance. It costs 0.1 credit per character of the full text. Inject the result into later translation jobs (other volumes, re-translations) to keep names and tone consistent without paying for extraction again.
1. Create the worldview job
`target_language` is the language the brief's references are written for. The response is 202 with status `queued`; credits are held now and consumed on success.
curl -X POST "https://xsfyj.com/api/b2b/v1/jobs" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"type": "worldview",
"source_id": "src_0mvri8g568XfrxRhqf6Az4C",
"source_language": "zh",
"target_language": "en",
"quote_id": "quo_0mvri9ezlgx1T4CTCRglnh1"
}'
{
"id": "job_0mvriardeM8hGujFyWfbGY0",
"object": "job",
"type": "worldview",
"status": "queued",
"source_id": "src_0mvri8g568XfrxRhqf6Az4C",
"series_id": null,
"target_language": "en",
"source_language": "zh-CN",
"options": { "output_format": "translation_only", "translate_filename": false },
"glossary": null,
"credits": 33,
"billing_state": "held",
"progress": { "stage": null, "percent": 0, "waiting_reason": null },
"result": null,
"error": null,
"poll_after_seconds": 5,
"created_at": "2026-10-28T02:39:44Z",
"completed_at": null
}
2. Poll the job
Status moves queued → running → succeeded (or failed / cancelled). Wait `poll_after_seconds` between polls; it becomes null in a final state. `progress.stage` is a stable machine value and `progress.percent` runs 0–100. A running job looks like this:
curl "https://xsfyj.com/api/b2b/v1/jobs/job_0mvriardeM8hGujFyWfbGY0" \
-H "Authorization: Bearer $KEY"
{
"id": "job_0mvriardeM8hGujFyWfbGY0",
"object": "job",
"type": "worldview",
"status": "running",
"credits": 33,
"billing_state": "held",
"progress": { "stage": "LANGUAGE_DETECT", "percent": 22, "waiting_reason": null },
"result": null,
"error": null,
"poll_after_seconds": 10,
"…": "…"
}
// succeeded
{
"id": "job_0mvriardeM8hGujFyWfbGY0",
"object": "job",
"type": "worldview",
"status": "succeeded",
"credits": 33,
"billing_state": "consumed",
"progress": { "stage": "COMPLETE", "percent": 100, "waiting_reason": null },
"result": { "worldview": "Source Title: 雾港\nKnown Target Title: Fog Port (uncertain; Low)\n…" },
"error": null,
"poll_after_seconds": null,
"created_at": "2026-10-28T02:39:44Z",
"completed_at": "2026-10-28T02:39:57Z"
}
3. Fetch the worldview
The brief is plain text — store it on your side, show it to an editor, or edit it before reuse. To get a translated book title as the output filename, set `options.translate_filename: true` on the translation job.
curl "https://xsfyj.com/api/b2b/v1/jobs/job_0mvriardeM8hGujFyWfbGY0/worldview" \
-H "Authorization: Bearer $KEY"
{
"job_id": "job_0mvriardeM8hGujFyWfbGY0",
"object": "worldview_result",
"worldview": "Source Title: 雾港\nKnown Target Title: Fog Port (uncertain; Low)\nNarrative Identity:\n- Default narrator: identity: impersonal, scope: whole_book\n…\nGenre: Fantasy / Adventure / Mystery\nEra/Setting: Ancient China-like\nRegister: period-flavored\nTone: melancholic, atmospheric, journey-focused\n…\nTranslation References:\n- 雾港 -> Fog Port (work_title; Medium; common web usage)\n Alternatives: Mist Port, Mist Harbor\n- 北境 -> the North (core_concept; High; common web usage)\n…\nRisk Notes: The text is very short; …"
}
4. Reuse it in a translation job
Pass the text (≤ 20,000 characters) as `options.worldview`. The job uses your brief as translation context; the price stays 1 credit per character of the selected scope — here 0–50% of 328 characters = 164 credits.
WORLDVIEW=$(curl -s "https://xsfyj.com/api/b2b/v1/jobs/job_0mvriardeM8hGujFyWfbGY0/worldview" \
-H "Authorization: Bearer $KEY" | jq -r .worldview)
curl -X POST "https://xsfyj.com/api/b2b/v1/jobs" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg wv "$WORLDVIEW" '{
type: "translation",
source_id: "src_0mvri8g568XfrxRhqf6Az4C",
source_language: "zh",
target_language: "en",
options: { scope: { start_percent: 0, end_percent: 50 }, worldview: $wv }
}')"
{
"id": "job_0mvribx53EiHALikS1yvzb8",
"object": "job",
"type": "translation",
"status": "queued",
"source_id": "src_0mvri8g568XfrxRhqf6Az4C",
"target_language": "en",
"source_language": "zh-CN",
"options": {
"scope": { "end_percent": 50, "start_percent": 0 },
"worldview": { "injected": true, "characters": 1834 },
"output_format": "translation_only",
"translate_filename": false
},
"glossary": null,
"credits": 164,
"billing_state": "held",
"poll_after_seconds": 5,
"…": "…"
}
// succeeded → result.files
"result": {
"files": [
{ "kind": "translated", "file_id": "NVMVRIBXC64Y_output_cfd974b74bfb4448",
"filename": "novel.range-0-50_translated.epub", "size_bytes": 3028 }
]
}
- Extract once per book (or per series) and reuse: a worldview costs 0.1 credit/char, so a 300,000-character novel costs 30,000 credits.
- Edit the brief freely before injecting it — fix a name in “Translation References” and every later job follows it. Pair it with a glossary for hard term locks.
- Job responses only echo the length of an injected worldview ({ injected, characters }), never the text itself.
- Series (/series) store and inject the worldview automatically across volumes; use options.worldview for one-off jobs.
Versioned glossary resources
A glossary resource (`gls_…`) stores your approved terms. Every edit creates a new immutable version, and a translation job pins the exact version it used, so re-running a job is reproducible. Create one from a glossary job, from a CSV file, or from inline `terms`.
1. Create a glossary from a glossary job
Terms copied from the job become `authority: locked` (user-approved). The version-specific `origin` records where the version came from.
curl -X POST "https://xsfyj.com/api/b2b/v1/glossaries" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"name": "Qingyun Saga", "from_job_id": "job_0mvri97fqVgsuxDwMqNrsCz"}'
{
"id": "gls_0mvriazvx5MpABdP6aMqf95",
"object": "glossary",
"name": "Qingyun Saga",
"version": 1,
"current_version": 1,
"term_count": 15,
"terms": [
{ "source": "林逸", "target": "Lin Yi", "category": "person_name", "gender": null, "note": "Protagonist of the story…", "count": 4, "authority": "locked" },
"…"
],
"origin": { "kind": "job", "job_id": "job_0mvri97fqVgsuxDwMqNrsCz" },
"created_at": "2026-10-28T02:39:55Z",
"version_created_at": "2026-10-28T02:39:55Z"
}
2. Edit terms with optimistic locking
`upsert` replaces a term with the same `source` (or adds it); `remove` deletes by `source`. Send the version you edited in `If-Match`; the response carries the new version in the body and in `ETag`.
curl -X PATCH "https://xsfyj.com/api/b2b/v1/glossaries/gls_0mvriazvx5MpABdP6aMqf95" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'If-Match: "1"' \
-H "Content-Type: application/json" \
-d '{
"upsert": [
{"source": "林逸", "target": "Lin Yi", "category": "person_name", "gender": "male", "note": "Protagonist"},
{"source": "青云宗", "target": "Azure Cloud Sect", "category": "proper_noun"}
],
"remove": ["第一章 青云入门", "长老"]
}'
HTTP/1.1 200 OK
ETag: "2"
{
"id": "gls_0mvriazvx5MpABdP6aMqf95",
"object": "glossary",
"version": 2,
"current_version": 2,
"term_count": 13,
"terms": [
{ "authority": "locked", "source": "林逸", "target": "Lin Yi", "category": "person_name", "gender": "male", "note": "Protagonist" },
"…"
],
"origin": { "kind": "patch" },
"version_created_at": "2026-10-28T02:40:09Z"
}
3. Stale version → 409 VERSION_CONFLICT
If someone else saved a newer version, re-read the glossary (`GET /glossaries/{id}`), re-apply your change and retry with the current version.
curl -X PATCH "https://xsfyj.com/api/b2b/v1/glossaries/gls_0mvriazvx5MpABdP6aMqf95" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'If-Match: "1"' \
-H "Content-Type: application/json" \
-d '{"remove": ["魔道"]}'
{
"type": "https://novotranslator.com/api-docs#error-VERSION_CONFLICT",
"title": "Version conflict",
"status": 409,
"code": "VERSION_CONFLICT",
"detail": "Glossary gls_0mvriazvx5MpABdP6aMqf95 changed; current version is 2.",
"param": null,
"request_id": "req_0mvribltqYesRZapdb2q2Yz",
"meta": { "current_version": 2 }
}
4. Export as CSV
Returns JSON with the CSV text in `csv` (same columns as the web glossary workbench). Add `version=1` to export an older version. Save it with `jq -r .csv > terms.csv`.
curl "https://xsfyj.com/api/b2b/v1/glossaries/gls_0mvriazvx5MpABdP6aMqf95/export?format=csv" \
-H "Authorization: Bearer $KEY" | jq -r .csv > terms.csv
{
"object": "glossary_export",
"format": "csv",
"version": 2,
"csv": "term,translation,category,gender,note,authority\n林逸,Lin Yi,person_name,male,Protagonist,locked\n苏清寒,Su Qinghan,person_name,female,Senior disciple of the sect leader…,locked\n…"
}
5. Import a CSV file
multipart/form-data with `file` and `name`. Required columns: `term`, `translation`; optional `category`, `note`. Imported terms are `locked`.
# terms.csv
# term,translation,category,note
# 林逸,Lin Yi,person_name,Protagonist
# 苏清寒,Su Qinghan,person_name,"Senior sister, cold tone"
# 青云宗,Azure Cloud Sect,proper_noun,
# 血煞门,Blood Fiend Sect,proper_noun,Demonic sect
# 太玄剑诀,Taixuan Sword Art,work_title,
curl -X POST "https://xsfyj.com/api/b2b/v1/glossaries" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-F "[email protected];type=text/csv" \
-F "name=Publisher glossary"
{
"id": "gls_0mvric0k0kq6EjO0gxRkPrD",
"object": "glossary",
"name": "Publisher glossary",
"version": 1,
"current_version": 1,
"term_count": 5,
"terms": [
{ "source": "林逸", "target": "Lin Yi", "category": "person_name", "note": "Protagonist", "authority": "locked" },
{ "source": "苏清寒", "target": "Su Qinghan", "category": "person_name", "note": "Senior sister, cold tone", "authority": "locked" },
{ "source": "青云宗", "target": "Azure Cloud Sect", "category": "proper_noun", "authority": "locked" },
"…"
],
"origin": { "kind": "csv", "filename": "terms.csv" },
"version_created_at": "2026-10-28T02:40:42Z"
}
- Fetch any older version with `GET /glossaries/{id}?version=1`; the `ETag` header always carries the returned version.
- Duplicate `source` entries are collapsed: the last one wins. A glossary holds up to 5,000 terms.
- Creating and editing glossaries is free; you only pay for the jobs that use them.
Translate a source with options
A translation job costs 1 credit per character in the selected scope. A custom `style_guide` (≤ 500 characters) adds 30% of the full source's character count, waived for Plus members. Quote first (free, valid 30 minutes), then create the job with the same parameters plus `quote_id`: the server re-prices and rejects the job with `QUOTE_EXPIRED_OR_CHANGED` if the price moved.
1. Quote the job
Translating the first half (200 of 399 characters) costs 200 credits; the style guide adds ceil(399 × 0.3) = 120.
curl -X POST "https://xsfyj.com/api/b2b/v1/quotes" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"source_id": "src_0mvri8vl8f7PDVEwlqpkm5B",
"target_language": "en",
"options": {
"output_format": "original_above",
"style_guide": "Keep a light, modern tone. Use pinyin for names; do not translate sect names literally unless the glossary says so.",
"scope": {"start_percent": 0, "end_percent": 50},
"translate_filename": true,
"retention_days": 30
},
"jobs": [{"type": "translation"}]
}'
{
"id": "quo_0mvricmlthSrwls5txr5Kro",
"object": "quote",
"source_id": "src_0mvri8vl8f7PDVEwlqpkm5B",
"target_language": "en",
"items": [{
"type": "translation", "characters": 200, "credits": 320,
"breakdown": { "base_credits": 200, "style_guide_credits": 120, "style_guide_waived": false,
"scope": { "start": 0, "end_exclusive": 200 } }
}],
"total_credits": 320,
"balance": 199085,
"sufficient": true,
"warnings": [],
"expires_at": "2026-10-28T03:11:11Z",
"created_at": "2026-10-28T02:41:11Z"
}
2. Create the job with the quote
`output_format`: `translation_only` (default), `original_above` (bilingual, original paragraph first) or `translation_above`. `translate_filename` also translates the output file name. `retention_days` can shorten (not extend) how long files are kept: 90 days by default, 180 for Plus.
curl -X POST "https://xsfyj.com/api/b2b/v1/jobs" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"quote_id": "quo_0mvricmlthSrwls5txr5Kro",
"type": "translation",
"source_id": "src_0mvri8vl8f7PDVEwlqpkm5B",
"target_language": "en",
"options": { …same options as the quote… }
}'
{
"id": "job_0mvrid2ce1Vv9nvcqbyUkw8",
"object": "job",
"type": "translation",
"status": "queued",
"source_id": "src_0mvri8vl8f7PDVEwlqpkm5B",
"target_language": "en",
"options": {
"scope": { "end_percent": 50, "start_percent": 0 },
"style_guide": "Keep a light, modern tone. …",
"output_format": "original_above",
"retention_days": 30,
"translate_filename": true
},
"glossary": null,
"credits": 320,
"billing_state": "held",
"progress": { "stage": null, "percent": 0, "waiting_reason": null },
"result": null,
"error": null,
"poll_after_seconds": 5,
"created_at": "2026-10-28T02:41:31Z"
}
3. Poll until succeeded
Wait `poll_after_seconds` between polls. `status` goes `queued` → `running` (with `progress.stage` / `percent`) → `succeeded` | `failed` | `cancelled`. On success `billing_state` becomes `consumed` and `result.files` lists the outputs.
curl "https://xsfyj.com/api/b2b/v1/jobs/job_0mvrid2ce1Vv9nvcqbyUkw8" \
-H "Authorization: Bearer $KEY"
{
"id": "job_0mvrid2ce1Vv9nvcqbyUkw8",
"object": "job",
"status": "succeeded",
"credits": 320,
"billing_state": "consumed",
"progress": { "stage": "COMPLETE", "percent": 100, "waiting_reason": null },
"result": {
"files": [{ "kind": "translated", "file_id": "NVMVRID2O4ZS_output_ec08cf5334ea43c9",
"filename": "Chapter 1 Entering Qingyun (chapter-1).range-0-50_bilingual.txt", "size_bytes": 1983 }]
},
"poll_after_seconds": null,
"completed_at": "2026-10-28T02:42:32Z",
"…": "…"
}
- A quote is a price check, not a reservation: credits are held only when the job is created.
- If the quote carries a `SOURCE_LANGUAGE_MISMATCH` warning, add `"confirm_source_language": true` to the job, otherwise it fails with 409 `SOURCE_LANGUAGE_CONFIRMATION_REQUIRED`.
- Jobs beyond your account's concurrent limit wait in `queued`; that is normal and the job starts automatically.
Translate a multi-volume series
A series keeps one worldview and one growing glossary for all volumes, so names and tone stay consistent from volume 1 to volume N. Flow: create the series → add volumes → bootstrap on the anchor volume (worldview 0.1 + glossary 0.5 credit per character of that volume) → for each later volume, optionally extract new terms (0.5 credit/char of that volume) and review them → translate the volume (1 credit/char, +30% when the series has a style_guide). Each job freezes the glossary version it used.
1. Create the series
`glossary_mode` decides how the series glossary is applied when translating: `merge` (default) lets the engine add terms it finds, `strict` only uses your glossary. `style_guide` (≤ 500 chars) and `output_format` apply to every volume translation.
curl -X POST "https://xsfyj.com/api/b2b/v1/series" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"name": "Azure Cloud Sect",
"source_language": "zh-CN",
"target_language": "en",
"glossary_mode": "merge",
"style_guide": "Keep Chinese names in pinyin; formal, slightly archaic tone for elders.",
"output_format": "translation_only"
}'
{
"id": "ser_0mvri8igdU1ZBKpByrilHDc",
"object": "series",
"name": "Azure Cloud Sect",
"source_language": "zh-CN",
"target_language": "en",
"settings": {
"style_guide": "Keep Chinese names in pinyin; formal, slightly archaic tone for elders.",
"glossary_mode": "merge",
"output_format": "translation_only",
"auto_accept_new_terms": true
},
"glossary_id": null,
"worldview": null,
"worldview_version": 0,
"created_at": "2026-10-28T02:37:59Z"
}
2. Upload each volume and add it to the series
Upload every volume as a source (file or `text`), then attach it with its reading order. `position` defaults to the next number. Repeat for volume 2 (`src_0mvri8wtzFSbMncyV5GZvwu` → `vol_0mvri9b6q2tHTry6X2O5cSb`).
curl -X POST "https://xsfyj.com/api/b2b/v1/sources?wait=30" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-F "[email protected]"
# → { "id": "src_0mvri8q0pk5VSCNlpLs0k55", "status": "ready", "characters": 221, … }
curl -X POST "https://xsfyj.com/api/b2b/v1/series/ser_0mvri8igdU1ZBKpByrilHDc/volumes" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "source_id": "src_0mvri8q0pk5VSCNlpLs0k55", "position": 1, "title": "Volume 1: Azure Cloud Gate" }'
{
"id": "vol_0mvri96244cG34JfpngJjzL",
"object": "series_volume",
"source_id": "src_0mvri8q0pk5VSCNlpLs0k55",
"position": 1,
"title": "Volume 1: Azure Cloud Gate"
}
3. Bootstrap the series on the anchor volume
Starts a worldview job and a glossary job on the anchor volume (default: position 1; pass `volume_id` to choose another). Returns 202 with both jobs. Here volume 1 has 221 characters: worldview ⌈221 × 0.1⌉ = 23, glossary ⌈221 × 0.5⌉ = 111 credits.
curl -X POST "https://xsfyj.com/api/b2b/v1/series/ser_0mvri8igdU1ZBKpByrilHDc/bootstrap" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
{
"object": "list",
"data": [
{
"id": "job_0mvri9glj2W6mt6fqgSikI2",
"object": "job",
"type": "worldview",
"status": "queued",
"source_id": "src_0mvri8q0pk5VSCNlpLs0k55",
"series_id": "ser_0mvri8igdU1ZBKpByrilHDc",
"credits": 23,
"billing_state": "held",
"poll_after_seconds": 5,
…
},
{
"id": "job_0mvri9h45o9tD37yT4cbPPw",
"object": "job",
"type": "glossary",
"status": "queued",
"credits": 111,
"billing_state": "held",
…
}
],
"has_more": false,
"next_cursor": null
}
4. Read the series after bootstrap
When both jobs succeed, the series gets `worldview` (version 1) and `glossary_id` (glossary version 1, every term `suggested`), and a `series.glossary.updated` event is emitted. `volumes[].jobs` lists the latest jobs of each volume.
curl "https://xsfyj.com/api/b2b/v1/series/ser_0mvri8igdU1ZBKpByrilHDc" \
-H "Authorization: Bearer $KEY"
{
"id": "ser_0mvri8igdU1ZBKpByrilHDc",
"object": "series",
"name": "Azure Cloud Sect",
"glossary_id": "gls_0mvriah1kudAgkROSl89vK9",
"worldview": "Source Title: 青云门 / azure-cloud-vol1.txt\nGenre: Fantasy / Cultivation / Xianxia\nRegister: period-flavored\nTranslation References:\n- 筑基 -> Foundation Establishment …",
"worldview_version": 1,
"volumes": [
{
"id": "vol_0mvri96244cG34JfpngJjzL",
"object": "series_volume",
"source_id": "src_0mvri8q0pk5VSCNlpLs0k55",
"position": 1,
"title": "Volume 1: Azure Cloud Gate",
"jobs": [
{ "id": "job_0mvri9h45o9tD37yT4cbPPw", "type": "glossary", "status": "succeeded", "credits": 111, "billing_state": "consumed", … },
{ "id": "job_0mvri9glj2W6mt6fqgSikI2", "type": "worldview", "status": "succeeded", "credits": 23, "billing_state": "consumed", … }
]
},
{ "id": "vol_0mvri9b6q2tHTry6X2O5cSb", "object": "series_volume", "position": 2, "title": "Volume 2: Myriad Demon Valley", "jobs": [] }
],
…
}
5. Review the glossary and lock the terms you approve
Glossaries are versioned. `upsert` replaces whole terms by `source`, `remove` deletes by `source`. Send the version you read as `If-Match`; if someone changed it meanwhile you get 409 `VERSION_CONFLICT` with `meta.current_version`. Locked terms are never overwritten by later extraction.
curl -X PATCH "https://xsfyj.com/api/b2b/v1/glossaries/gls_0mvriah1kudAgkROSl89vK9" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H 'If-Match: "1"' \
-H "Content-Type: application/json" \
-d '{
"upsert": [
{ "source": "林逸", "target": "Lin Yi", "category": "person_name", "gender": "male", "authority": "locked" },
{ "source": "苏晴", "target": "Su Qing", "category": "person_name", "gender": "female", "authority": "locked" },
{ "source": "青云门", "target": "Azure Cloud Sect", "category": "proper_noun", "authority": "locked" },
{ "source": "玄冥玉佩", "target": "Xuanming Jade Pendant", "category": "proper_noun", "authority": "locked" }
],
"remove": ["第一章 青云门"]
}'
ETag: "2"
{
"id": "gls_0mvriah1kudAgkROSl89vK9",
"object": "glossary",
"name": "Azure Cloud Sect glossary",
"version": 2,
"current_version": 2,
"term_count": 10,
"terms": [
{ "source": "青云门", "target": "Azure Cloud Sect", "category": "proper_noun", "gender": null, "authority": "locked" },
{ "source": "林逸", "target": "Lin Yi", "category": "person_name", "gender": "male", "authority": "locked" },
{ "source": "问心阶", "target": "Heart-Questioning Steps", "category": "cultural_concept", "gender": null, "note": "…", "alternatives": ["…"], "count": 2, "authority": "suggested" },
…
],
"origin": { "kind": "patch" },
"version_created_at": "2026-10-28T02:40:26Z"
}
6. Extract new terms from volume 2
Runs a glossary job on this volume with the series glossary as input (0.5 credit/char of the volume: ⌈209 × 0.5⌉ = 105). On success, existing terms are kept unchanged and only new terms are appended as `suggested` — a new glossary version plus a `series.glossary.updated` event (`added_terms`, `glossary_version`).
curl -X POST "https://xsfyj.com/api/b2b/v1/series/ser_0mvri8igdU1ZBKpByrilHDc/volumes/vol_0mvri9b6q2tHTry6X2O5cSb/glossary" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
# after the job succeeds:
curl "https://xsfyj.com/api/b2b/v1/glossaries/gls_0mvriah1kudAgkROSl89vK9" -H "Authorization: Bearer $KEY"
{
"id": "gls_0mvriah1kudAgkROSl89vK9",
"object": "glossary",
"version": 3,
"term_count": 17,
"terms": [
{ "source": "林逸", "target": "Lin Yi", "gender": "male", "authority": "locked", … },
{ "source": "苏晴", "target": "Su Qing", "gender": "female", "authority": "locked", … },
…
{ "source": "血煞宗", "target": "Blood Fiend Sect", "category": "proper_noun", "authority": "suggested", … },
{ "source": "万妖谷", "target": "Myriad Demon Valley", "category": "proper_noun", "authority": "suggested", … },
{ "source": "噬魂幡", "target": "soul-devouring banner", "category": "cultural_concept", "authority": "suggested", … }
],
"origin": { "kind": "series_increment", "added": 7, "job_id": "job_0mvriby2od1mYMZ2wW0IWVC", "series_id": "ser_0mvri8igdU1ZBKpByrilHDc" }
}
7. Translate volume 2
Uses the series worldview and the glossary version current at submission time — frozen into the job (`glossary.version`), so later edits do not affect a running job. Credits: 209 chars × 1 + ⌈209 × 0.3⌉ style-guide surcharge = 272. Download the result via `GET /jobs/{id}/files/{file_id}`.
curl -X POST "https://xsfyj.com/api/b2b/v1/series/ser_0mvri8igdU1ZBKpByrilHDc/volumes/vol_0mvri9b6q2tHTry6X2O5cSb/translate" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{}'
{
"id": "job_0mvrieto7PiS3X5kaHeulKk",
"object": "job",
"type": "translation",
"status": "queued",
"source_id": "src_0mvri8wtzFSbMncyV5GZvwu",
"series_id": "ser_0mvri8igdU1ZBKpByrilHDc",
"target_language": "en",
"source_language": "zh-CN",
"options": {
"style_guide": "Keep Chinese names in pinyin; formal, slightly archaic tone for elders.",
"output_format": "translation_only",
"translate_filename": false
},
"glossary": { "mode": "merge", "glossary_id": "gls_0mvriah1kudAgkROSl89vK9", "version": 4, "inline_terms": 0 },
"credits": 272,
"billing_state": "held",
…
}
# succeeded → "result": { "files": [{ "kind": "translated", "file_id": "NVMVRIETV3HS_output_e657f246a7ff4dd0", "filename": "azure-cloud-vol2_translated.txt", "size_bytes": 969 }] }
# "Three months later, Lin Yi had broken through to Foundation Establishment. Yun Zhonghe ordered him to travel with Su Qing to Myriad Demon Valley to investigate the Blood Fiend Sect's traces. …"
8. Revise the series worldview
Replaces the worldview text and bumps `worldview_version`. Translations submitted afterwards use the new text; earlier jobs keep what they were given.
curl -X PATCH "https://xsfyj.com/api/b2b/v1/series/ser_0mvri8igdU1ZBKpByrilHDc/worldview" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{ "worldview": "Genre: Xianxia / cultivation.\nNames: pinyin (Lin Yi, Su Qing, Yun Zhonghe). Su Qing is female; address her as \"Senior Sister\".\nFactions: Azure Cloud Sect (orthodox) vs Blood Fiend Sect (demonic)." }'
{
"id": "ser_0mvri8igdU1ZBKpByrilHDc",
"object": "series",
"glossary_id": "gls_0mvriah1kudAgkROSl89vK9",
"worldview": "Genre: Xianxia / cultivation.\nNames: pinyin (Lin Yi, Su Qing, Yun Zhonghe). Su Qing is female; address her as \"Senior Sister\".\nFactions: …",
"worldview_version": 2,
…
}
- Cost of this example: bootstrap 23 + 111, volume-2 terms 105, volume-2 translation 272 = 511 credits. Credits are held at submission and consumed only on success.
- Your account runs a limited number of heavy jobs at once; extra jobs wait in `queued` (see `progress.waiting_reason`). Subscribe to `job.succeeded` and `series.glossary.updated` webhooks instead of polling.
- Skip the per-volume term extraction if a volume introduces no new names — translation already applies the series glossary in `merge` mode.
- Review new `suggested` terms (PATCH with `authority: "locked"`) before translating the volume, so the frozen glossary version contains your decisions.
Receive webhooks
Webhooks follow the Standard Webhooks spec. Events are thin: they carry ids and a status summary, never translated text — fetch the job (or glossary / series) afterwards. Event types: source.ready, source.failed, job.queued, job.running, job.succeeded, job.failed, job.cancelled, series.glossary.updated, account.credits_low.
1. Create an endpoint
The URL must be public https on port 443 (private, loopback and http URLs are rejected with 400 `INVALID_PARAMETER`). `events` defaults to `["*"]`. The signing `secret` is returned only in this response — store it now. Up to 10 endpoints per account.
curl -X POST "https://xsfyj.com/api/b2b/v1/webhook_endpoints" \
-H "Authorization: Bearer $KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/hooks/novo",
"events": ["job.succeeded", "job.failed", "series.glossary.updated"],
"description": "production worker"
}'
{
"id": "whe_0mvri9p5niB6qBCANjOEjQ4",
"object": "webhook_endpoint",
"url": "https://example.com/hooks/novo",
"events": ["job.succeeded", "job.failed", "series.glossary.updated"],
"status": "enabled",
"description": "production worker",
"consecutive_failures": 0,
"disabled_at": null,
"created_at": "2026-10-28T02:38:54Z",
"secret": "whsec_…"
}
2. Send a test event and inspect deliveries
The test sends a `job.succeeded` event with `data.test: true`. `GET /webhook_endpoints/{id}` returns the 20 most recent deliveries with `status` (pending / succeeded / failed), `attempts`, `last_status_code`, `last_error` and `next_attempt_at`.
curl -X POST "https://xsfyj.com/api/b2b/v1/webhook_endpoints/whe_0mvri9p5niB6qBCANjOEjQ4/test" \
-H "Authorization: Bearer $KEY"
curl "https://xsfyj.com/api/b2b/v1/webhook_endpoints/whe_0mvri9p5niB6qBCANjOEjQ4" \
-H "Authorization: Bearer $KEY"
{
"object": "webhook_test",
"event_id": "evt_0mvri9zz6q8ZGNnz5y0MZKP",
"endpoint": {
"id": "whe_0mvri9p5niB6qBCANjOEjQ4",
"object": "webhook_endpoint",
"status": "enabled",
"consecutive_failures": 0,
"recent_deliveries": [
{
"id": "dc15bd0c-60e0-47bc-a105-120ce14798d3",
"event_id": "evt_0mvri9zz6q8ZGNnz5y0MZKP",
"event_type": "job.succeeded",
"status": "succeeded",
"attempts": 1,
"last_status_code": 200,
"last_error": null,
"next_attempt_at": "2026-10-28T03:02:53Z"
}
],
…
}
}
3. What your endpoint receives
A POST with JSON body and three signing headers. `webhook-id` equals the event id and stays the same on retries — use it to deduplicate. Respond 2xx within 5 seconds; anything else (or a redirect) counts as a failure.
POST /hooks/novo HTTP/1.1
content-type: application/json
user-agent: NovoTranslator-Webhooks/1.0
webhook-id: evt_0mvriah30unQ1UIWaJkCcDY
webhook-timestamp: 1793155171
webhook-signature: v1,<base64 HMAC-SHA256>
{
"id": "evt_0mvriah30unQ1UIWaJkCcDY",
"object": "event",
"type": "job.succeeded",
"created_at": "2026-10-28T02:39:31Z",
"data": {
"id": "job_0mvri9h45o9tD37yT4cbPPw",
"object": "job",
"type": "glossary",
"status": "succeeded",
"credits": 111,
"series_id": "ser_0mvri8igdU1ZBKpByrilHDc",
"source_id": "src_0mvri8q0pk5VSCNlpLs0k55"
}
}
// series.glossary.updated
{ "id": "evt_0mvrid5lnlq9QtEYr35dZHF", "object": "event", "type": "series.glossary.updated", "created_at": "2026-10-28T02:41:36Z",
"data": { "id": "ser_0mvri8igdU1ZBKpByrilHDc", "object": "series", "glossary_id": "gls_0mvriah1kudAgkROSl89vK9", "glossary_version": 3, "added_terms": 7, "job_id": "job_0mvriby2od1mYMZ2wW0IWVC" } }
4. Verify the signature — Node.js
Signed content is `{webhook-id}.{webhook-timestamp}.{raw body}`, HMAC-SHA256 with the base64-decoded part of the secret after `whsec_`. Compare in constant time and reject timestamps more than 5 minutes away.
// Node.js ≥ 18 — verify a Standard Webhooks signature (no dependencies)
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyWebhook(secret, headers, rawBody, nowSeconds = Math.floor(Date.now() / 1000)) {
const id = headers["webhook-id"];
const timestamp = Number(headers["webhook-timestamp"]);
if (!id || !Number.isFinite(timestamp)) return false;
if (Math.abs(nowSeconds - timestamp) > 5 * 60) return false; // reject replays / clock skew > 5 min
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = createHmac("sha256", key).update(id + "." + timestamp + "." + rawBody).digest();
// the header may carry several space-separated signatures, e.g. during secret rotation
return String(headers["webhook-signature"] ?? "").split(" ").some((entry) => {
const [version, value] = entry.split(",");
if (version !== "v1" || !value) return false;
const actual = Buffer.from(value, "base64");
return actual.length === expected.length && timingSafeEqual(actual, expected);
});
}
// Express: keep the raw body — re-serialised JSON will not match the signature
app.post("/hooks/novo", express.raw({ type: "application/json" }), async (req, res) => {
if (!verifyWebhook(process.env.NOVO_WEBHOOK_SECRET, req.headers, req.body.toString("utf8"))) {
return res.status(400).end();
}
const event = JSON.parse(req.body);
res.status(204).end(); // acknowledge fast (< 5 s), work async
await queue.add(event.id, event); // dedupe on event.id
});
// Test vector (standardwebhooks.com) → true:
// verifyWebhook("whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw",
// { "webhook-id": "msg_p5jXN8AQM9LWM0D4loKWxJek", "webhook-timestamp": "1614265330",
// "webhook-signature": "v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=" },
// '{"test": 2432232314}', 1614265330)
5. Verify the signature — Python
Same algorithm. Official Standard Webhooks libraries (npm `standardwebhooks`, PyPI `standardwebhooks`, and others) also work with these headers.
# Python ≥ 3.10 — verify a Standard Webhooks signature (standard library only)
import base64, hashlib, hmac, time
def verify_webhook(secret: str, headers: dict, raw_body: bytes, now: int | None = None) -> bool:
msg_id = headers.get("webhook-id", "")
timestamp = headers.get("webhook-timestamp", "")
if not msg_id or not timestamp.isdigit():
return False
if abs((now or int(time.time())) - int(timestamp)) > 5 * 60: # reject skew > 5 min
return False
key = base64.b64decode(secret.removeprefix("whsec_"))
signed = f"{msg_id}.{timestamp}.".encode() + raw_body
expected = base64.b64encode(hmac.new(key, signed, hashlib.sha256).digest()).decode()
return any(
version == "v1" and hmac.compare_digest(value, expected)
for version, _, value in (entry.partition(",") for entry in headers.get("webhook-signature", "").split(" "))
)
# Flask: use request.get_data() (raw bytes), and lower-case header names
@app.post("/hooks/novo")
def novo_hook():
headers = {k.lower(): v for k, v in request.headers.items()}
if not verify_webhook(os.environ["NOVO_WEBHOOK_SECRET"], headers, request.get_data()):
abort(400)
enqueue(request.get_json()) # dedupe on event["id"]
return "", 204
6. Retries, auto-disable and catching up
Failed deliveries are retried with backoff (30 s, 2 min, 10 min, 30 min, 1 h, 2 h, 4 h, 8 h, 12 h — roughly a day in total), then marked `failed`. An endpoint failing continuously for 3 days is set to `disabled`; fix it and re-enable with PATCH `status: "enabled"` (resets the failure counter). Events are kept 30 days — after an outage, page through `GET /events` and fetch each job.
curl -X PATCH "https://xsfyj.com/api/b2b/v1/webhook_endpoints/whe_0mvri9p5niB6qBCANjOEjQ4" \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{ "status": "enabled" }'
curl "https://xsfyj.com/api/b2b/v1/events?type=job.succeeded&limit=3" \
-H "Authorization: Bearer $KEY"
# continue with ?cursor=<next_cursor>; delete an endpoint with DELETE /webhook_endpoints/{id} → 204
{
"object": "list",
"data": [
{
"id": "evt_0mvriah30unQ1UIWaJkCcDY",
"object": "event",
"type": "job.succeeded",
"created_at": "2026-10-28T02:39:31Z",
"data": { "id": "job_0mvri9h45o9tD37yT4cbPPw", "object": "job", "type": "glossary", "status": "succeeded", "credits": 111, "series_id": "ser_0mvri8igdU1ZBKpByrilHDc", "source_id": "src_0mvri8q0pk5VSCNlpLs0k55" }
},
…
],
"has_more": true,
"next_cursor": "WyIyMDI2LTEwLTI4VDAyOjM5OjA4Ljg4NVoiLCJldnRfMG12cmk5eno2cThaR05uejV5ME1aS1AiXQ"
}
- Verify against the raw request bytes; parsing and re-serialising JSON changes whitespace and breaks the signature.
- Delivery order is not guaranteed and an event may arrive more than once — dedupe on `webhook-id` and always re-read the job for its current state.
- Never expose the endpoint secret; if it leaks, create a new endpoint and delete the old one.