Fill a new book with its chapters
const url = 'https://digize.com/api/v1/books/example/chapters/import';const options = { method: 'POST', headers: { 'Idempotency-Key': '5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69', 'x-api-key': '<x-api-key>', 'Content-Type': 'application/json' }, body: '{"parts":[{"kind":"chapter","matter":null,"title":"example","blocks":[{"content":[{"text":"example","marks":["bold"],"href":"example"}],"type":"paragraph","id":"example"}]}],"figures":[],"cover":null}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://digize.com/api/v1/books/example/chapters/import \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \ --header 'x-api-key: <x-api-key>' \ --data '{ "parts": [ { "kind": "chapter", "matter": null, "title": "example", "blocks": [ { "content": [ { "text": "example", "marks": [ "bold" ], "href": "example" } ], "type": "paragraph", "id": "example" } ] } ], "figures": [], "cover": null }'Fills a book still at its brief, with nothing written, with a book the author already wrote: its front matter, chapters and back matter in order, each as blocks (Books › Library › Import a PDF reads them from a PDF). A figure block’s figureId is the ref of one of figures, each a picture uploaded with books.figures.createUpload (kind figure) and ready as it is. cover is a front uploaded the same way (kind cover) with the title, subtitle and author already on it: it’s printed as it is. The book moves to editing, its chapters the author’s own.
Needs the books:write permission.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”Makes the request safe to send again: for 24 hours the same key and request answer the first response without repeating the change.
Example
5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69Request Bodyrequired
Section titled “Request Bodyrequired”object
object
object
object
object
object
object
object
object
object
object
object
The picture, uploaded with books.figures.createUpload (kind figure).
Responses
Section titled “Responses”Done
object
object
object
Made from the title and unique, for the book’s page on a site.
Its stage: brief while the brief isn’t finished, then briefing, interviewing, generating, editing, ready once a build exists, and published once a listing is live.
The author’s photo, from Books › Settings when the book began.
Why reading the sources for the interview failed, when it did; the book is back at brief until it’s started again.
How many runs of the writer it has had; 0 before the first.
Words in its chapters.
The model the author picked to write it, preselected for the next run (books.writers.list).
What writing it with a GPT model has cost on the workspace’s own OpenAI account, in US dollars.
How many things the interview learned, which the writer writes from.
Whether it has something to write from: an outline or an insight (books.generate.start).
B5: the cover front picked, in Images (books.cover.get has the rest).
The cover front picked, as the shelf shows it; unless it’s coverDesigned, the title and author are set over it at build.
Whether the cover front picked is a whole design with the title, subtitle and author in it (GPT Image’s), printed as it is.
Example
{ "chapterLength": "short", "trim": "5x8", "theme": "classic", "sources": { "services": [ "stripe" ] }, "status": "brief"}What was sent isn’t valid (invalid).
object
object
object
Example
{ "error": { "code": "invalid" }}No key, or one that’s unknown, off or expired.
object
object
object
Example
{ "error": { "code": "invalid" }}The key doesn’t have the permission this needs.
object
object
object
Example
{ "error": { "code": "invalid" }}Nothing has that id (not_found).
object
object
object
Example
{ "error": { "code": "invalid" }}A request with the same Idempotency-Key is still running (conflict).
object
object
object
Example
{ "error": { "code": "invalid" }}The Idempotency-Key was used with a different request.
object
object
object
Example
{ "error": { "code": "invalid" }}Over the rate limit; see retry-after.
object
object
object
Example
{ "error": { "code": "invalid" }}