Troubleshooting Guide
This guide helps you diagnose and resolve common issues with the Audian API.
Authentication Issues​
Error: "invalid_api_key"​
Symptom: All API requests return 401 Unauthorized with message "The API key provided is invalid"
Causes:
- API key is missing from the request
- API key is malformed or expired
- API key is for the wrong environment (test vs. live)
- API key has been revoked
Diagnosis:
# Check if API key is set
echo $AUDIAN_API_KEY
# Verify API key format (should start with 'sk_live_' or 'sk_test_')
echo $AUDIAN_API_KEY | grep -E '^sk_(live|test)_'
Solutions:
- Verify API Key Exists
const apiKey = process.env.AUDIAN_API_KEY;
if (!apiKey) {
throw new Error('AUDIAN_API_KEY environment variable not set');
}
- Check API Key Format
# Correct format
sk_live_XXXXXXXXXXXXXXXXXXXX
sk_test_XXXXXXXXXXXXXXXXXXXX
- Regenerate API Key
- Log in to your Audian Dashboard
- Go to Settings > API Keys
- Click "Regenerate" to create a new key
- Update your environment variables
- Verify Authorization Header
curl -H "X-Auth-Token: sk_live_..." https://api.audian.com:8443/v2/numbers
Error: "missing_authentication"​
Symptom: API requests return 401 Unauthorized with message "Authentication credentials were not provided"
Cause: The Authorization header is missing or improperly formatted
Solution:
Ensure the Authorization header is included:
curl \
-H "X-Auth-Token: YOUR_API_KEY" \
https://api.audian.com:8443/v2/numbers
JavaScript SDK:
const client = new AudianClient({
apiKey: 'YOUR_API_KEY'
});
Request Validation Issues​
Error: "invalid_phone_number"​
Symptom: Phone number operations fail with "The phone number must be in E.164 format"
Valid Formats:
- E.164 (International standard):
+14155551234 - Must start with
+ - Must include country code (1 for US/Canada)
- No spaces, dashes, or parentheses
Common Mistakes:
| Invalid | Valid | Notes |
|---|---|---|
| 415-555-1234 | +14155551234 | Remove formatting |
| (415) 555-1234 | +14155551234 | Remove parentheses |
| 1-415-555-1234 | +14155551234 | Remove hyphens, add + |
| 4155551234 | +14155551234 | Add + and country code |
Solution:
function formatPhoneNumber(input) {
// Remove all non-digit characters except +
let digits = input.replace(/[^\d+]/g, '');
// If doesn't start with +, assume US
if (!digits.startsWith('+')) {
digits = '+1' + digits.replace(/^1/, '');
}
return digits;
}
// Test
console.log(formatPhoneNumber('415-555-1234')); // +14155551234
console.log(formatPhoneNumber('(415) 555-1234')); // +14155551234
console.log(formatPhoneNumber('4155551234')); // +14155551234
Error: "invalid_location"​
Symptom: Number search fails with "The location must be in format: country-state-areacode"
Valid Location Formats:
US-CA-415(Country-State-Area Code)US-NY(Country-State)US(Country only)
Common Mistakes:
| Invalid | Valid | Notes |
|---|---|---|
| California | US-CA | Use state abbreviation |
| CA-415 | US-CA-415 | Include country code |
| USA-CA | US-CA | Use country code (US, CA, GB, etc.) |
| 415 | US-CA-415 | Include country and state |
Solution:
function validateLocation(location) {
const parts = location.split('-');
if (parts.length < 1 || parts.length > 3) {
throw new Error('Invalid location format');
}
// Check country code (2-3 characters)
if (parts[0].length < 2 || parts[0].length > 3) {
throw new Error('Invalid country code');
}
// Check state code if provided (2 characters)
if (parts.length > 1 && parts[1].length !== 2) {
throw new Error('Invalid state code');
}
// Check area code if provided (3 digits)
if (parts.length > 2 && !/^\d{3}$/.test(parts[2])) {
throw new Error('Invalid area code');
}
return true;
}
Rate Limiting Issues​
Error: "rate_limit_error"​
Symptom: API requests fail with HTTP 429 "Too many requests"
Causes:
- Requests exceed rate limit (e.g., 1000/hour)
- Monthly request quota exceeded
- Burst rate limit exceeded
Diagnosis:
// Check rate limit headers
const response = await client.numbers.list();
console.log('Limit:', response.headers['x-ratelimit-limit']);
console.log('Remaining:', response.headers['x-ratelimit-remaining']);
console.log('Reset:', new Date(response.headers['x-ratelimit-reset'] * 1000));
Solutions:
- Implement Exponential Backoff
async function requestWithRetry(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (error.status === 429) {
const retryAfter = parseInt(error.headers['retry-after'] || '60');
console.log(`Rate limited. Waiting ${retryAfter}s...`);
await sleep(retryAfter * 1000);
} else {
throw error;
}
}
}
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
- Implement Request Queuing
class RequestQueue {
constructor(rateLimit = 1000, interval = 3600000) {
this.rateLimit = rateLimit;
this.interval = interval;
this.requests = [];
}
async execute(fn) {
const now = Date.now();
this.requests = this.requests.filter(t => now - t < this.interval);
if (this.requests.length >= this.rateLimit) {
const oldest = this.requests[0];
const waitTime = this.interval - (now - oldest);
await sleep(waitTime);
}
this.requests.push(Date.now());
return await fn();
}
}
// Usage
const queue = new RequestQueue(1000, 3600000); // 1000 requests/hour
const numbers = await queue.execute(() =>
client.numbers.search({ location: 'US-CA-415' })
);
- Cache Responses
class CacheLayer {
constructor(ttl = 300000) { // 5 minutes
this.cache = new Map();
this.ttl = ttl;
}
async get(key, fn) {
const cached = this.cache.get(key);
if (cached && Date.now() - cached.time < this.ttl) {
return cached.data;
}
const data = await fn();
this.cache.set(key, { data, time: Date.now() });
return data;
}
}
// Usage
const cache = new CacheLayer();
const numbers = await cache.get('numbers-us-ca-415', () =>
client.numbers.search({ location: 'US-CA-415' })
);
- Contact Support to Increase Limits
- Log in to Audian Dashboard
- Go to Settings > Rate Limits
- Request higher limits
- Provide use case details
Resource Not Found Issues​
Error: "not_found_error"​
Symptom: API requests return 404 "The requested resource was not found"
Common Causes:
- Resource ID is incorrect
- Resource has been deleted
- Resource belongs to a different account
- Resource ID format is wrong
Diagnosis:
// Verify resource exists
try {
const number = await client.numbers.get('num_abc123');
console.log('Resource found:', number);
} catch (error) {
if (error.code === 'not_found_error') {
console.log('Resource not found');
// List all numbers to verify ID
const all = await client.numbers.list();
console.log('Available numbers:', all.data.numbers);
}
}
Solutions:
- Verify Resource ID
// List all numbers to find the correct ID
const response = await client.numbers.list({ limit: 100 });
const numberIds = response.data.numbers.map(n => n.id);
console.log('Available IDs:', numberIds);
// Use the correct ID
const number = await client.numbers.get(numberIds[0]);
- Check Resource Ownership
// Verify the resource belongs to your account
const response = await client.numbers.list({
limit: 100,
status: 'active'
});
const owned = response.data.numbers.find(n => n.id === 'num_abc123');
if (!owned) {
console.log('This number is not owned by your account');
}
Payment and Billing Issues​
Error: "insufficient_funds"​
Symptom: Operations fail with HTTP 402 "Your account does not have sufficient funds"
Causes:
- Account balance is too low
- Payment method failed
- Subscription expired
- Credit limit exceeded
Solutions:
- Check Account Balance
const account = await client.accounts.get();
console.log('Balance:', account.data.balance);
console.log('Credit Limit:', account.data.creditLimit);
- Add Funds
- Log in to Audian Dashboard
- Go to Billing > Payment Methods
- Add a credit card or prepaid credits
- Enable Auto-Recharge
- Go to Billing > Auto-Recharge
- Set up automatic payment when balance drops below threshold
Webhook Issues​
Webhook Not Being Delivered​
Causes:
- Webhook endpoint is not returning 200 OK
- Endpoint is timing out
- Firewall blocking requests
- Endpoint URL is incorrect
Diagnosis:
# Test webhook endpoint manually
curl -X POST https://your-domain.com/webhook \
-H "Content-Type: application/json" \
-H "X-Audian-Signature: whsig_..." \
-d '{"type":"test","data":{}}'
# Should return 200 OK within 5 seconds
Solution:
// Webhook handler should respond quickly
app.post('/webhook', async (req, res) => {
// Return 200 immediately
res.status(200).json({ success: true });
// Process webhook asynchronously
processWebhookAsync(req.body).catch(console.error);
});
async function processWebhookAsync(event) {
// Verify signature
const verifier = new WebhookVerifier({ signingSecret: '...' });
try {
verifier.verify(event, signature);
} catch (error) {
console.error('Invalid signature');
return;
}
// Handle event
switch (event.type) {
case 'sms.received':
await handleSMS(event.data);
break;
}
}
Getting Help​
If you're still experiencing issues:
- Check Documentation: Review the relevant API endpoint documentation
- Check Status Page: Visit status.audian.com for service status
- Enable Debug Logging: Enable debug mode in the SDK
- Contact Support: Email support@audian.com with:
- API endpoint being used
- Error code and message
- Request ID (from response headers)
- Steps to reproduce
- Environment details (SDK version, language, OS)
Enable Debug Mode​
JavaScript:
const client = new AudianClient({
apiKey: 'YOUR_API_KEY',
debug: true
});
Python:
import logging
logging.basicConfig(level=logging.DEBUG)
client = AudianClient(api_key='YOUR_API_KEY', debug=True)
Go:
client := audian.NewClient(
audian.WithAPIKey("YOUR_API_KEY"),
audian.WithDebug(true),
)