-
-
Notifications
You must be signed in to change notification settings - Fork 0
Installation & Configuration
Everything you need to go from zero to a working Teamleader connection.
| Requirement | Version |
|---|---|
| PHP | 8.2 or higher |
| Laravel | 10.x, 11.x, or 12.x |
| Database | MySQL 5.7+ / PostgreSQL 10+ / SQLite 3.8+ |
| Cache driver | Any Laravel cache driver (Redis strongly recommended for production) |
You also need a Teamleader Marketplace application β see Create a Marketplace App below.
composer require mcore-services-bv/teamleader-sdkPublish the configuration file:
php artisan vendor:publish --tag=teamleader-configThis creates config/teamleader.php in your application. The SDK does not require php artisan migrate β the teamleader_tokens table is created automatically on the first successful OAuth callback.
The SDK uses OAuth 2.0. You need a Teamleader Marketplace application to get your client_id and client_secret.
- Go to your Teamleader Focus integrations and sign in with your Teamleader account.
- Click Create integration, enter a name and proceed to the next page.
- Set the Redirect URI to
https://your-app.com/teamleader/callbackβ this must matchTEAMLEADER_REDIRECT_URIin your.envexactly. - Copy the Client ID and Client Secret from the app detail page.
- Fill in the remaining (required) fields.
- Click the button to save changes, unless making your app public you don't need to request publication.
For local development,
APP_URLis typicallyhttp://localhostorhttp://127.0.0.1:8000. Teamleader acceptshttp://redirect URIs for local development only.
TEAMLEADER_CLIENT_ID=your_client_id
TEAMLEADER_CLIENT_SECRET=your_client_secret
TEAMLEADER_REDIRECT_URI=${APP_URL}/teamleader/callbackThe SDK will throw a ConfigurationException on boot if any of these three are missing.
All variables and their defaults:
# ββ Required ββββββββββββββββββββββββββββββββββββββββββββββββββ
TEAMLEADER_CLIENT_ID=
TEAMLEADER_CLIENT_SECRET=
TEAMLEADER_REDIRECT_URI=${APP_URL}/teamleader/callback
# ββ API βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
TEAMLEADER_API_VERSION=2023-09-26 # API version header sent with every request
# ββ HTTP timeouts (seconds) βββββββββββββββββββββββββββββββββββ
TEAMLEADER_API_TIMEOUT=30
TEAMLEADER_API_CONNECT_TIMEOUT=10
TEAMLEADER_API_READ_TIMEOUT=25
# ββ Retries βββββββββββββββββββββββββββββββββββββββββββββββββββ
TEAMLEADER_API_RETRY_ATTEMPTS=3
TEAMLEADER_API_RETRY_DELAY=1000 # milliseconds between attempts
# ββ Rate limiting βββββββββββββββββββββββββββββββββββββββββββββ
TEAMLEADER_RATE_LIMITING_ENABLED=true
TEAMLEADER_RATE_LIMIT=200 # Teamleader's limit: 200 req/min
TEAMLEADER_THROTTLE_THRESHOLD=0.7 # Start throttling at 70% usage
TEAMLEADER_AGGRESSIVE_THROTTLING=true
TEAMLEADER_RESPECT_RETRY_AFTER=true
# ββ Logging βββββββββββββββββββββββββββββββββββββββββββββββββββ
TEAMLEADER_LOG_REQUESTS=false # Log every outgoing request (verbose)
TEAMLEADER_LOG_RESPONSES=false # Log every API response (verbose)
TEAMLEADER_LOG_RATE_LIMITS=true
TEAMLEADER_LOG_TOKEN_REFRESH=true
TEAMLEADER_LOG_CHANNEL= # Defaults to your app's default log channel
TEAMLEADER_SANITIZE_LOGS=true # Redact tokens from log outputAdd two routes to your application. The exact paths can be anything β just make sure TEAMLEADER_REDIRECT_URI matches your callback route.
// routes/web.php
use McoreServices\TeamleaderSDK\Facades\Teamleader;
// Step 1: redirect the user to Teamleader to authorise
Route::get('/teamleader/connect', function () {
return Teamleader::authorize();
})->middleware('auth');
// Step 2: Teamleader redirects back here with a code
Route::get('/teamleader/callback', function (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. Please try again.');
});Laravel's CSRF middleware will block the OAuth callback unless you exclude it:
// bootstrap/app.php (Laravel 11+)
->withMiddleware(function (Middleware $middleware) {
$middleware->validateCsrfTokens(except: [
'teamleader/callback',
]);
})// app/Http/Middleware/VerifyCsrfToken.php (Laravel 10)
protected $except = [
'teamleader/callback',
];Once you've completed the OAuth flow, run these commands to confirm everything is working:
# Connection and token status
php artisan teamleader:status
# Full configuration validation
php artisan teamleader:config:validate
# Live API health check
php artisan teamleader:healthOr test directly in Tinker:
php artisan tinker
>>> Teamleader::isAuthenticated() # should return true
>>> Teamleader::companies()->list()Before going live, verify these additional settings:
-
CACHE_DRIVER=redisβ file cache does not coordinate across queue workers - Redis is password-protected with TLS enabled (
REDIS_SCHEME=tls) -
.envis excluded from version control (.gitignore) -
APP_KEYis unique and not shared between environments -
TEAMLEADER_SANITIZE_LOGS=trueto keep tokens out of log files -
TEAMLEADER_LOG_REQUESTSandTEAMLEADER_LOG_RESPONSESarefalsein production
For token encryption and additional hardening, see Token-Storage-&-Security.
To revoke the connection and clear all stored tokens:
Teamleader::logout();Or from the command line:
php artisan teamleader:token --revokeAfter revoking, also remove the redirect URI from the integration in Teamleader Developers Portal to invalidate the OAuth tokens server-side. Please note that created integration cannot be removed.
- Usage β Common operations, filtering, pagination, error handling
- Token Storage & Security β How tokens are stored and how to harden for production
- 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