πŸ”Authentication

The Authorization section of the API documentation provides endpoints for user authentication and session management. These endpoints allow users to log in to the system, obtain a JWT token for subsequent authenticated requests, and log out of the system. The token obtained from the login endpoint must be included in the headers of all protected API requests to verify the user's identity and permissions.

Login

  • Endpoint: POST /api/login

  • Headers:

    apikey: your_api_key_here
    Content-Type: application/json
  • Request Body:

    {
      "email": "[email protected]",
      "password": "your-password"
    }
  • Response:

    • Success:

      {
          "success": true,
          "message": "Login successfully",
          "data": {
              "id": 1,
              "name": "John Smith",
              "role_id": 1,
              "phone": "",
              "email": "[email protected]",
              "location": "",
              "profile_image": "https://example.com/public/images/default/user.jpg",
              "token": "your_jwt_token_here"
          }
      }
    • Error (Invalid Credentials):

      {
        "message": "invalid_credentials",
        "errors": [],
        "code": 401
      }
    • Error (Validation Failure):

      {
        "message": "required_field_missing",
        "errors": { "email": ["The email field is required."], "password": ["The password field is required."] },
        "code": 422
      }
    • Error (API Key Missing):

      {
        "success": false,
        "message": "API key missing",
        "data": []
      }

Logout

  • Endpoint: POST /api/logout

  • Headers:

  • Request Body: None

  • Response:

    • Success:

    • Error:

Last updated