Authentication

Authentication API

The Authentication API allows you to register new users, authenticate them, and manage their profiles. All authentication endpoints are located under /api/v1/auth.

Register

Create a new user account.

Endpoint: POST /api/v1/auth/register

Request Parameters

ParameterTypeRequiredDescription
namestringYesFull name of the user
emailstringYesValid email address (must be unique)
passwordstringYesPassword (min 8 characters)
password_confirmationstringYesMust match password
application_idintegerNoID of the mobile application (if applicable)

Response (201 Created)

{
  "success": true,
  "message": "Registration successful",
  "data": {
    "user": {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com",
      "avatar": "https://...",
      "status": "active",
      "created_at": "2023-01-01T12:00:00.000000Z",
      "updated_at": "2023-01-01T12:00:00.000000Z"
    },
    "token": "1|sanctum_token_string..."
  }
}

Login

Authenticate an existing user and retrieve an API token.

Endpoint: POST /api/v1/auth/login

Request Parameters

ParameterTypeRequiredDescription
emailstringYesRegistered email address
passwordstringYesUser's password

Response (200 OK)

{
  "success": true,
  "message": "Login successful",
  "data": {
    "user": {
      "id": 1,
      "name": "John Doe",
      "email": "john@example.com",
      "avatar": "https://...",
      "status": "active",
      "created_at": "2023-01-01T12:00:00.000000Z",
      "updated_at": "2023-01-01T12:00:00.000000Z"
    },
    "token": "2|new_sanctum_token_string..."
  }
}

Get Current User

Retrieve the currently authenticated user's profile.

Endpoint: GET /api/v1/auth/me Authentication: Required (Bearer <token>)

Response (200 OK)

{
  "success": true,
  "data": {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com",
    "avatar": "https://...",
    "status": "active",
    "created_at": "2023-01-01T12:00:00.000000Z",
    "updated_at": "2023-01-01T12:00:00.000000Z"
  }
}

Verify Token

Verify if the current token is valid and the user account is active.

Endpoint: GET /api/v1/auth/verify Authentication: Required (Bearer <token>)

Response (200 OK)

{
  "success": true,
  "message": "Token is valid",
  "data": {
    "user": { ... },
    "status": "active"
  }
}

Error Response (403 Forbidden)

If the account is inactive or banned:

{
  "success": false,
  "message": "Account is inactive",
  "code": 403,
  "data": {
    "status": "inactive",
    "requires_logout": true
  }
}

Update Profile

Update the authenticated user's profile information.

Endpoint: PATCH /api/v1/auth/profile Authentication: Required (Bearer <token>)

Request Parameters

ParameterTypeRequiredDescription
namestringNoNew full name
emailstringNoNew email address (must be unique)

Response (200 OK)

{
  "success": true,
  "message": "Profile updated successfully",
  "data": {
    "id": 1,
    "name": "Jane Doe",
    "email": "jane@example.com",
    ...
  }
}

Update Password

Change the authenticated user's password.

Endpoint: PUT /api/v1/auth/password Authentication: Required (Bearer <token>)

Request Parameters

ParameterTypeRequiredDescription
current_passwordstringYesThe user's current password
passwordstringYesNew password (min 8 characters)
password_confirmationstringYesMust match the new password

Response (200 OK)

{
  "success": true,
  "message": "Password updated successfully",
  "data": null
}

Logout

Invalidate the current API token.

Endpoint: POST /api/v1/auth/logout Authentication: Required (Bearer <token>)

Response (200 OK)

{
  "success": true,
  "message": "Logged out successfully",
  "data": null
}