This document outlines the functionalities and usage of the Laravel API for managing customers and invoices. Secure access is ensured through Laravel Sanctum token authentication.
The API utilizes Laravel Sanctum for token-based authentication. To access protected endpoints, users need to generate a token using their login credentials.
- Generating a Token:
- Send a GEt request to
/setup
and it will generate thsi default user that will be used to generate the tokens that will be used to access the tokens:
{
"email": "[email protected]",
"password": "password"
}
- A successful response will include a token field containing the 3 access tokens.
- Basic token
- Admin token
- Update token
- Including the Token in Requests:
- Include the access token in the authorization header of all subsequent requests. Here's an example using curl:
curl -X GET https://your-api-domain/api/v1/customers \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Important Note:
Store the access token securely and avoid exposing it in client-side code.
The API is organized with a base URI of /api/v1
. Here's a breakdown of the available endpoints:
Customers:
GET /customers
: Retrieve a list of all customers.GET /customers/{id}
: Get details of a specific customer by their ID.POST /customers
: Create a new customer.PUT /customers/{id}
: Update an existing customer[all fields].PATCH /customers/{id}
: Update a single existing customer field.DELETE /customers/{id}
: Delete a customer.
Invoices:
GET /invoices
: Retrieve a list of all invoices.GET /invoices/{id}
: Get details of a specific invoice by their ID.POST /invoices
: Create a new invoice.PUT /invoices/{id}
: Update an existing invoice[all fields].PATCH /invoices/{id}
: Update a single existing invoice field.DELETE /invoices/{id}
: Delete a invoice.
Additional Features
- Bulk Invoice Insertion
- Customer and Invoice Filtering using operator custom patterns..
For more info, please refer to the more detailed api documentation.
- Documentation Home page
Specific details about request parameters and response structures can be found in the controller code within your project. Error responses will be formatted as JSON objects with an error message and relevant details (e.g., validation errors).
Example Usage:
- Generate a token using the
/login
endpoint. - Use the retrieved token in subsequent requests with the Authorization header.
- Refer to the specific endpoint documentation for details on request parameters and expected responses.
This is a basic documentation structure. You can expand on it by including:
- Specific request parameters for each endpoint (e.g., required fields, data types).
- Expected response structure (including data fields and their meanings).
- Authentication error codes and their descriptions.
- Example code snippets for making API calls in different languages.
- Remember to update this documentation as your API evolves and add new functionalities.
Thanks for checking out my repo
vernonthedev