Overview
This endpoint implements the command part of CQRS pattern to create a new Author entity in the Catalog bounded context. It follows Domain-Driven Design principles by encapsulating the author creation operation as a discrete business capability.
Security
- Authorization: Requires admin privileges (Policy:
Admin
) - Authentication: Required
- API Version: 1.0
Implementation Details
The endpoint follows these key principles:
- CQRS Pattern: Implements the Command side for author creation
- Domain-Driven Design: Encapsulates author creation as a domain operation
- Vertical Slice Architecture: Contains all layers (API, Application, Domain, Infrastructure) within the Catalog bounded context
Loading graph...
Validation Rules
- Author name is required (cannot be empty)
- Author name has a maximum length constraint defined by
DataSchemaLength.Large
Technical Characteristics
- Idempotency: Author creation operations are idempotent
- Transactional: Changes are wrapped in a unit of work
- Response: Returns the newly created author’s GUID
- HTTP Method: POST
- Endpoint:
/api/v1/authors
Architecture
POST (/api/v1/authors)
Request Body
Example Usage
curl -X POST "https://api.bookworm.com/api/v1/authors/{id}" \ -H "Authorization: Bearer <admin-token>" \ -H "Content-Type: application/json" \ -d '{ "name": "John Doe" }'
Response Details
201 Created
- Returns the newly created author’s GUID
- Includes a Location header with the URL to the new resource
- Format:
/api/v1/authors/{guid}
400 Bad Request
Returned when:
- Author name is empty
- Author name exceeds maximum length
- Invalid request format
401 Unauthorized
Returned when the request lacks valid authentication credentials.
403 Forbidden
Returned when the authenticated user lacks admin privileges.