Login to obtain an access token for authenticating subsequent API requests.
POST /api/v1/login
| Header | Required | Description |
|---|---|---|
Content-Type |
Yes | application/json |
Accept |
Yes | application/json |
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
string | Yes | Your app_id |
password |
string | Yes | Your app_secret |
{
"username": "app_id",
"password": "app_secret"
}
{
"success": true,
"message": "Login successful",
"data": {
"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"token_type": "Bearer",
"expires_in": 3600,
"merchant_id": "MERCHANT001",
"merchant_name": "Your Merchant Name"
},
"meta": {
"timestamp": "2024-01-15T10:30:00Z"
}
}
| Field | Type | Description |
|---|---|---|
access_token |
string | JWT access token for API authentication |
token_type |
string | Token type (always "Bearer") |
expires_in |
integer | Token expiration time in seconds |
merchant_id |
string | Your unique merchant ID |
merchant_name |
string | Your merchant display name |
<?php
$data = [
'username' => 'app_id',
'password' => 'app_secret'
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://openapi.payara.id:7654/api/v1/login',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json'
),
));
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
if ($httpCode === 200) {
$result = json_decode($response, true);
$accessToken = $result['data']['access_token'];
echo "Login successful. Token: " . $accessToken;
} else {
echo "Login failed";
}
const loginData = {
username: 'app_id',
password: 'app_secret'
};
try {
const response = await fetch('https://openapi.payara.id:7654/api/v1/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify(loginData)
});
if (response.ok) {
const result = await response.json();
const accessToken = result.data.access_token;
console.log('Login successful. Token:', accessToken);
// Store token for subsequent requests
localStorage.setItem('swiftrans_token', accessToken);
} else {
console.error('Login failed');
}
} catch (error) {
console.error('Login error:', error);
}
curl -X POST https://openapi.payara.id:7654/api/v1/login \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"username": "app_id",
"password": "app_secret"
}'
Once you have obtained an access token, include it in the Authorization header of all subsequent API requests:
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...
Access tokens expire after 1 hour (3600 seconds). You should:
expires_in value from the login response{
"success": false,
"message": "Invalid username or password",
"error_code": "INVALID_CREDENTIALS"
}
{
"success": false,
"message": "Merchant account is suspended",
"error_code": "ACCOUNT_SUSPENDED"
}
{
"success": false,
"message": "Too many login attempts. Please try again later",
"error_code": "TOO_MANY_ATTEMPTS"
}