library-rest

Create a new author.

POST/authors

Creates an author with no books linked yet. Books are linked to it via POST /books.

Request body

application/json

FieldTypeRequiredDescription
biostringA short biography of the author. Optional.
namestringyesThe author's full name. Must not be blank.

Responses

201 The author was created.

application/json

FieldTypeRequiredDescription
dataobjectyesA book author, referencing the books they have written by id.
biostringyesA short biography of the author.
bookIdsarray of stringyesIds of the books this author has written.
idstringyesUnique identifier assigned by the server, prefixed with au_.
namestringyesThe author's full name.
metaobjectyesResponse metadata attached to every successful response.
requestIdstringyesCorrelation id for this request, echoed from the X-Request-Id request header or generated if absent. Useful for tracing a request across logs.
totalintegerTotal number of matches before pagination was applied. Present only on paginated list responses (currently GET /books).

Errors

CodeMessageDescription
400The request body is not valid JSON.
401The request is missing a valid Authorization: Bearer <token> header.
415The request has a body but its Content-Type is not application/json.
422name is missing or blank.
500An unexpected error occurred. The response never leaks internal error details.

Request example

{
  "bio": "bio_725",
  "name": "name_222"
}

Response example

{
  "data": {
    "bio": "bio_61",
    "bookIds": [
      "bookIds_92"
    ],
    "id": "id_519",
    "name": "name_97"
  },
  "meta": {
    "requestId": "requestId_120",
    "total": 883
  }
}