A community developed API wrapper around the V2 Teamleader Focus API. This package is completely written in Typescript and uses Zod for schema validation and Axios for requests.
WARNING: This package is currently marked as 'experimental' and 'in development' and should be used at your own risk.
Endpoints wille be added whenever I need them in production / have some spare time. You can help speed up development by submitting a pull request
- General âś…
- âś… Departments (list, info)
- âś… Users (me, list, info)
- âś… Teams (list)
- âś… Custom Fields (list, info)
- âś… Work Types (list)
- CRM 👷‍♂️
- âś… Contacts (list, info, add, update, delete, tag, untag, linkToCompany, unlinkFromCompany, updateCompanyLink)
- âś… Companies (list, info, add, update, delete, tag, untag)
- 👷‍♂️ Business Types
- 👷‍♂️ Tags
- 👷‍♂️ Addresses
- Deals 👷‍♂️
- 👷‍♂️ Deals (list, info, create, update, move, win, lose, delete,
lostReasonsList) - 👷‍♂️ Quotations (
list,info,download, create, send,update,accept,delete)
- 👷‍♂️ Deals (list, info, create, update, move, win, lose, delete,
- Calendar 👷‍♂️
- 👷‍♂️ Events (
list, info,create,update,cancel) Activity Types
- 👷‍♂️ Events (
- Invoicing 👷‍♂️
- âś… Tax Rates (list)
- Products âś… (list, info, add)
ProjectsTasksTime TrackingFiles- Other 👷‍♂️
- 👷‍♂️ Migrate (id,
taxRate,ActivityType) - âś… Webhooks (register, list, unregister)
- 👷‍♂️ Migrate (id,
npm i @coachall/teamleader-node-client
yarn add @coachall/teamleader-node-client
Initialize the client:
import TLclient from "@coachall/teamleader-node-client";
/*
The initial configuration of the client.
You will need to manage refresh and access tokens yourself with the callback function.
It is advised to use a lightweight database to store these (eg: Lowdb, SQLite)
*/
const config = {
client_id: string,
client_secret: string,
refresh_token: string,
access_token: string,
redirect_uri: string,
//callback function fires when a new token pair is requested. Use the results to overwrite the refresh_token and access_token above
callback: (e) => {
e.access_token: string
e.refresh_token: string,
e.token_type: string,
e.expires_in: number,
},
};
const client = new TLclient(config);
// Get all departments
const departments = await client.departmentsList();
console.log(departments);
/* ---- RESULT----
{
data: [
{
id: 'c506e35a-2177-0626-865f-c1fcdfgc2bd21',
name: 'Coachall BV',
currency: 'EUR',
vat_number: 'BE 0743.533.110',
emails: [Array],
status: 'active'
}
]
}
*/
// Get a single department
const ourDepartment = await client.departmentsInfo(
"c506e35a-2177-0626-865f-c1fcdfgc2bd21"
);
console.log(ourDepartment);
/* ---- RESULT----
{
data: {
id: 'c506e35a-2177-0626-865f-c1fcdfgc2bd21',
name: 'Coachall BV',
currency: 'EUR',
vat_number: 'BE 0743.533.110',
emails: [Array],
status: 'active'
}
}
*/
// Filter the departments
const filteredDepartments = await client.departmentsList({
filter: {
status: "archived",
},
});
console.log(filteredDepartments);
/* ---- RESULT----
{
data: []
}
*/
General (9/9)
Departments are used to split quotations and invoices for different legal entities or within one organisation. https://developer.teamleader.eu/#/reference/general/departments
Get a list of departments. https://developer.teamleader.eu/#/reference/general/departments/departments.list
const departments: Promise<DepartmentsListResponse> = await client.departmentsList(params?: DepartmentsListParams);
Get details for a single department. https://developer.teamleader.eu/#/reference/general/departments/departments.info
const departmentsInfo: Promise<DepartmentsInfoResponse> = await client.departmentsList(id: Uuid);
Users are co-workers in a Teamleader account. https://developer.teamleader.eu/#/reference/general/users
Get the current authenticated user. https://developer.teamleader.eu/#/reference/general/users/users.me
const me: Promise<UsersMe> = await client.usersMe();
Get a list of all users. https://developer.teamleader.eu/#/reference/general/users/users.list
const userList: Promise<UsersList> = await client.usersList(params?: UsersListParams);
Get details for a single user. https://developer.teamleader.eu/#/reference/general/users/users.info
const userInfo: Promise<UsersInfo> = await client.usersInfo(id: Uuid);
https://developer.teamleader.eu/#/reference/general/teams
Get a list of all teams. https://developer.teamleader.eu/#/reference/general/users/teams.list
const teams: Promise<TeamsList> = await client.teamsList();
Custom fields are used to add additional data/properties to entities within Teamleader. https://developer.teamleader.eu/#/reference/general/custom-fields
Get a list of all the definitions of custom fields. https://developer.teamleader.eu/#/reference/general/custom-fields/customfielddefinitions.list
const customfields: Promise<CustomFieldDefinitionsList> = await client.customFieldDefinitionsList(params?: CustomFieldDefinitionsListParams);
Get info about a specific custom field definition. https://developer.teamleader.eu/#/reference/general/custom-fields/customfielddefinitions.info
const customfieldInfo: Promise<CustomFieldDefinitionsInfo> = await client.customFieldDefinitionsInfo(id: Uuid);
Work types define the type of work for events or time tracking. Hourly rates can be added to work types, so that the work can be billed to a customer. https://developer.teamleader.eu/#/reference/general/work-types
Get a list of all the definitions of custom fields. https://developer.teamleader.eu/#/reference/general/work-types/worktypes.list
const worktypes: Promise<WorkTypesList> = await client.workTypesList(params?: WorkTypesListParams);
CRM (17/20)
Contacts are physical entities who are added to your CRM database. Contacts might be linked to one or more companies. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.list
Get a list of contacts. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.list
const contacts: Promise<ContactsListResponse> = await client.contactsList(params?: ContactsListParams);
Get details for a single contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.info
const contact: Promise<ContactsInfoResponse> = await client.contactsInfo(id: Uuid);
Add a new contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.add
const addContact: Promise<contactsAddResponse> = await client.contactsAdd(body: ContactsAdd);
Update a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.update
const updateContact: Promise<null> = await client.contactsUpdate(body: ContactsUpdate);
Delete a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.delete
const deleteContact: Promise<null> = await client.contactsDelete(body: ContactsDelete);
Add a new or existing tag to a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.tag
const tagContact: Promise<null> = await client.contactsTag(body: ContactsTag);
Remove a tag from a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.untag
const untagContact: Promise<null> = await client.contactsUntag(body: ContactsUntag);
Link a contact to a company. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.linktocompany
const linkContact: Promise<null> = await client.contactsLinkToCompany(body: ContactsLinkToCompany);
Unlink a contact from a company. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.unlinkfromcompany
const unlinkContact: Promise<null> = await client.contactsUnlinkFromCompany(body: ContactsUnlinkFromCompany);
Update contact to company link. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.updatecompanylink
const updateCompanyLink: Promise<null> = await client.contactsUpdateCompanyLink(body: ContactsUpdateCompanyLink);