๐ API Overview
Dokumentasi lengkap REST API PintarX untuk integrasi dengan sistem Anda.
๐ฏ Apa itu PintarX API?โ
PintarX API adalah REST API yang memungkinkan Anda mengintegrasikan fitur WhatsApp automation dengan aplikasi atau sistem backend Anda.
Use Cases API:โ
- ๐ Automasi Workflow - Trigger pesan dari sistem CRM/ERP
- ๐ Sinkronisasi Data - Sync kontak, pesan, logs
- ๐ค Custom Logic - Build automation sesuai kebutuhan
- ๐ Notifikasi Real-time - Send alerts via WhatsApp
- ๐ฑ Multi-channel Integration - Integrasikan dengan channel lain
๐ Quick Startโ
1. Dapatkan API Keyโ
- Login ke dashboard PintarX
- Buka menu Settings โ API Keys
- Klik Generate New API Key
- Copy dan simpan API Key Anda
API Key: pintarx_live_1234567890abcdefghijklmnop
Jangan share API Key ke publik. Simpan dengan aman seperti password.
2. Base URLโ
Production: https://api.pintarx.space/v1
Sandbox: https://sandbox-api.pintarx.space/v1
3. Authenticationโ
Semua request harus include Bearer Token di header:
Authorization: Bearer pintarx_live_1234567890abcdefghijklmnop
4. Test Connectionโ
Test API Key Anda:
curl -X GET https://api.pintarx.space/v1/auth/me \
-H "Authorization: Bearer YOUR_API_KEY"
Response:
{
"success": true,
"data": {
"sellerId": "uuid-1234",
"businessName": "Toko Elektronik Jaya",
"email": "owner@tokojaya.com",
"plan": "business",
"apiQuota": {
"limit": 200000,
"used": 12345,
"remaining": 187655
}
}
}
๐ API Endpointsโ
Authenticationโ
GET /auth/me- Get current user info
WhatsApp Pairingโ
GET /whatsapp/devices- List connected WhatsApp numbersGET /whatsapp/qr/:deviceId- Get QR code for pairingPOST /whatsapp/disconnect/:deviceId- Disconnect device
Messagesโ
POST /messages/send- Send single messagePOST /messages/send-bulk- Send bulk messagesPOST /messages/send-template- Send using templateGET /messages/:messageId- Get message statusGET /message-logs- Get message history
Contactsโ
GET /contacts- List all contactsPOST /contacts- Create new contactGET /contacts/:contactId- Get contact detailPUT /contacts/:contactId- Update contactDELETE /contacts/:contactId- Delete contactPOST /contacts/import- Bulk import contacts
Templatesโ
GET /templates- List all templatesPOST /templates- Create new templateGET /templates/:templateId- Get template detailPUT /templates/:templateId- Update templateDELETE /templates/:templateId- Delete template
Auto Replyโ
GET /auto-reply/rules- List auto reply rulesPOST /auto-reply/rules- Create auto reply rulePUT /auto-reply/rules/:ruleId- Update ruleDELETE /auto-reply/rules/:ruleId- Delete rule
AI (Coming Soon)โ
GET /ai/settings- Get AI configurationPUT /ai/settings- Update AI settingsGET /ai/knowledge- List knowledge basePOST /ai/knowledge- Add knowledge entryPOST /ai/test- Test AI response
Webhooksโ
GET /webhooks- List webhook configsPOST /webhooks- Create webhookPUT /webhooks/:webhookId- Update webhookDELETE /webhooks/:webhookId- Delete webhook
๐ Authenticationโ
API Key Typesโ
| Type | Format | Usage |
|---|---|---|
| Live | pintarx_live_xxx | Production environment |
| Test | pintarx_test_xxx | Development/testing |
Header Formatโ
Authorization: Bearer pintarx_live_1234567890abcdefghijklmnop
Content-Type: application/json
Example Requestโ
curl -X POST https://api.pintarx.space/v1/messages/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"deviceId": "uuid-device",
"to": "6281234567890",
"message": "Halo dari API!"
}'
๐ฅ Response Formatโ
Success Responseโ
{
"success": true,
"data": {
// Response data
},
"message": "Operation successful",
"timestamp": "2024-01-15T10:30:45Z"
}
Error Responseโ
{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Phone number format invalid",
"details": {
"field": "to",
"issue": "Must start with country code"
}
},
"timestamp": "2024-01-15T10:30:45Z"
}
Status Codesโ
| Code | Meaning |
|---|---|
| 200 | Success |
| 201 | Created |
| 400 | Bad Request (invalid parameters) |
| 401 | Unauthorized (invalid API key) |
| 403 | Forbidden (insufficient permissions) |
| 404 | Not Found |
| 429 | Rate Limit Exceeded |
| 500 | Internal Server Error |
๐ฆ Rate Limitingโ
Limits by Planโ
| Plan | Requests/Minute | Requests/Day |
|---|---|---|
| Lite | 10 | 1,000 |
| Pro | 60 | 10,000 |
| Business | 300 | 100,000 |
| Enterprise | 1,000 | Unlimited |
Rate Limit Headersโ
Response headers include rate limit info:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1705315845
Handling Rate Limitsโ
If you exceed the limit:
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "API rate limit exceeded",
"details": {
"limit": 60,
"retryAfter": 42
}
}
}
Best Practice:
- Implement exponential backoff
- Cache responses when possible
- Batch requests using bulk endpoints
๐ Webhooksโ
Webhook Eventsโ
PintarX dapat send webhook ke URL Anda untuk event:
message.incoming- Pesan masukmessage.sent- Pesan terkirimmessage.delivered- Pesan deliveredmessage.read- Pesan dibacamessage.failed- Pesan gagaldevice.connected- WhatsApp connecteddevice.disconnected- WhatsApp disconnected
Webhook Payloadโ
{
"event": "message.incoming",
"timestamp": "2024-01-15T10:30:45Z",
"data": {
"messageId": "msg-12345",
"deviceId": "device-uuid",
"from": "6281234567890",
"message": "Halo, ada promo?",
"messageType": "text",
"timestamp": "2024-01-15T10:30:45Z"
}
}
Webhook Securityโ
Verify webhook authenticity using signature:
X-PintarX-Signature: sha256=abcdef1234567890...
Verify signature:
const crypto = require('crypto');
function verifyWebhook(payload, signature, secret) {
const hash = crypto
.createHmac('sha256', secret)
.update(JSON.stringify(payload))
.digest('hex');
return `sha256=${hash}` === signature;
}
๐ Code Examplesโ
JavaScript/Node.jsโ
const axios = require('axios');
const apiKey = 'pintarx_live_YOUR_API_KEY';
const baseURL = 'https://api.pintarx.space/v1';
const api = axios.create({
baseURL,
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
});
// Send message
async function sendMessage(deviceId, to, message) {
try {
const response = await api.post('/messages/send', {
deviceId,
to,
message
});
console.log('Message sent:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response.data);
throw error;
}
}
// Usage
sendMessage('device-uuid', '6281234567890', 'Halo dari API!');
Pythonโ
import requests
API_KEY = 'pintarx_live_YOUR_API_KEY'
BASE_URL = 'https://api.pintarx.space/v1'
headers = {
'Authorization': f'Bearer {API_KEY}',
'Content-Type': 'application/json'
}
# Send message
def send_message(device_id, to, message):
url = f'{BASE_URL}/messages/send'
payload = {
'deviceId': device_id,
'to': to,
'message': message
}
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
print('Message sent:', response.json())
return response.json()
else:
print('Error:', response.json())
raise Exception(response.json())
# Usage
send_message('device-uuid', '6281234567890', 'Halo dari Python!')
PHPโ
<?php
$apiKey = 'pintarx_live_YOUR_API_KEY';
$baseURL = 'https://api.pintarx.space/v1';
function sendMessage($deviceId, $to, $message) {
global $apiKey, $baseURL;
$url = $baseURL . '/messages/send';
$data = [
'deviceId' => $deviceId,
'to' => $to,
'message' => $message
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($statusCode == 200) {
echo "Message sent: " . $response . "\n";
return json_decode($response, true);
} else {
echo "Error: " . $response . "\n";
throw new Exception($response);
}
}
// Usage
sendMessage('device-uuid', '6281234567890', 'Halo dari PHP!');
?>
cURLโ
# Send message
curl -X POST https://api.pintarx.space/v1/messages/send \
-H "Authorization: Bearer pintarx_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"deviceId": "device-uuid",
"to": "6281234567890",
"message": "Halo dari cURL!"
}'
๐งช Testingโ
Postman Collectionโ
Download Postman collection:
Sandbox Environmentโ
Use sandbox for testing:
Sandbox URL: https://sandbox-api.pintarx.space/v1
Sandbox features:
- โ Test all endpoints
- โ No real messages sent
- โ Unlimited requests
- โ Mock responses
๐ API Quotaโ
Check Quotaโ
GET /auth/me
Response includes quota:
{
"apiQuota": {
"limit": 200000,
"used": 12345,
"remaining": 187655,
"resetAt": "2024-02-01T00:00:00Z"
}
}
Quota by Planโ
| Plan | API Calls/Month |
|---|---|
| Lite | 10,000 |
| Pro | 100,000 |
| Business | 500,000 |
| Enterprise | Unlimited |
๐ Langkah Selanjutnyaโ
Pelajari endpoint spesifik:
โก๏ธ Send Message - Kirim pesan via API
โก๏ธ Kembali ke Dokumentasi - Halaman utama dokumentasi
โ FAQ APIโ
Apakah API gratis?โ
API included dalam semua paket berbayar. Quota sesuai paket yang dipilih.
Apakah ada SDK official?โ
Belum ada SDK official. Tapi API menggunakan standard REST, bisa digunakan dengan library HTTP apapun.
Bagaimana cara test API tanpa mengirim pesan asli?โ
Gunakan Sandbox Environment untuk testing tanpa send pesan real.
Apakah API support GraphQL?โ
Saat ini hanya REST API. GraphQL support sedang dipertimbangkan.
Bagaimana cara report bug atau request feature API?โ
Email ke: api-support@pintarx.space atau buat ticket di dashboard.
Apakah ada dokumentasi OpenAPI/Swagger?โ
Ya, akses Swagger UI di: https://api.pintarx.space/docs