Add a bookmark or highlight
const url = 'http://localhost:8080/api/v1/publications/1/annotations';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"kind":"bookmark","locator":{"href":"example","type":"application/xhtml+xml","title":"example","locations":{"fragments":["example"],"progression":1,"totalProgression":1,"position":1},"text":{"before":"example","highlight":"example","after":"example"}},"color":"example","note":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/api/v1/publications/1/annotations \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "kind": "bookmark", "locator": { "href": "example", "type": "application/xhtml+xml", "title": "example", "locations": { "fragments": [ "example" ], "progression": 1, "totalProgression": 1, "position": 1 }, "text": { "before": "example", "highlight": "example", "after": "example" } }, "color": "example", "note": "example" }'A highlight’s locator must carry the highlighted text in text.highlight. A publication holds up to 5,000 annotations per user.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
A Readium Locator. The server checks the fields below and stores the rest as sent, up to 16 KiB in all.
object
The resource’s media type.
Example
application/xhtml+xmlobject
Position within the resource.
Position within the publication.
object
A color name or value the client chooses, such as yellow.
Responses
Section titled “Responses”The new annotation.
object
A Readium Locator. The server checks the fields below and stores the rest as sent, up to 16 KiB in all.
object
The resource’s media type.
object
Position within the resource.
Position within the publication.
object
The device name of the session that last saved it.
Example
{ "kind": "bookmark", "locator": { "type": "application/xhtml+xml" }}The request was malformed.
object
Explains the problem to a developer.
Example
{ "code": "bad_request"}The request has no valid session token.
object
Explains the problem to a developer.
Example
{ "code": "bad_request"}The signed-in user may not do this. demo_account when the user is a
shared demo account, named in CHEK_DEMO_USERS, which can’t change
its password, sessions, sign-in providers, extensions or annotations.
object
Explains the problem to a developer.
Example
{ "code": "bad_request"}The resource does not exist.
object
Explains the problem to a developer.
Example
{ "code": "bad_request"}The server failed; details are in its log.
object
Explains the problem to a developer.
Example
{ "code": "bad_request"}