You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Develop an API endpoint that allows authenticated users to create a new billing plan by providing details such as the plan name and price, with proper validation to ensure data accuracy. The endpoint should handle errors gracefully by returning appropriate HTTP status codes, meaningful error messages, and logging requests for monitoring and debugging.
Endpoint Details
Method:POST URL:/api/v1/billing-plans
Request
Headers
Authorization: Bearer <token> (Required: Ensures only authenticated users can access the endpoint)
Content-Type: application/json
Request Body
{
"name": "string",
"price": "number"
}
Response
Success (201 Created)
Body:
{
"Status": 201,
"Message": "Billing plan created successfully",
"Data": {
"id": "string",
"name": "string",
"price": "number"
}
}
Failure Responses
401 Unauthorized
Body:
{
"Status": 401,
"Message": "Unauthorized"
}
500 Internal Server Error
Body:
{
"Status": 500,
"Message": "Internal server error"
}
Acceptance Criteria
The endpoint must require authentication, returning a 401 Unauthorized error if the user is not authenticated.
Upon successful creation, the endpoint must return:
201 Created status code
A success message
The created billing plan details under the Data key
The system should properly handle unexpected errors and return a 500 Internal Server Error when necessary.
Additional Details
Authorization
Only authenticated users should be able to create billing plans.
Unauthorized access must result in a 401 Unauthorized response with a clear error message.
Data Validation
name: Must be a non-empty string.
price: Must be a valid numerical value.
Error Handling
Implement meaningful error messages and appropriate HTTP status codes.
Ensure consistent response formats for errors.
Logging
Log both successful operations and errors to facilitate debugging and system monitoring.
The text was updated successfully, but these errors were encountered:
odero-lavenda
changed the title
Develop an endpoint that allows for the creation of a new billing plan within the system.
FEAT: Create Billing Plan Endpoint
Feb 27, 2025
Description
Develop an API endpoint that allows authenticated users to create a new billing plan by providing details such as the plan name and price, with proper validation to ensure data accuracy. The endpoint should handle errors gracefully by returning appropriate HTTP status codes, meaningful error messages, and logging requests for monitoring and debugging.
Endpoint Details
Method:
POST
URL:
/api/v1/billing-plans
Request
Headers
Authorization: Bearer <token>
(Required: Ensures only authenticated users can access the endpoint)
Content-Type: application/json
Request Body
Response
Success (201 Created)
Body:
Failure Responses
401 Unauthorized
Body:
500 Internal Server Error
Body:
Acceptance Criteria
Data
keyAdditional Details
Authorization
Data Validation
name
: Must be a non-empty string.price
: Must be a valid numerical value.Error Handling
Logging
The text was updated successfully, but these errors were encountered: