Authentication
These endpoints allow you to manage user authentication, including login and registration.
The auth response
When successfully authenticated, you'll receive a response containing user information and a Bearer token for API access.
Properties
- Name
success
- Type
- boolean
- Description
Indicates if the operation was successful.
- Name
message
- Type
- string
- Description
A human-readable message about the operation result.
- Name
data
- Type
- object
- Description
- Name
user
- Type
- object
- Description
Object containing user information (name, email).
- Name
token
- Type
- string
- Description
Bearer token for API authentication.
- Name
token_type
- Type
- string
- Description
Type of token (always "Bearer").
Register
Create a new user account and receive an authentication token.
Required attributes
- Name
name
- Type
- string
- Description
The user's full name.
- Name
email
- Type
- string
- Description
A valid email address.
- Name
password
- Type
- string
- Description
The user's password.
Request
curl -X POST https://api.tradevps.net/v1/auth/register \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "Test TradeVPS",
"email": "[email protected]",
"password": "secretpass"
}'
Response 200
{
"success": true,
"message": "Your account has been created.",
"data": {
"user": {
"name": "Test TradeVPS",
"email": "[email protected]"
},
"token": "3|tX1Iy3xuaU215jLAxSnYBaL7BE1BlCxze0HYcndv23881b8d",
"token_type": "Bearer"
}
}
Response 422
{
"message": "The email has already been taken.",
"errors": {
"email": [
"The email has already been taken."
]
}
}
Login
Authenticate a user and retrieve a token.
Required attributes
- Name
email
- Type
- string
- Description
The user's email address.
- Name
password
- Type
- string
- Description
The user's password.
Request
curl -X POST https://api.tradevps.net/v1/auth/login \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "secretpass"
}'
Response 200
{
"success": true,
"message": "Login success",
"data": {
"user": {
"name": "Test TradeVPS",
"email": "[email protected]"
},
"token": "4|JTPVrCmTWPznZKO3uRflyIwOJwZGEfklxKpKzG1u00da2a6f",
"token_type": "Bearer"
}
}
Response 404
{
"success": false,
"message": "Invalid email or password",
"data": null
}
Logout
Invalidate the current user's authentication token.
Required headers
- Name
Authorization
- Type
- string
- Description
The Bearer token to invalidate.
Request
curl -X POST https://api.tradevps.net/v1/auth/logout \
-H "Accept: application/json" \
-H "Authorization: Bearer {token}"
Response 200
{
"ok": true,
"msg": "Logout successfully",
"data": null
}
Forgot Password
Request a password reset code. The code will be sent to the provided email address.
Required attributes
- Name
email
- Type
- string
- Description
The email address associated with the account.
Request
curl -X POST https://api.tradevps.net/v1/auth/forgot-password \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]"
}'
Responses
Response 200
{
"ok": true,
"msg": "Reset code sent to your email",
"data": null
}
Response 422
{
"message": "The email field is required.",
"errors": {
"email": [
"The email field is required."
// or "The selected email is invalid."
]
}
}
Possible Validation Errors
- Email is required
- Email must be valid and exist in the system
Reset Password
Reset user's password using the verification code received via email.
Warning: Resetting your password will automatically revoke all existing API tokens. You will need to generate new tokens either by using the login endpoint or creating new tokens after resetting your password.
Required attributes
- Name
email
- Type
- string
- Description
The email address associated with the account. Must be a valid email that exists in the system.
- Name
code
- Type
- string
- Description
The 6-digit verification code sent to the email.
- Name
password
- Type
- string
- Description
The new password. Must be at least 8 characters long.
- Name
password_confirmation
- Type
- string
- Description
Must match the password field.
Request
curl -X POST https://api.tradevps.net/v1/auth/reset-password \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"code": "767023",
"password": "password2",
"password_confirmation": "password2"
}'
Response 200
{
"ok": true,
"msg": "Password reset successfully",
"data": null
}
Response 422
{
"message": "The email field is required. (and 2 more errors)",
"errors": {
"email": ["The email field is required."],
"code": ["The code field is required."],
"password": ["The password field is required."]
}
}