API Docs

Authentication

To use the Ping API, you need to authenticate using an API key. You can obtain your API key from the Ping dashboard.

Ping API supports two authentication methods for different use cases:

API Key Authentication

For programmatic access, use API keys in the Authorization header of your requests. This is the recommended method for server-side integrations.

API Key Formats

  • Test Publishable: pk_test_[32-char-string] - For client-side testing
  • Live Publishable: pk_live_[32-char-string] - For client-side production
  • Test Secret: sk_test_[32-char-string] - For server-side testing
  • Live Secret: sk_live_[32-char-string] - For server-side production

Authorization Header Format

Authorization: Bearer YOUR_API_KEY

Bearer Token Authentication

For authenticated users through the web application, use Bearer tokens with user type headers:

Authorization: Bearer {access_token}
User-Type: user | adminuser | agent

Get Your API Keys

You can manage your API keys from your dashboard:

Ping Dashboard

Secure Your API Keys

  • Never commit API keys to version control
  • Do not use secret keys in client-side code
  • Use environment variables to store API keys
  • Rotate keys regularly if compromised
  • Use test keys for development and testing

API Endpoints

API requests made without authentication will fail with status code 401: Unauthorized. All API requests must be made over HTTPS.

Sample Request to Send SMS

cURL

curl -X POST https://api.ping.co.zw/v1/notification/api/sms/send \
-H "Authorization: Bearer sk_test_your_secret_key_here" \
-H "Content-Type: application/json" \
-d '{
  "to_phone": "+263771234567",
  "message": "Hello from Ping!",
  "sender_id": "PING"
}'

Python

import requests

url = "https://api.ping.co.zw/v1/notification/api/sms/send"
headers = {
    "Authorization": "Bearer sk_test_your_secret_key_here",
    "Content-Type": "application/json"
}

data = {
    "to_phone": "+263771234567",
    "message": "Hello from Ping!",
    "sender_id": "PING"
}

response = requests.post(url, headers=headers, json=data)

if response.status_code == 200:
    print("SMS sent successfully:", response.json())
else:
    print("Error:", response.status_code, response.text)

Environment Detection

The API automatically detects the environment based on your API key prefix:

  • Test keys (pk_test_, sk_test_) → Test environment
  • Live keys (pk_live_, sk_live_) → Production environment