Skip to main content
ADMIN role required — This endpoint requires administrator privileges. Non-admin users will receive a 403 Forbidden error.

Endpoint

POST /api/repair-request

Authentication

This endpoint requires a valid JWT Bearer token with ADMIN role.
Authorization: Bearer YOUR_JWT_TOKEN

Content Type

This endpoint accepts multipart/form-data for file uploads.
Content-Type: multipart/form-data

Request Body

customer_name
string
required
Customer’s full name (minimum 3 characters)
customer_phone
string
required
Customer’s phone number (minimum 8 characters)
customer_email
string
required
Customer’s email address (must be valid email format)
article_name
string
required
Name of the article to be repaired (minimum 3 characters)
article_type
string
required
Type of the article (minimum 3 characters)
article_brand
string
required
Brand of the article (minimum 2 characters)
article_model
string
required
Model of the article (minimum 2 characters)
article_serialnumber
string
Serial number of the article (optional, minimum 6 characters if provided)
article_accesories
string
Accessories included with the article (optional, minimum 3 characters if provided)
article_problem
string
required
Description of the problem (minimum 3 characters)
repair_status
string
required
Initial status of the repair. Must be one of:
  • pending - Pending review
  • in_progress - Under repair
  • waiting_parts - Waiting for parts
  • completed - Repaired
  • delivered - Delivered to the client
  • canceled - Canceled
repair_details
string
Details about the repair work (optional, minimum 3 characters if provided)
repair_price
number
Price of the repair (optional, must be numeric)
received_at
string
required
Date when the article was received (date format: YYYY-MM-DD)
repaired_at
string
Date when the repair was completed (optional, date format: YYYY-MM-DD)
images[]
file[]
Array of image files (optional). Accepted formats: jpeg, png, jpg

Response

Returns the created repair request with a unique receipt_number and associated images.

Response Fields

success
boolean
required
Indicates if the request was successful
message
string
required
Success message
data
object
required

Examples

curl -X POST https://api.yourservice.com/api/repair-request \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Accept: application/json" \
  -F "customer_name=John Doe" \
  -F "customer_phone=+1234567890" \
  -F "[email protected]" \
  -F "article_name=Laptop" \
  -F "article_type=Electronics" \
  -F "article_brand=Dell" \
  -F "article_model=XPS 15" \
  -F "article_serialnumber=SN123456" \
  -F "article_accesories=Charger, Case" \
  -F "article_problem=Screen not turning on" \
  -F "repair_status=pending" \
  -F "repair_details=Initial inspection needed" \
  -F "repair_price=0" \
  -F "received_at=2026-03-08" \
  -F "images[]=@/path/to/image1.jpg" \
  -F "images[]=@/path/to/image2.jpg"

Response Example

{
  "success": true,
  "message": "Repair request created successfully",
  "data": {
    "repairRequest": {
      "id": 1,
      "receipt_number": "RR-20260308143025123456789",
      "customer_name": "John Doe",
      "customer_phone": "+1234567890",
      "customer_email": "[email protected]",
      "article_name": "Laptop",
      "article_type": "Electronics",
      "article_brand": "Dell",
      "article_model": "XPS 15",
      "article_serialnumber": "SN123456",
      "article_accesories": "Charger, Case",
      "article_problem": "Screen not turning on",
      "repair_status": "pending",
      "repair_details": "Initial inspection needed",
      "repair_price": "0.00",
      "received_at": "2026-03-08T00:00:00.000000Z",
      "repaired_at": null,
      "images": [
        {
          "id": 1,
          "path": "repair_requests/repair_request_image_RR-20260308143025123456789_1.jpg",
          "imageable_type": "App\\Models\\RepairRequest",
          "imageable_id": "RR-20260308143025123456789"
        },
        {
          "id": 2,
          "path": "repair_requests/repair_request_image_RR-20260308143025123456789_2.jpg",
          "imageable_type": "App\\Models\\RepairRequest",
          "imageable_id": "RR-20260308143025123456789"
        }
      ],
      "created_at": "2026-03-08T14:30:25.000000Z",
      "updated_at": "2026-03-08T14:30:25.000000Z",
      "deleted_at": null
    }
  }
}

Error Responses

401 Unauthorized

{
  "success": false,
  "message": "Unauthenticated"
}

403 Forbidden

Returned when the authenticated user does not have ADMIN role.
{
  "success": false,
  "message": "This action is unauthorized"
}

422 Validation Error

Returned when the request data fails validation.
{
  "success": false,
  "message": "The given data was invalid",
  "errors": {
    "customer_name": [
      "The customer name field is required."
    ],
    "customer_email": [
      "The customer email must be a valid email address."
    ],
    "repair_status": [
      "The repair status must be one of: pending, in_progress, waiting_parts, completed, delivered, canceled."
    ]
  }
}

500 Internal Server Error

Returned when there’s an error during the creation process (e.g., database or file storage failure).
{
  "success": false,
  "message": "Repair request creation failed",
  "errors": {
    "exception": "Error message details"
  }
}

Notes

  • The receipt_number is automatically generated with format: RR-
  • Images are stored in the repair_requests directory with the naming pattern: repair_request_image_{receipt_number}_{index}.{extension}
  • The operation is wrapped in a database transaction to ensure data integrity
  • If the transaction fails (e.g., image upload error), all changes are rolled back
  • All image files must be in jpeg, png, or jpg format

Build docs developers (and LLMs) love