// 01 REST API

API Reference

Base URL: https://www.scriptinphp.com/samples/api/  ·  3 registered users  ·  All endpoints return JSON

● LIVE Health Check ↗
GET?action=healthPublic

Returns system status, PHP version, database connectivity, and user count. No authentication required.

POST?action=loginPublic

Authenticate with email and password. Returns a 24-hour bearer token. Include in subsequent requests via the X-Token header.

ParameterTypeRequiredDescription
emailstring YesUser email address
passwordstring YesAccount password
POST?action=registerPublic

Create a new user account. Validates email format, checks for duplicates, hashes password with bcrypt.

ParameterTypeRequiredDescription
namestring YesFull name
emailstring YesEmail address (must be unique)
passwordstring YesMinimum 6 characters
GET?action=validate&token=TOKENToken

Validate an existing token. Returns user info if valid, 401 if expired or invalid. Log in first to get a token.

GET?action=profileToken Required

Returns full profile of the authenticated user. Send token via X-Token header.

GET?action=usersToken Required

Returns paginated list of registered sample users (max 20). Requires valid authentication token.

POST?action=logoutToken Required

Invalidates the current session token. Token is immediately revoked server-side.