Skip to content

FEAT: Create Billing Plan Endpoint #678

@odero-lavenda

Description

@odero-lavenda

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

{
  "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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions