API Documentation

This document outlines the available API endpoints for the React frontend.

Base URL: /api (Relative to the application root)

Common Headers

All requests should include the following headers to ensure correct JSON handling and authentication with Laravel Sanctum:

Error Responses

API requests may return error responses with appropriate HTTP status codes and JSON bodies.

422 Unprocessable Entity (Validation Error)

Returned when request data fails validation rules.

{
    "message": "The given data was invalid.",
    "errors": {
        "field_name": [
            "The field name field is required."
        ]
    }
}

401 Unauthorized

Returned when authentication fails (e.g., missing or invalid token).

{
    "message": "Unauthenticated."
}

403 Forbidden

Returned when the user is authenticated but does not have permission to perform the action.

{
    "message": "This action is unauthorized."
}

Authentication

Register

Create a new user account.

Login

Authenticate a user.

Logout

Invalidate the current session token.

DingTalk Login Redirect

Get the DingTalk OAuth login URL.

DingTalk Login Callback

Handle the DingTalk OAuth callback and authenticate/register the user.

User & Profile

Get Current User

Fetch the currently authenticated user's details.

Update Profile

Update the user's name and/or email.

Update Password

Change the user's password.

List All Users (Admin Only)

Get a paginated list of all users. Only users with is_admin set to true can access this endpoint.

Update User Admin Status (Admin Only)

Update any user's is_admin attribute. Only users with is_admin set to true can access this endpoint.

File Upload

Upload File

Upload an image or PDF file (Max 10MB).

Reimbursements

List My Reimbursements

Get a paginated list of the current user's reimbursement reports.

List All Reimbursements (Admin Only)

Get a paginated list of all users' reimbursement reports (default excludes drafts).

Create Reimbursement Report

Create a new reimbursement group (e.g., "Jan 2025").

Show Reimbursement Report

Get details of a specific report, including its items.

Update Reimbursement Report

Update report details (title, offset invoices) while in draft or rejected status.

Submit Report

Submit a draft report for approval.

Delete Reimbursement Report

Delete a reimbursement report. Only the owner can delete their own report, and only when it's in draft status.

Add Item

Add a specific expense item to a report.

Update Item

Update an existing item.

Delete Item

Remove an item from a draft report.

Approve Report (Admin Only)

Approve a submitted report.

Reject Report (Admin Only)

Reject a submitted report.

DingTalk Table (Generic)

Get Table Data

Fetch all records from a specified DingTalk AI Table (Notable). Supports generic filtering.

LLM

LLM Completion

Sends a request for chat completion to a Large Language Model (LLM) service.

Store Signboards

This section outlines API endpoints for managing water pump store signboard information. Each record is associated with the user who created it, ensuring data independence.

List My Store Signboards

Get a paginated list of the current user's store signboard records.

Create Store Signboard

Create a new store signboard record. The image_path should be obtained by first uploading the image using the /api/upload endpoint.

Show Store Signboard

Get details of a specific store signboard. Only the owner or an admin can access this.

Update Store Signboard

Update details of a specific store signboard. Only the owner or an admin can update this.

Delete Store Signboard

Delete a specific store signboard record. Only the owner or an admin can delete this.