-
-
Notifications
You must be signed in to change notification settings - Fork 0
Resources
How the Teamleader SDK resource architecture works.
Every entity in the SDK β companies, deals, invoices, etc. β is represented by a resource class. All resource classes extend the base Resource class, which provides standard CRUD methods, filtering, sorting, pagination, and sideloading through FilterTrait.
Resources are accessed via the Teamleader facade:
use McoreServices\TeamleaderSDK\Facades\Teamleader;
Teamleader::companies() // Companies resource
Teamleader::deals() // Deals resource
Teamleader::invoices() // Invoices resourceEvery resource inherits these methods from the base Resource class. Individual resources may override them to add validation or custom behaviour.
Retrieve a list of records. Filters go in the first argument, options (sort, pagination, includes) in the second.
$companies = Teamleader::companies()->list(
['status' => 'active'],
['page_size' => 50, 'sort' => 'name']
);Retrieve a single record by UUID. The optional second argument accepts a comma-separated string or array of sideloaded relationships.
$company = Teamleader::companies()->info('company-uuid');
$company = Teamleader::companies()->info('company-uuid', 'custom_fields,responsible_user');Create a new record.
$company = Teamleader::companies()->create([
'name' => 'Acme Corp',
]);Update an existing record.
Teamleader::companies()->update('company-uuid', [
'name' => 'Acme Corp Ltd',
]);Delete a record.
Teamleader::companies()->delete('company-uuid');Resources support a fluent with() method for sideloading, which can be chained before any method call.
$company = Teamleader::companies()
->with('custom_fields')
->with('responsible_user')
->info('company-uuid');
$companies = Teamleader::companies()
->with('custom_fields,price_list')
->list(['status' => 'active']);Each resource declares which operations it supports via boolean flags. Not every resource supports every method.
// Inspect a resource's capabilities at runtime
$capabilities = Teamleader::companies()->getCapabilities();
// Returns:
[
'supports_pagination' => true,
'supports_filtering' => true,
'supports_sorting' => true,
'supports_sideloading' => true,
'supports_creation' => true,
'supports_update' => true,
'supports_deletion' => true,
'supports_batch' => false,
'default_includes' => [],
'available_includes' => ['custom_fields', 'responsible_user', ...],
'endpoint' => 'companies',
]Calling a method on a resource that does not support it will throw a BadMethodCallException.
| Resource | Facade method | Notes |
|---|---|---|
| Companies | companies() |
Full CRUD + uploadLogo()
|
| Contacts | contacts() |
Full CRUD + uploadAvatar()
|
| Business Types | businessTypes() |
Read-only |
| Tags | tags() |
Read-only |
| Addresses | addresses() |
Read-only |
| Resource | Facade method | Notes |
|---|---|---|
| Deals | deals() |
Full CRUD |
| Quotations | quotations() |
Full CRUD |
| Orders | orders() |
Read-only |
| Lost Reasons | lostReasons() |
Read-only |
| Sources | sources() |
Read-only |
| Resource | Facade method | Notes |
|---|---|---|
| Invoices | invoices() |
Full CRUD + actions |
| Credit Notes | creditNotes() |
Full CRUD |
| Payment Methods | paymentMethods() |
Read-only |
| Payment Terms | paymentTerms() |
Read-only |
| Tax Rates | taxRates() |
Read-only |
| Withholding Tax Rates | withholdingTaxRates() |
Read-only |
| Commercial Discounts | commercialDiscounts() |
Read-only |
| Subscriptions | subscriptions() |
Full CRUD |
| Bookkeeping Submissions | bookkeepingSubmissions() |
Read-only |
| Incoming Invoices | incomingInvoices() |
Full CRUD |
| Incoming Credit Notes | incomingCreditNotes() |
Full CRUD |
| Receipts | receipts() |
Full CRUD |
| Resource | Facade method | Notes |
|---|---|---|
| Projects | projects() |
Full CRUD |
| Project Lines | projectLines() |
Full CRUD |
| Milestones | milestones() |
Full CRUD |
| Resource | Facade method | Notes |
|---|---|---|
| Planning Events | planningEvents() |
Full CRUD |
| Plannable Items | plannableItems() |
Read-only |
| Resource | Facade method | Notes |
|---|---|---|
| Products | products() |
Full CRUD |
| Product Categories | productCategories() |
Read-only |
| Resource | Facade method | Notes |
|---|---|---|
| Time Tracking | timeTracking() |
Full CRUD |
| Timers | timers() |
Start/stop/info |
| Resource | Facade method | Notes |
|---|---|---|
| Expenses | expenses() |
Full CRUD |
| Resource | Facade method | Notes |
|---|---|---|
| Users | users() |
Read-only |
| Departments | departments() |
Read-only |
| Teams | teams() |
Read-only |
| Work Types | workTypes() |
Read-only |
| Custom Fields | customFields() |
Read-only |
| Files | files() |
Upload/download |
| Notes | notes() |
Full CRUD |
| Webhooks | webhooks() |
Full CRUD |
| Email Tracking | emailTracking() |
Read-only |
| Document Templates | documentTemplates() |
Read-only |
| Activity Types | activityTypes() |
Read-only |
Every resource exposes documentation helpers:
// Full documentation array
$docs = Teamleader::companies()->getDocumentation();
// Markdown string
$markdown = Teamleader::companies()->generateMarkdownDocs();
// Capabilities only
$caps = Teamleader::companies()->getCapabilities();- Filtering β Filters, sorting, pagination
- Sideloading β Loading related data
- Usage β Getting started and authentication
- 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