API Documentation
The PPM.Network API provides a simple and powerful way to integrate pay-per-message functionality into your applications. This documentation outlines the endpoints, request parameters, and response formats you'll use.
Authentication
All requests to the PPM.Network API must be authenticated using bearer token authentication.
// Example: Authenticating with your API key
fetch('https://api.ppm.network/endpoint', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
API Key Management
You will receive two types of API keys:
- Test Keys - Prefixed with
test_
for use in your development environment. - Live Keys - Prefixed with
live_
for use in production.
Always keep your API keys secure and never expose them in client-side code. Use environment variables or secure vaults to store your keys.
Sending Messages
To send a message to an influencer, use the /sendMessage
endpoint.
// POST /sendMessage
fetch('https://api.ppm.network/sendMessage', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: 'influencer_username', // Username of the recipient
from: 'user_id', // Your user's ID
message: 'Hello, I have a question about...',
credits: 10 // Credits to pay for the message
})
});
// Response
{
"success": true,
"message_id": "msg_12345",
"status": "sent",
"credits_used": 10,
"created_at": "2025-05-05T15:30:45Z"
}
Required Parameters
- to - The username of the influencer.
- from - The user ID of the sender.
- message - The content of the message (max 2000 characters).
- credits - The number of credits to pay for this message.
Receiving Replies
You can receive replies either by polling the API or setting up webhooks.
Option 1: Polling
// GET /messages/{message_id}
fetch('https://api.ppm.network/messages/msg_12345', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
// Response
{
"message_id": "msg_12345",
"status": "replied",
"original_message": "How do I cook beef wellington?",
"reply": "Start by searing the beef...",
"replied_at": "2025-05-06T10:15:30Z"
}
Option 2: Webhooks
Set up webhooks to receive real-time notifications when an influencer replies to a message.
// POST /configureWebhook
fetch('https://api.ppm.network/configureWebhook', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://your-app.com/webhooks/ppm',
events: ['message.replied', 'message.refunded']
})
});
// Example webhook payload for message.replied event
{
"event": "message.replied",
"message_id": "msg_12345",
"original_message": "How do I cook beef wellington?",
"reply": "Start by searing the beef...",
"replied_at": "2025-05-06T10:15:30Z",
"user_id": "user_6789",
"influencer": "gordon_ramsay"
}
Refunds & Disputes
If an influencer doesn't respond within 7 days, the system automatically issues a refund. You can also manually process refunds.
// POST /refundMessage
fetch('https://api.ppm.network/refundMessage', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message_id: 'msg_12345',
reason: 'no_response'
})
});
// Response
{
"success": true,
"message_id": "msg_12345",
"refunded_credits": 10,
"refund_id": "ref_67890",
"processed_at": "2025-05-12T08:45:22Z"
}
Credit Management
Manage user credits with these endpoints.
Add Credits
// POST /addCredits
fetch('https://api.ppm.network/addCredits', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
user_id: 'user_12345',
amount: 50,
source: 'stripe_payment_id' // Optional reference to payment
})
});
// Response
{
"success": true,
"user_id": "user_12345",
"previous_balance": 10,
"added_credits": 50,
"new_balance": 60,
"transaction_id": "txn_123456"
}
Check Balance
// GET /userCredits/{user_id}
fetch('https://api.ppm.network/userCredits/user_12345', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
// Response
{
"user_id": "user_12345",
"balance": 60,
"last_transaction": {
"id": "txn_123456",
"type": "add",
"amount": 50,
"timestamp": "2025-05-05T14:30:22Z"
}
}
Rate Limits
To ensure platform stability, the API implements rate limiting.
Endpoint | Rate Limit | Window |
---|---|---|
/sendMessage | 100 requests | 10 minutes |
/messages/{message_id} | 300 requests | 10 minutes |
/addCredits | 50 requests | 10 minutes |
All other endpoints | 200 requests | 10 minutes |
When a rate limit is exceeded, the API will return a 429 Too Many Requests
status code. The response will include X-RateLimit-Limit
, X-RateLimit-Remaining
, and X-RateLimit-Reset
headers to help you manage your request rate.