Skip to content

Auth - User

Base URL: https://your-domain.com

Authentication endpoints for Admin/Staff/Reseller users.


Login

Authenticate a user (Admin/Staff/Reseller) and receive an access token for API access.

PropertyValue
EndpointUser Login
MethodPOST
URL/api/v1/auth/login
AuthenticationNot Required

Request Headers:

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes

Request Body:

json
{
    "email": "[email protected]",
    "password": "your-password"
}
ParameterTypeRequiredDescription
emailstringYesUser's email address
passwordstringYesUser's password

Success Response (200 OK):

json
{
    "success": true,
    "message": "Login successful",
    "data": {
        "user": {
            "id": 1,
            "name": "Admin User",
            "email": "[email protected]",
            "role": "admin"
        },
        "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
        "token_type": "bearer",
        "expires_in": 3600
    }
}

Error Response (401 Unauthorized):

json
{
    "success": false,
    "message": "Invalid credentials"
}

Error Response (422 Validation Error):

json
{
    "success": false,
    "message": "Validation failed",
    "errors": {
        "email": ["The email field is required."],
        "password": ["The password field is required."]
    }
}

Logout

Invalidate the current access token and end the user session.

PropertyValue
EndpointUser Logout
MethodPOST
URL/api/v1/auth/logout
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Request Body: None

Success Response (200 OK):

json
{
    "success": true,
    "message": "Successfully logged out"
}

Error Response (401 Unauthorized):

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

Me (Get Current User)

Retrieve the authenticated user's profile information including permissions and role.

PropertyValue
EndpointGet Current User
MethodGET
URL/api/v1/auth/me
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Request Body: None

Success Response (200 OK):

json
{
    "success": true,
    "data": {
        "id": 1,
        "name": "Admin User",
        "email": "[email protected]",
        "phone": "01712345678",
        "role": "admin",
        "isp_id": 1,
        "branch_id": 1,
        "permissions": ["subscribers.view", "subscribers.create", "packages.view"]
    }
}

Error Response (401 Unauthorized):

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

Refresh Token

Refresh the access token to extend the session without re-authentication.

PropertyValue
EndpointRefresh Token
MethodPOST
URL/api/v1/auth/refresh
AuthenticationBearer Token

Request Headers:

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer your-auth-tokenYes

Request Body: None

Success Response (200 OK):

json
{
    "success": true,
    "data": {
        "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
        "token_type": "bearer",
        "expires_in": 3600
    }
}

Error Response (401 Unauthorized):

json
{
    "success": false,
    "message": "Token has expired and cannot be refreshed"
}

www.onezeroart.com