Authentication
Endpoints for user authentication, registration, login, logout, and password management.
missing_translation: api_documentation.endpoints
POST /api/auth - Authentication
Authenticate, register, refresh tokens, reset password, and logout using these endpoints.
action - The authentication action to perform (login, register, refresh, forgot-password, reset-password)email - User email addresspassword - User passwordname - User name (for registration)remember_me - Boolean for remember me functionalitytwofa_code - Two-factor authentication code (if enabled)is_newsletter_subscribed - Boolean for newsletter subscriptionrefresh_token - Refresh token for token refreshcode - Reset code for password reset
Login
POST https://oqp.link/api/authBody:
{
"action": "login",
"email": "user@example.com",
"password": "password123",
"remember_me": true
}
Register
POST https://oqp.link/api/authBody:
{
"action": "register",
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
"is_newsletter_subscribed": false
}
Refresh Token
POST https://oqp.link/api/authBody:
{
"action": "refresh",
"refresh_token": "your_refresh_token_here"
}
Forgot Password
POST https://oqp.link/api/authBody:
{
"action": "forgot-password",
"email": "user@example.com"
}
Reset Password
POST https://oqp.link/api/authBody:
{
"action": "reset-password",
"code": "reset_code_from_email",
"password": "new_password123"
}
Success Response (Login/Register)
{
"data": {
"user": {
"id": 1,
"email": "user@example.com",
"name": "John Doe",
"type": 0,
"status": 1,
"plan_id": "free",
"plan_expiration_date": "2024-01-01 12:00:00",
"plan_settings": {...},
"language": "english",
"currency": "USD",
"timezone": "UTC",
"datetime": "2024-01-01 12:00:00",
"last_activity": "2024-01-01 12:00:00"
},
"access_token": "your_access_token_here",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "your_refresh_token_here",
"refresh_expires_in": 2592000
}
}
Error Response
{
"errors": [
{
"title": "Invalid credentials",
"status": "401"
}
]
}
DELETE /api/auth - Logout
Logout and invalidate the current access token.
Authorization: Bearer your_access_token_here
{
"data": {
"message": "Logged out successfully"
}
}
missing_translation: api_documentation.error_codes
| missing_translation: api_documentation.status_code | missing_translation: api_documentation.description |
|---|---|
200 |
missing_translation: api_documentation.success |
201 |
missing_translation: api_documentation.created |
400 |
missing_translation: api_documentation.bad_request |
401 |
missing_translation: api_documentation.unauthorized |
403 |
missing_translation: api_documentation.forbidden |
409 |
missing_translation: api_documentation.conflict |
429 |
missing_translation: api_documentation.too_many_requests |
missing_translation: api_documentation.usage_examples
JavaScript (Fetch)
// Login
const loginResponse = await fetch('https://oqp.link/api/auth', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
action: 'login',
email: 'user@example.com',
password: 'password123',
remember_me: true
})
});
const loginData = await loginResponse.json();
const accessToken = loginData.data.access_token;
// Use the token for authenticated requests
const vcardsResponse = await fetch('https://oqp.link/api/vcards', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
// Logout
await fetch('https://oqp.link/api/auth', {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
cURL
# Login
curl -X POST 'https://oqp.link/api/auth' \
-H 'Content-Type: application/json' \
-d '{
"action": "login",
"email": "user@example.com",
"password": "password123"
}'
# Get vCards (with token)
curl -X GET 'https://oqp.link/api/vcards' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
# Logout
curl -X DELETE 'https://oqp.link/api/auth' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
PHP
// Login
$loginData = [
'action' => 'login',
'email' => 'user@example.com',
'password' => 'password123'
];
$ch = curl_init('https://oqp.link/api/auth');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($loginData));
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$loginResult = json_decode($response, true);
$accessToken = $loginResult['data']['access_token'];
// Use token for authenticated requests
$ch = curl_init('https://oqp.link/api/vcards');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $accessToken
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$vcards = json_decode($response, true);