Skip to content

Change a chapter

PATCH
/api/v1/books/{bookId}/chapters/{id}
curl --request PATCH \
--url https://digize.com/api/v1/books/example/chapters/example \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: 5f1c2a8e-3b7d-4c55-9a0e-1f2d3c4b5a69' \
--header 'x-api-key: <x-api-key>' \
--data '{ "title": "example", "blocks": [ { "content": [ { "text": "example", "marks": [ "bold" ], "href": "example" } ], "type": "paragraph", "id": "example" } ], "baseVersion": 1 }'

Saves a chapter’s title or blocks. The version it replaces is kept (the last five are). Give baseVersion, the version the change was made on, to be refused if the chapter changed since.

Needs the books:write permission.

bookId
required
string
>= 1 characters <= 64 characters
id
required
string
>= 1 characters <= 64 characters
Idempotency-Key
string
>= 1 characters <= 255 characters

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-1f2d3c4b5a69
Media typeapplication/json
object
title
string
>= 1 characters <= 200 characters
blocks
Array
<= 3000 items
One of:
object
content
required
Array<object>
<= 2000 items
object
text
required
string
<= 20000 characters
marks
Array<string>
<= 5 items
Allowed values: bold italic underline strike code
href
string
>= 1 characters <= 2000 characters
type
required
string
Allowed value: paragraph
id
required
string
/^[\w-]{4,40}$/
baseVersion
integer
>= 1 <= 9007199254740991

Done

Media typeapplication/json
object
id
required
string
position
required
integer
>= -9007199254740991 <= 9007199254740991
kind
required

A chapter, or front or back matter.

string
Allowed values: chapter front back
matter
required
Any of:
string
Allowed values: title copyright dedication foreword introduction conclusion about acknowledgments
number
required
Any of:
integer
>= -9007199254740991 <= 9007199254740991
title
required
string
promise
required

One line: what the reader gets from it.

string
status
required

planned until it’s written, drafting while the writer writes it, drafted, then edited once the author changed it.

string
Allowed values: planned drafting drafted edited
words
required
integer
>= -9007199254740991 <= 9007199254740991
grade
required

Its reading level as a US school grade (Flesch–Kincaid), or null with too little text or in another language than English.

number | null
version
required
integer
>= -9007199254740991 <= 9007199254740991
generation
required

The run of the writer that last wrote it.

integer
>= -9007199254740991 <= 9007199254740991
updatedAt
required
string format: date-time
summary
required
string
blocks
required

Its content as blocks, each with an id: paragraph, heading, list, quote, pullquote, callout, table, figure, break.

Array
One of:
object
content
required
Array<object>
<= 2000 items
object
text
required
string
<= 20000 characters
marks
Array<string>
<= 5 items
Allowed values: bold italic underline strike code
href
string
>= 1 characters <= 2000 characters
type
required
string
Allowed value: paragraph
id
required
string
/^[\w-]{4,40}$/
insightIds
required
Array<string>
targetWords
required
integer
>= -9007199254740991 <= 9007199254740991

Example

{
"kind": "chapter",
"matter": "title",
"status": "planned",
"blocks": [
{
"content": [
{
"marks": [
"bold"
]
}
],
"type": "paragraph"
}
]
}

What was sent isn’t valid (invalid).

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

No key, or one that’s unknown, off or expired.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

The key doesn’t have the permission this needs.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

Nothing has that id (not_found).

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

A request with the same Idempotency-Key is still running (conflict).

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

The Idempotency-Key was used with a different request.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}

Over the rate limit; see retry-after.

Media typeapplication/json
object
error
required
object
code
required
string
Allowed values: invalid unauthorized forbidden not_found conflict too_large rate_limited unavailable internal
message
required
string
details
object
key
additional properties
any

Example

{
"error": {
"code": "invalid"
}
}