Errors

Check the HTTP status code first. When a request fails, the JSON body includes a message and, for validation errors, the fields that failed.

Send Accept: application/json so validation and authentication failures stay JSON.

Status codes

  • Name
    200
    Type
    Description

    The request succeeded. Creating a client or risk profile also returns 200 with the new resource.

  • Name
    401
    Type
    Description

    The bearer token is missing or invalid, or login credentials are wrong. The body is { "message": "Unauthenticated." } for a missing token, or { "message": "The provided credentials are incorrect." } for login.

  • Name
    403
    Type
    Description

    The user is authenticated but is not allowed to perform the action. Login returns this when the RiskAdvisor API feature is disabled.

  • Name
    404
    Type
    Description

    The record does not exist, or the risk profile has no auto insurance when you list or add drivers or vehicles. That auto-insurance case returns { "error": "No Auto Insurance for This RiskProfile" }.

  • Name
    422
    Type
    Description

    The payload failed validation, or the user has no team (No active team found.).

Validation bodies

Clients, risk profiles, drivers, and vehicles return field errors under details:

422 from client, risk profile, driver, or vehicle writes

{
  "message": "Invalid data send",
  "details": {
    "email": ["The email field is required."]
  }
}

Other endpoints use Laravel's default shape, with field errors under errors:

422 from other endpoints

{
  "message": "The client email field must be a valid email address.",
  "errors": {
    "client_email": ["The client email field must be a valid email address."]
  }
}

Archiving a client returns 200 and:

DELETE /api/clients/:id

{
  "message": "Client and related RiskProfiles archived successfully."
}