A book is a three-level tree: the book holds units, and a unit holds pages. All three share the Pages module’s storage, so each keeps its content in revisions and renders through its layout’s areas.
API ReferenceContent
Books
Books, their units and pages, and a book’s PDF export.
About books
Book, unit and page. Units and pages have their own routes and pages here.
The Books moduleBook, unit and page each keep their content in revisions.
Revisions, publishing and approvalA book can be exported as a PDF; the export runs in the background and its state can be read.
The Books moduleKey fields
id- integer
- The book id.
name- string
- The live revision's name.
slug- string
- The book's path segment.
unitsCount, pagesCount- integer
- How many units and pages the book holds. Computed.
children- Unit[]
- The book's units.
activeRevision- Revision
- The live revision.
published- datetime
- When the book went, or goes, public.
List books#
/cdna-api/books/books
Lists books. Without limit every match comes back.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Model
- Book, in the Reference
Parameters
propertiesquery- selector
- The fields and relations to return, such as
{id,name,slug,unitsCount,pagesCount}. filtersquery- name=value
- Any stored field, or a relation with a dot, such as
parent.id=12. Prefix the name with!,>,<,%or|. Use stored field names exactly as in the model, and comparetotalCountwith the unfiltered list's to confirm a filter applied. orderByquery- string
field:ASCorfield:DESC, comma-separated. Stored fields only.limitquery- integer
- Records per response. There is no default.
offsetquery- integer
- Records to skip.
retrieveUnpublishedquery- 1
- Include unpublished records.
Example
GET /cdna-api/books/books?limit=2&properties={id,name,slug,unitsCount,pagesCount} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"totalCount": 15,
"data": [
{
"id": 1677,
"name": "The APIs: REST, GraphQL and custom endpoints",
"slug": "apis",
"unitsCount": 6,
"pagesCount": 6
},
{
"id": 1590,
"name": "Choosing how to build",
"slug": "choosing-how-to-build",
"unitsCount": 4,
"pagesCount": 4
}
]
}Show a book#
/cdna-api/books/book/{id}
Reads one book by its id.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Model
- Book, in the Reference
Parameters
idpathrequired- integer
- The book id.
propertiesquery- selector
- The fields and relations to return, such as
{id,name,slug,unitsCount,pagesCount}.
Example
GET /cdna-api/books/book/1677?properties={id,name,slug,unitsCount,pagesCount} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"data": {
"id": 1677,
"name": "The APIs: REST, GraphQL and custom endpoints",
"slug": "apis",
"unitsCount": 6,
"pagesCount": 6
}
}Read a book’s PDF export state#
/cdna-api/books/book/{id}
Reads the state of the book’s PDF export through the regular show route. exportPdfStatus is generate_pdfs, merging, success, error, or null when no export has run; exportPdfPath is the finished file. Postman’s older exportStatus is no longer a field.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
- Model
- Book, in the Reference
Parameters
idpathrequired- integer
- The book id.
propertiesquery- selector
- The fields and relations to return, such as
{id,exportPdfStatus,exportPdfPath,exportPdfDate}.
Example
GET /cdna-api/books/book/1677?properties={id,exportPdfStatus,exportPdfPath,exportPdfDate} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"data": {
"id": 1677,
"exportPdfStatus": "",
"exportPdfPath": null,
"exportPdfDate": null
}
}Create a book#
/cdna-api/books/book
Creates a book.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
revisionsbody- object
- A new revision:
name,layoutandareas, ortextfor a record with a body. Areas left out are empty.
Example
POST /cdna-api/books/book HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"revisions": {
"name": "Test from API 208"
}
}{
"result": "success",
"data": {
"book": {
"unitsCount": 0,
"pagesCount": 0,
"units": [],
"lastRevision": 494,
"name": "Test from API 342",
"fullSlug": "/test-from-api-342",
"fullPath": "/test-from-api-342",
"id": 100,
"slug": "test-from-api-342",
"publishAt": null
}
},
"message": "The Book has been added successfully."
}Edit a book#
/cdna-api/books/book/{id}
Changes a book. Fields left out keep their values.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The book id.
revisionsbody- object
- A new revision:
name,layoutandareas, ortextfor a record with a body. Areas left out are empty.
A revisions object makes a new revision that is not live unless the request also sends "activeRevision": true, and it holds only the areas sent. To change some areas and keep the rest, use patchRevision with originRevision.
Example
PUT /cdna-api/books/book/1 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"revisions": {
"name": "Changed book title from API 435"
}
}{
"result": "success",
"data": {
"book": {
"unitsCount": 4,
"pagesCount": 1,
"units": [
3,
32
],
"lastRevision": 496,
"name": "Changed book title from API 312",
"fullSlug": "/test-book",
"fullPath": "/test-book",
"id": 1,
"slug": "test-book",
"publishAt": null
}
},
"message": "The Book has been saved successfully."
}Delete a book#
/cdna-api/books/book/{id}
Deletes a book.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The book id.
Example
DELETE /cdna-api/books/book/53 HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"data": [],
"message": "The Book has successfully been deleted."
}Duplicate a book#
/cdna-api/books/duplicate-book/{id}
Copies a book. The copy is unpublished.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The book id.
Example
POST /cdna-api/books/duplicate-book/24365?properties={id,units} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"data": {
"book": {
"id": 24428,
"units": [
24429
]
}
},
"message": "The Book has successfully been duplicated."
}Export a book as a PDF#
/cdna-api/books/export-book-pdf/{id}
Starts a PDF export of the book. The export runs in the background; read its progress from the book’s exportPdfStatus. The saved response below predates the field’s rename and shows it as exportStatus.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
idpathrequired- integer
- The book id.
Example
POST /cdna-api/books/export-book-pdf/24365?properties={id,exportPdfStatus,exportPdfPath} HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json{
"result": "success",
"data": {
"book": {
"id": 24365,
"exportStatus": "generate_pdfs",
"exportPdfPath": null
}
},
"message": "The export of the book PDF has been started. Once the export is completed, it will be attached to the book."
}Check that a book slug is free#
/cdna-api/books/books/check-slug
Answers {"result":"success"} when no book uses the slug. A slug in use, or one with characters a slug cannot have, answers HTTP 200 too, with "result": "error" and a message.
- Access
- Admin users and integrations, with an OAuth access token or an API key.
Parameters
slugbodyrequired- string
- The slug to check.
idbody- integer
- A record to leave out of the check, when renaming it.
sitebody- integer
- The site to check in.
Example
POST /cdna-api/books/books/check-slug HTTP/1.1
Host: hub.coredna.com
Authorization: Bearer YOUR_ACCESS_TOKEN
Accept: application/json
Content-Type: application/json
{
"slug": "start-here"
}{
"result": "error",
"message": "A record with this slug already exists"
}