S
ShadhinPay Docs

Authentication

Learn how to authenticate your API requests to ShadhinPay

Authentication

All API requests to ShadhinPay require authentication using your API credentials. This guide explains how to obtain and use your credentials securely.

API Credentials

You need three credentials to authenticate API requests:

CredentialDescription
Client-IdYour unique client identifier
Business-IdThe ID of the business making the request
Secret-KeyYour secret API key (keep this private!)

Getting Your Credentials

  1. Log in to your ShadhinPay Dashboard
  2. Navigate to SettingsAPI Keys
  3. Click Generate New Keys if you haven't already
  4. Copy all three credentials and store them securely

Security Warning: Never expose your Secret-Key in:

  • Client-side JavaScript
  • Mobile app source code
  • Public GitHub repositories
  • Browser network requests

Making Authenticated Requests

Include all three credentials in the request headers:

cURL
curl -X GET https://api.shadhinpay.com/api/v1/payments \
  -H "Client-Id: cl_live_abc123" \
  -H "Business-Id: bus_xyz789" \
  -H "Secret-Key: sk_live_secret_key_here"
JavaScript
const headers = {
  'Client-Id': process.env.SHADHINPAY_CLIENT_ID,
  'Business-Id': process.env.SHADHINPAY_BUSINESS_ID,
  'Secret-Key': process.env.SHADHINPAY_SECRET_KEY,
  'Content-Type': 'application/json',
};

const response = await fetch('https://api.shadhinpay.com/api/v1/payments', {
  headers,
});
Python
import os
import requests

headers = {
    'Client-Id': os.environ['SHADHINPAY_CLIENT_ID'],
    'Business-Id': os.environ['SHADHINPAY_BUSINESS_ID'],
    'Secret-Key': os.environ['SHADHINPAY_SECRET_KEY'],
    'Content-Type': 'application/json',
}

response = requests.get(
    'https://api.shadhinpay.com/api/v1/payments',
    headers=headers
)

Test vs Live Credentials

ShadhinPay provides separate credentials for testing and production:

EnvironmentPrefixBase URL
Sandboxcl_test_, sk_test_https://sandbox.shadhinpay.com/api/v1
Productioncl_live_, sk_live_https://api.shadhinpay.com/api/v1

Use sandbox credentials during development. Switch to live credentials only when you're ready for production.

Authentication Errors

If authentication fails, you'll receive one of these errors:

Status CodeErrorDescription
401INVALID_CLIENT_IDClient-Id header is missing or invalid
401INVALID_BUSINESS_IDBusiness-Id header is missing or invalid
401INVALID_SECRET_KEYSecret-Key is incorrect
403BUSINESS_NOT_AUTHORIZEDBusiness doesn't have access to this resource
Error Response
{
  "success": false,
  "error": {
    "code": "INVALID_SECRET_KEY",
    "message": "The provided secret key is invalid"
  }
}

Best Practices

  1. Use environment variables - Never hardcode credentials
  2. Rotate keys regularly - Generate new keys periodically
  3. Use separate keys per environment - Different keys for dev/staging/prod
  4. Monitor API usage - Check your dashboard for unusual activity
  5. Restrict key permissions - Use business-specific keys when possible

Next Steps

On this page