Lewati ke konten utama

๐Ÿ”Œ 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โ€‹

  1. Login ke dashboard PintarX
  2. Buka menu Settings โ†’ API Keys
  3. Klik Generate New API Key
  4. Copy dan simpan API Key Anda
API Key: pintarx_live_1234567890abcdefghijklmnop
Keamanan

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 numbers
  • GET /whatsapp/qr/:deviceId - Get QR code for pairing
  • POST /whatsapp/disconnect/:deviceId - Disconnect device

Messagesโ€‹

  • POST /messages/send - Send single message
  • POST /messages/send-bulk - Send bulk messages
  • POST /messages/send-template - Send using template
  • GET /messages/:messageId - Get message status
  • GET /message-logs - Get message history

Contactsโ€‹

  • GET /contacts - List all contacts
  • POST /contacts - Create new contact
  • GET /contacts/:contactId - Get contact detail
  • PUT /contacts/:contactId - Update contact
  • DELETE /contacts/:contactId - Delete contact
  • POST /contacts/import - Bulk import contacts

Templatesโ€‹

  • GET /templates - List all templates
  • POST /templates - Create new template
  • GET /templates/:templateId - Get template detail
  • PUT /templates/:templateId - Update template
  • DELETE /templates/:templateId - Delete template

Auto Replyโ€‹

  • GET /auto-reply/rules - List auto reply rules
  • POST /auto-reply/rules - Create auto reply rule
  • PUT /auto-reply/rules/:ruleId - Update rule
  • DELETE /auto-reply/rules/:ruleId - Delete rule

AI (Coming Soon)โ€‹

  • GET /ai/settings - Get AI configuration
  • PUT /ai/settings - Update AI settings
  • GET /ai/knowledge - List knowledge base
  • POST /ai/knowledge - Add knowledge entry
  • POST /ai/test - Test AI response

Webhooksโ€‹

  • GET /webhooks - List webhook configs
  • POST /webhooks - Create webhook
  • PUT /webhooks/:webhookId - Update webhook
  • DELETE /webhooks/:webhookId - Delete webhook

๐Ÿ” Authenticationโ€‹

API Key Typesโ€‹

TypeFormatUsage
Livepintarx_live_xxxProduction environment
Testpintarx_test_xxxDevelopment/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โ€‹

CodeMeaning
200Success
201Created
400Bad Request (invalid parameters)
401Unauthorized (invalid API key)
403Forbidden (insufficient permissions)
404Not Found
429Rate Limit Exceeded
500Internal Server Error

๐Ÿšฆ Rate Limitingโ€‹

Limits by Planโ€‹

PlanRequests/MinuteRequests/Day
Lite101,000
Pro6010,000
Business300100,000
Enterprise1,000Unlimited

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 masuk
  • message.sent - Pesan terkirim
  • message.delivered - Pesan delivered
  • message.read - Pesan dibaca
  • message.failed - Pesan gagal
  • device.connected - WhatsApp connected
  • device.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โ€‹

PlanAPI Calls/Month
Lite10,000
Pro100,000
Business500,000
EnterpriseUnlimited

๐Ÿ“Œ 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