-
-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
MC0RE edited this page Mar 30, 2026
·
7 revisions
Getting started with the Teamleader SDK for Laravel.
composer require mcore-services/teamleader-sdkPublish the configuration file:
php artisan vendor:publish --tag=teamleader-configNo
php artisan migrateis required. The SDK automatically creates theteamleader_tokenstable on first use.
Add your credentials to .env:
TEAMLEADER_CLIENT_ID=your_client_id
TEAMLEADER_CLIENT_SECRET=your_client_secret
TEAMLEADER_REDIRECT_URI=${APP_URL}/teamleader/callbackKey options in config/teamleader.php:
| Option | Description |
|---|---|
api_version |
Teamleader API version |
timeouts.connection |
Connection timeout in seconds |
timeouts.read |
Read timeout in seconds |
retry.attempts |
Number of automatic retry attempts |
retry.delay |
Delay between retries in milliseconds |
error_handling.throw_exceptions |
Whether to throw exceptions (429 always throws) |
The SDK uses OAuth 2.0. Set up two routes in your application.
use McoreServices\TeamleaderSDK\Facades\Teamleader;
public function redirectToTeamleader()
{
return Teamleader::authorize();
}public function handleCallback(Request $request)
{
if (Teamleader::handleCallback($request->get('code'), $request->get('state'))) {
return redirect('/dashboard')->with('success', 'Connected to Teamleader!');
}
return redirect('/settings')->with('error', 'Connection failed.');
}if (Teamleader::isAuthenticated()) {
// Ready to make API calls
}Teamleader::logout();use McoreServices\TeamleaderSDK\Facades\Teamleader;
// List resources
$companies = Teamleader::companies()->list();
// Get a single resource
$contact = Teamleader::contacts()->info('contact-uuid');
// Create a resource
$deal = Teamleader::deals()->create([
'title' => 'New Opportunity',
'lead' => [
'customer' => ['type' => 'company', 'id' => 'company-uuid'],
],
]);
// Update a resource
Teamleader::companies()->update('company-uuid', ['name' => 'Acme Corp Ltd']);
// Delete a resource
Teamleader::companies()->delete('company-uuid');use McoreServices\TeamleaderSDK\TeamleaderSDK;
class CompanyService
{
public function __construct(private TeamleaderSDK $teamleader) {}
public function getActive(): array
{
return $this->teamleader->companies()->list(['status' => 'active']);
}
}Teamleader UUIDs are environment-specific. Store them in config/teamleader.php rather than scattering raw UUID strings through your codebase.
# All resources
php artisan teamleader:export-uuids
# Specific resources
php artisan teamleader:export-uuids --resource=departments
php artisan teamleader:export-uuids --resource=users
php artisan teamleader:export-uuids --resource=deal-phases
php artisan teamleader:export-uuids --resource=custom-fieldsThe command outputs ready-to-paste configuration for config/teamleader.php.
php artisan tinkerTeamleader::departments()->list();
Teamleader::workTypes()->list();
Teamleader::customFields()->list();Teamleader::deals()->create([
'title' => 'Enterprise Deal',
'phase_id' => config('teamleader.deal_phases.qualified'),
'source_id' => config('teamleader.deal_sources.website'),
'department_id' => config('teamleader.departments.sales'),
]);Enable request logging in .env:
TEAMLEADER_DEBUG_MODE=true
TEAMLEADER_LOG_ALL_REQUESTS=trueInspect API call statistics:
$count = Teamleader::getApiCallCount();
$calls = Teamleader::getApiCalls();
Teamleader::resetApiCallStats();# Check SDK and auth status
php artisan teamleader:status
# Validate configuration
php artisan teamleader:config:validate
# Run health check
php artisan teamleader:health
# Export UUIDs
php artisan teamleader:export-uuids- Resources — Full resource reference and capability matrix
- Filtering — Filters, sorting, pagination
- Sideloading — Loading related data
- Errors — Exception reference
Last Updated: August 2026 • SDK Version: 2.2.2 • Made with ❤️ by MCore Services
- Departments
- Users
- Teams
- Custom Fields
- Work Types
- Document Templates
- Currencies
- Notes
- Email Tracking
- Closing Days
- Day Off Types
- Days Off
- User Schedules
- Invoices
- Credit Notes
- Subscriptions
- Payment Methods
- Payment Terms
- Tax Rates
- Withholding Tax Rates
- Commercial Discounts
Next Gen Projects
Legacy Projects