Best Practices
This page provides recommendations and best practices for using the Vibe Mobi SIM Activation API effectively.
Authentication
- Token Management: Store your access token securely and refresh it before expiration.
- Credential Security: Never hardcode credentials in your application code. Use environment variables or secure credential storage.
- Error Handling: Implement proper error handling for authentication failures, including automatic retry with new token generation when a token expires.
SIM Activation
Transaction IDs
Always generate a unique transaction_id for each request to ensure proper tracking. This ID should:
- Be unique across all requests
- Be stored in your system for future reference
- Follow a consistent format for easy identification
Example implementation:
import uuid
import time
def generate_transaction_id(prefix="TRANS"):
"""Generate a unique transaction ID with timestamp and UUID."""
timestamp = int(time.time())
unique_id = str(uuid.uuid4())[:8]
return f"{prefix}_{timestamp}_{unique_id}"
Default Action
Use the default action new_number_activation_with_zip_code unless a specific action is required for your use case. This action:
- Assigns a new phone number based on the provided ZIP code
- Activates the SIM with standard settings
- Works for both physical SIMs and eSIMs
Source Parameter
Always include the source parameter to identify the origin of the activation request. This helps with:
- Tracking activations across different platforms
- Troubleshooting issues specific to certain integration points
- Analyzing activation patterns and success rates
Error Handling
Implement robust error handling in your application:
- Retry Logic: Implement appropriate retry logic for transient errors, with exponential backoff.
- Validation: Validate all required fields before submitting to avoid preventable errors.
- Logging: Log all requests, responses, and errors for troubleshooting.
- User Feedback: Provide clear error messages to end-users based on the API responses.
Common Error Scenarios
| Error Scenario | Recommended Action |
|---|---|
| Invalid SIM | Verify SIM number format and check if it exists in inventory |
| Already Active SIM | Check if SIM is already activated or in use |
| Missing Required Fields | Validate all required fields before submission |
| Authentication Failures | Regenerate access token and retry |
Rate Limiting
The API implements rate limiting to prevent abuse. To avoid hitting rate limits:
- Cache authentication tokens until they expire
- Implement queuing for bulk operations
- Add delays between consecutive requests in batch processing
Testing
Before moving to production:
- Test with a variety of valid and invalid inputs
- Verify error handling works as expected
- Test the complete activation flow from authentication to activation
- Implement integration tests that simulate real-world scenarios
Security Considerations
- Use HTTPS for all API communications
- Implement IP whitelisting if available
- Rotate credentials periodically
- Monitor for unusual activity patterns
- Implement proper access controls for your application
By following these best practices, you can ensure a smooth integration with the Vibe Mobi SIM Activation API and provide a reliable service to your users.