Using the CRM PHP and Python SDKs
Introduction to the CRM PHP and Python SDKs
The CRM offers officially supported PHP and Python SDKs that provide a simplified way to integrate with the CRM's v2 Public API. These libraries handle complex authentication processes automatically, allowing you to focus on building your application's unique features rather than managing OAuth flows and token management.
Key Benefits of Using the SDKs
The SDKs provide several significant advantages for developers:
- Automatic OAuth 2.0 token exchange, storage, and refresh with minimal code
- Flexible database-agnostic session storage options including memory, MongoDB, Redis, MySQL, and others
- Built-in webhook signature validation and automatic processing of install/uninstall events
- Type-safe service methods for all public API endpoints, reducing boilerplate code and potential errors
- Automatic updates that keep your client synchronized with API changes
Supported OAuth 2.0 Workflows
The SDKs support various installation scenarios that developers commonly encounter:
- Sub-account installations through the Marketplace Connect button
- Bulk agency installations covering multiple locations simultaneously
- Automatic installations when new sub-accounts are created
- Daily automatic token refresh before expiration
- Clean uninstall cleanup processes
Database-Agnostic Token Storage
The SDKs offer pluggable storage adapters that work with your existing data persistence solutions. You can use in-memory caching for local development or integrate with MongoDB, Redis, MySQL, PostgreSQL, or implement your own custom storage class using the provided interface.
Automatic SDK Generation
Both PHP and Python SDKs are automatically generated from the OpenAPI specification whenever the CRM releases new endpoints or fields. This means you can update to the latest version with simple package manager commands (composer update for PHP or pip install --upgrade for Python), ensuring your integration remains current with minimal effort.
Frequently Asked Questions
Do I need to manually refresh tokens?
No. Once you configure session storage, the SDK automatically handles token refresh before expiration.
Can I use MySQL for token storage instead of MongoDB?
Yes. You can extend the provided storage base class with your own create/read/update logic for MySQL or any other database system.
Does the SDK support Private Integration Tokens?
Yes. You can pass a privateIntegrationToken parameter when OAuth flows aren't required for your use case.
How do I validate webhook signatures?
Use the appropriate webhook validation methods provided by the SDK: client.webhooks.subscribe() in Python or getWebhookManager()->verifySignature() in PHP.
Is the SDK compatible with v1 endpoints?
No. The SDK specifically targets the Public API v2 endpoints only.
Will updates break my code?
The SDK follows semantic versioning, with breaking changes triggering major version updates. This allows you to pin specific versions and upgrade deliberately when ready.