Skip to content

Repository files navigation

Clockodo

Unofficial JavaScript/TypeScript SDK for Clockodo.

Version on NPMSemantically releasedMonthly downloads on NPM
NPM Bundle size minifiedNPM Bundle size minified and gzipped
License

Installation and usage

npm install clockodo

For the constructor arguments, you must get the user (email) and clockodo API key from the "My area" section of Clockodo's website.

import{Clockodo}from"clockodo";constclockodo=newClockodo({client: {// You need to add some information about yourself that will be// sent along every request,// see https://docs.clockodo.com/#section/Clockodo-REST-API/Client-identification// PLEASE NOTE: name + ";" + email must not be longer than 50 characters.name: "Your application/company",email: "technical-contact@your-company.com",},authentication: {user: "test-user@example.com",// You can get your API key from https://my.clockodo.com/en/users/editselfapiKey: "kjfdskj643fgnlksf343kdslm",},});

Config

  • client: Specify a name and an email for the X-Clockodo-External-Application header
  • authentication: Specify a user and an apiKey to authenticate every request
  • baseUrl: Points to the Clockodo API. Defaults to https://my.clockodo.com/api

You can update the configuration later like this:

clockodo.api.config({authentication: {/* ... */},});

API

We provide methods for Clockodo endpoints and normalize payload keys automatically: query params and request bodies are mapped from camelCase to snake_case (deeply), response bodies are mapped from snake_case to camelCase (deeply), and empty query values (undefined, null, "") are omitted. You can find the implementation in src/lib/mappings.ts.

For any questions about the different properties please consult the official Clockodo API documentation.

Some constants are also available for import:

import{AbsenceStatus,AbsenceType,Billability,EntriesTextsMode,EntryType}from"clockodo";console.log(EntryType.Time);// 1console.log(EntryType.LumpsumValue);// 2console.log(EntryType.LumpsumService);// 3console.log(Billability.NotBillable);// 0console.log(Billability.Billable);// 1console.log(Billability.Billed);// 2

Checkout models for more constants and TypeScript types.


Get Methods

Gets a selected absence by its ID.

Example:

awaitclockodo.getAbsence({id: 7});

Gets a user's (readonly) access rights for customers and projects.

Example:

awaitclockodo.getUsersAccessCustomersProjects({usersId: 67325});

Gets a user's (readonly) access rights for services.

Example:

awaitclockodo.getUsersAccessServices({usersId: 67325});

Gets a list of absences in the provided year

Example:

awaitclockodo.getAbsences({year: 2018});

Get currently running entry for the credentials attached to Clockodo object.

Example:

awaitclockodo.getClock();

Get specific customer by ID

Example:

awaitclockodo.getCustomer({id: 777});

Get all customers from all pages.

Example:

awaitclockodo.getCustomers();// orawaitclockodo.getCustomers({filter: {// Filter by active flagactive: true,},});

Get all customers from a specific page.

Example:

awaitclockodo.getCustomersPage({page: 2});

Get the number of active and inactive projects per customer.

Example:

awaitclockodo.getCustomersCountProjects();// orawaitclockodo.getCustomersCountProjects({customersId: [10,11]});

Get an entry by its ID.

Example:

awaitclockodo.getEntry({id: 4});

splitAllEntriesAtMidnight()

Splits all entries for a given user and day at midnight.

Example:

awaitclockodo.splitAllEntriesAtMidnight({day: "2026-02-17",usersId: 123,});

Get all entries from all pages.

Example:

import{Billability}from"clockodo";awaitclockodo.getEntries({// timeSince and timeUntil are requiredtimeSince: "2017-08-18T00:00:00Z",timeUntil: "2018-02-09T00:00:00Z",filter: {// You can also add additional filters herebillable: Billability.Billed,},});

Get all entries from a specific page

Example:

awaitclockodo.getEntriesPage({timeSince: "2017-08-18T00:00:00Z",timeUntil: "2018-02-09T00:00:00Z",page: 2,});

Get a group of entries defined by your criteria.

Example:

awaitclockodo.getEntryGroups({timeSince: "2017-08-18T00:00:00Z",timeUntil: "2018-02-09T00:00:00Z",grouping: ["customersId","projectsId"],roundToMinutes: 15,});

Retreive all descriptions (and no additional info) entered for time and lump sum entries from all pages.

Example:

awaitclockodo.getEntriesTexts({term: "meeting with client",mode: EntriesTextsMode.Add,});

Retreive all descriptions from a specific page.

Example:

awaitclockodo.getEntriesTextsPage({term: "meeting with client",mode: EntriesTextsMode.Edit,page: 2,});

Get a project by its ID.

Example:

awaitclockodo.getProject({id: 1985});

Get all projects from all pages.

Example:

awaitclockodo.getProjects();// orawaitclockodo.getProjects({filter: {// Filter by a specific customer idcustomersId: 123,// Filter by active flagactive: true,},});

Get all projects from a specific page.

Example:

awaitclockodo.getProjectsPage({page: 2});

Get all project report rows from all pages.

Example:

awaitclockodo.getProjectsReports();

Get project report rows from a specific page.

Example:

awaitclockodo.getProjectsReportsPage({page: 2});

Get a subproject by its ID.

Example:

awaitclockodo.getSubproject({id: 11});

Get all subprojects from all pages.

Example:

awaitclockodo.getSubprojects();

Get all subprojects from a specific page.

Example:

awaitclockodo.getSubprojectsPage({page: 2});

Get a service by its ID.

Example:

awaitclockodo.getService({id: 10});

Get list of all services

Example:

awaitclockodo.getServices();

Get a list of services from a specific page.

Example:

awaitclockodo.getServicesPage({page: 2});

Get team by id.

Example:

awaitclockodo.getTeam({id: 10});

Get list of all teams from all pages.

Example:

awaitclockodo.getTeams();

Get all teams from a specific page.

Example:

awaitclockodo.getTeamsPage({page: 2});

Get a lumpsum service by its ID.

Example:

awaitclockodo.getLumpSumService({id: 10});

Get a list of all lumpsum services

Example:

awaitclockodo.getLumpSumServices();

Get a list of lumpsum services from a specific page.

Example:

awaitclockodo.getLumpSumServicesPage({page: 2});

Get a specific target hour period for a specific user by its ID (not the ID of the user)

Example:

awaitclockodo.getTargethoursRow({id: 1234});

Get list of target hours for all users, with option to pass an object with an usersId to filter the history of target hours to a specific user.

Example:

awaitclockodo.getTargethours();// orawaitclockodo.getTargethours({usersId: 346923});

Create a target hour period for a user.

Example:

import{TargethoursRowType}from"clockodo";awaitclockodo.addTargethour({usersId: 1,type: TargethoursRowType.Weekly,dateSince: "2023-02-28",dateUntil: null,compensationMonthly: 0,});

Update a target hour period by ID.

Example:

awaitclockodo.editTargethour({id: 1234,type: TargethoursRowType.Weekly,dateSince: "2023-02-28",});

Delete a target hour period by ID.

Example:

awaitclockodo.deleteTargethour({id: 1234});

Get a co-worker by their ID.

Example:

awaitclockodo.getUser({id: 1263});

Get list of users from all pages.

Example:

awaitclockodo.getUsers();

Get all users from a specific page.

Example:

awaitclockodo.getUsersPage({page: 2});

getSurchargeModel()

Get a surcharge model by ID.

Example:

awaitclockodo.getSurchargeModel({id: 7});

getSurchargeModels()

Get all surcharge models.

Example:

awaitclockodo.getSurchargeModels();

Get a report for a specific user and year.

Example:

awaitclockodo.getUserReport({usersId: 1263,year: 2017});

Get an employee/user's report, which contains data such as hours worked and holidays taken.

Example:

awaitclockodo.getUserReports({year: 2017,type: 1});

Gets all nonbusiness groups.

Example:

awaitclockodo.getNonbusinessGroups();

Gets a nonbusiness group by ID.

Example:

awaitclockodo.getNonbusinessGroup({id: 123});

Gets all nonbusiness days for a given year.

Example:

awaitclockodo.getNonbusinessDays({nonbusinessGroupId: 123,year: 2021,});

Gets a nonbusiness day by ID.

Example:

awaitclockodo.getNonbusinessDay({id: 12,year: 2026});

Gets user and company settings for the logged-in user.

Example:

awaitclockodo.getMe();

Get subscription data.

Example:

awaitclockodo.getSubscription();

Get list of access groups.

Example:

awaitclockodo.getAccessGroups();

Get an access group by ID.

Example:

awaitclockodo.getAccessGroup({id: 1});

Get customers and projects access for an access group.

Example:

awaitclockodo.getAccessGroupsCustomersProjects({accessGroupsId: 1});

Get services access for an access group.

Example:

awaitclockodo.getAccessGroupsServices({accessGroupsId: 1});

Get a user's access rights for customers and projects.

Example:

awaitclockodo.getIndividualUserAccessCustomersProjects({usersId: 67325});

Get a user's access rights for services.

Example:

awaitclockodo.getIndividualUserAccessServices({usersId: 67325});

Get overtime reduction rows, optionally filtered by user(s).

Example:

awaitclockodo.getOvertimeReductions();// orawaitclockodo.getOvertimeReductions({usersId: 17});

Get an overtime reduction by ID.

Example:

awaitclockodo.getOvertimeReduction({id: 7});

Get user nonbusiness days from a specific page.

Example:

awaitclockodo.getUsersNonbusinessDaysPage({page: 1});

Get all user nonbusiness days (all pages).

Example:

awaitclockodo.getUsersNonbusinessDays();

Get user nonbusiness groups from a specific page.

Example:

awaitclockodo.getUsersNonbusinessGroupsPage({page: 1});

Get all user nonbusiness groups (all pages).

Example:

awaitclockodo.getUsersNonbusinessGroups();

Get a user nonbusiness group by ID.

Example:

awaitclockodo.getUsersNonbusinessGroup({id: 1});

Gets work times from a specific page.

Example:

awaitclockodo.getWorkTimesPage({usersId: 123,dateSince: "2026-02-01",dateUntil: "2026-02-07",page: 2,});

Gets all work time pages for the given filter.

Example:

awaitclockodo.getWorkTimes({usersId: 123,dateSince: "2026-02-01",dateUntil: "2026-02-07",});

Gets work time change requests from a specific page.

Example:

awaitclockodo.getWorkTimesChangeRequestsPage({usersId: 123,dateSince: "2026-02-01",dateUntil: "2026-02-07",page: 2,});

Gets all work time change request pages for the given filter.

Example:

awaitclockodo.getWorkTimesChangeRequests({usersId: 123,dateSince: "2026-02-01",dateUntil: "2026-02-07",});

Gets overtime carry rows.

Example:

awaitclockodo.getOvertimecarry({usersId: 17,year: 2028});

Gets an overtime carry row by ID.

Example:

awaitclockodo.getOvertimecarryRow({id: 7});

Gets holiday quota rows.

Example:

awaitclockodo.getHolidaysQuotas({usersId: 17,year: 2028});

Gets a holiday quota row by ID.

Example:

awaitclockodo.getHolidaysQuota({id: 7});

Gets holiday carryover rows.

Example:

awaitclockodo.getHolidaysCarryovers({usersId: 17,year: 2028});

Gets a holiday carryover row by ID.

Example:

awaitclockodo.getHolidaysCarryover({id: 7});

Post Methods

Default behavior adds an absence for the user attached to the credentials given to the clockodo object. To add the absence for another user you can use the usersId option if you have the permissions.

Example:

import{AbsenceType}from"clockodo";awaitclockodo.addAbsence({dateSince: "2017-08-18T00:00:00Z",dateUntil: "2018-02-09T00:00:00Z",type: AbsenceType.SpecialLeave,note: "elternzeit",usersId: 12321,});

Adds a customer to the organization.

Example:

awaitclockodo.addCustomer({name: "Weyland-Yutani"});

Create an access group (name required; optional user IDs for members).

Example:

awaitclockodo.addAccessGroup({name: "Support Team"});

Adds a lumpsum service.

Example:

awaitclockodo.addLumpsumService({name: "Flat Rate Support",price: 99});

Creates a nonbusiness group.

Example:

awaitclockodo.addNonbusinessGroup({name: "NRW",preset: ""});

Creates a nonbusiness day.

Example:

awaitclockodo.addNonbusinessDay({nonbusinessGroupId: 2,type: "DISTINCT_ONCE",name: "Labor Day",});

Create a user nonbusiness group.

Example:

awaitclockodo.addUsersNonbusinessGroup({usersId: 17,nonbusinessGroupsId: 1,dateSince: "2023-02-28",});

Creates an overtime carry row.

Example:

awaitclockodo.addOvertimecarry({usersId: 17,year: 2028,hours: 8,note: "carryover",});

Create an overtime reduction row.

Example:

awaitclockodo.addOvertimeReduction({usersId: 17,date: "2028-01-28",hours: 8,});

Creates a holidays quota row.

Example:

awaitclockodo.addHolidaysQuota({usersId: 17,yearSince: 2028,count: 30,});

Creates a holidays carryover row.

Example:

awaitclockodo.addHolidaysCarryover({usersId: 17,year: 2028,count: 5,});

Creates an entry for either the user attached to the Clockodo instance or the passed in usersId. Depending on the type of entry different properties are required:

Type of entryRequired properties
Manual time entrycustomersId, servicesId, billable, timeSince, timeUntil
Lumpsum value entrycustomersId, servicesId, billable, timeSince, lumpsum
Lumpsum service entrycustomersId, lumpsumServicesAmount, lumpsumServicesId, billable, timeSince

Example:

import{Billability}from"clockodo";awaitclockodo.addEntry({customersId: 1,servicesId: 2,billable: Billability.Billable,timeSince: "2018-10-01T00:00:00Z",timeUntil: "2018-10-01T03:00:00Z",});

Creates a project for an existing customer.

Example:

awaitclockodo.addProject({name: "Clockodo Api Wrapper",customersId: 1});

Create the next project interval for a project by ID.

Example:

awaitclockodo.createNextProjectInterval({id: 20});

Creates a subproject for an existing project.

Example:

awaitclockodo.addSubproject({projectsId: 1,name: "SDK Migration"});

Adds to the list of services offered by your organization.

Example:

awaitclockodo.addService({name: "Thinking"});

Creates a new team under your organization.

Example:

awaitclockodo.addTeam({name: "Gold Team"});

Creates new user in organization.

Example:

import{UserRole}from"clockodo";awaitclockodo.addUser({name: "Merkel",number: "08",email: "angela@eu.eu",role: UserRole.Owner,});

addSurchargeModel()

Adds a surcharge model.

Example:

awaitclockodo.addSurchargeModel({name: "Night Shift",accumulation: true});

Start a new running clockodo entry.

Example:

import{Billability}from"clockodo";awaitclockodo.startClock({customersId: 24,servicesId: 7,projectsId: 365,billable: Billability.Billable,});

Creates a work time change request.

Example:

import{WorkTimeChangeRequestIntervalType}from"clockodo";awaitclockodo.addWorkTimesChangeRequest({date: "2026-02-17",usersId: 123,changes: [{type: WorkTimeChangeRequestIntervalType.Add,timeSince: "2026-02-17T08:00:00Z",timeUntil: "2026-02-17T12:00:00Z",},],});

Approves a work time change request by ID.

Example:

awaitclockodo.approveWorkTimesChangeRequest({id: 17});

Declines a work time change request by ID.

Example:

awaitclockodo.declineWorkTimesChangeRequest({id: 17});

Put methods

Changes the duration of an entry. Because the ID returned by clock methods is just the entry ID, and this function can only be used after an entry is finished, there seems to be no difference from using editEntry().

Example:

awaitclockodo.changeClockDuration({entriesId: 7082,duration: 540,durationBefore: 300,});

Edit existing Clockodo absence.

Example:

awaitclockodo.editAbsence({id: 74,note: "I know what he did last summer"});

Edit existing Clockodo customer.

Example:

awaitclockodo.editCustomer({id: 15,name: "The Mystery Gang"});

Update an access group by ID.

Example:

awaitclockodo.editAccessGroup({id: 1,name: "Updated Name"});

Update an access group's customer access.

Example:

import{AccessType,AccessValue}from"clockodo";awaitclockodo.editAccessGroupsCustomer({accessGroupsId: 1,id: 10,type: AccessType.Add,value: AccessValue.FullAccess,});

Update an access group's general customers access.

Example:

import{AccessType,AccessValue}from"clockodo";awaitclockodo.editAccessGroupsCustomersGeneral({accessGroupsId: 1,type: AccessType.Add,value: AccessValue.FullAccess,});

Update an access group's project access.

Example:

import{AccessProjectOrServiceValue,AccessType}from"clockodo";awaitclockodo.editAccessGroupsProject({accessGroupsId: 1,id: 5,type: AccessType.Add,value: AccessProjectOrServiceValue.FullAccess,});

Update an access group's service access.

Example:

import{AccessProjectOrServiceValue,AccessType}from"clockodo";awaitclockodo.editAccessGroupsService({accessGroupsId: 1,id: 3,type: AccessType.Add,value: AccessProjectOrServiceValue.FullAccess,});

Update an access group's general services access.

Example:

import{AccessType,AccessValue}from"clockodo";awaitclockodo.editAccessGroupsServicesGeneral({accessGroupsId: 1,type: AccessType.Add,value: AccessValue.FullAccess,});

Update a user's customer access.

Example:

import{AccessType,AccessValue}from"clockodo";awaitclockodo.editIndividualUserAccessCustomer({usersId: 67325,id: 10,type: AccessType.Add,value: AccessValue.FullAccess,});

Update a user's general customers access.

Example:

import{AccessType,AccessValue}from"clockodo";awaitclockodo.editIndividualUserAccessCustomersGeneral({usersId: 67325,type: AccessType.Add,value: AccessValue.FullAccess,});

Update a user's project access.

Example:

import{AccessProjectOrServiceValue,AccessType}from"clockodo";awaitclockodo.editIndividualUserAccessProject({usersId: 67325,id: 5,type: AccessType.Add,value: AccessProjectOrServiceValue.FullAccess,});

Update a user's service access.

Example:

import{AccessProjectOrServiceValue,AccessType}from"clockodo";awaitclockodo.editIndividualUserAccessService({usersId: 67325,id: 3,type: AccessType.Add,value: AccessProjectOrServiceValue.FullAccess,});

Update a user's general services access.

Example:

import{AccessType,AccessValue}from"clockodo";awaitclockodo.editIndividualUserAccessServicesGeneral({usersId: 67325,type: AccessType.Add,value: AccessValue.FullAccess,});

Edit an existing lumpsum service.

Example:

awaitclockodo.editLumpsumService({id: 15,name: "Updated Flat Rate"});

Changes the values of a Clockodo entry. Unlike changeClockDuration(), editEntry() can seemingly mutate any of the accepted parameters even when the entry is running.

Example:

awaitclockodo.editEntry({id: 365,duration: 540});

Allows for mass edit of entries based on a set of filters.

Example:

import{Billability}from"clockodo";awaitclockodo.editEntryGroup({timeSince: "2017-08-18T00:00:00Z",timeUntil: "2018-02-09T00:00:00Z",filter: {text: "Browsing Reddit",billable: Billability.NotBillable,},});

Edit existing project.

Example:

awaitclockodo.editProject({id: 20,name: "Awesome new project"});

Set a project's completion status.

Example:

awaitclockodo.completeProject({id: 20,completed: true});

Set a project's billed status and billed amount.

Example:

awaitclockodo.setProjectBilled({id: 20,billed: true,billedMoney: 1234.5});

Edit existing subproject.

Example:

awaitclockodo.editSubproject({id: 20,name: "SDK Migration Phase 2"});

Set a subproject's completion status.

Example:

awaitclockodo.completeSubproject({id: 20,completed: true});

Edit existing service.

Example:

awaitclockodo.editService({id: 23,name: "Room Service"});

Edit existing team.

Example:

awaitclockodo.editTeam({id: 6324,name: "New Team Name"});

Edit existing user.

Example:

awaitclockodo.editUser({id: 33,name: "Moalo Loco"});

editSurchargeModel()

Edit an existing surcharge model.

Example:

awaitclockodo.editSurchargeModel({id: 365,name: "ABC"});

Edits a nonbusiness group.

Example:

awaitclockodo.editNonbusinessGroup({id: 2,name: "Holidays"});

Edits a nonbusiness day.

Example:

awaitclockodo.editNonbusinessDay({id: 2,name: "Holiday",type: "DISTINCT_RECURRING",});

Update a user nonbusiness group by ID.

Example:

awaitclockodo.editUsersNonbusinessGroup({id: 1,name: "Updated Group"});

Edits an overtime carry row.

Example:

awaitclockodo.editOvertimecarry({id: 2,hours: 8,note: "updated"});

Update an overtime reduction by ID.

Example:

awaitclockodo.editOvertimeReduction({id: 2,hours: 4});

Edits a holidays quota row.

Example:

awaitclockodo.editHolidaysQuota({id: 2,count: 25,note: "updated"});

Edits a holidays carryover row.

Example:

awaitclockodo.editHolidaysCarryover({id: 2,count: 5,note: "updated"});

Delete methods

Clear individual user access (customers/projects and services) for a user.

Example:

awaitclockodo.clearIndividualUserAccess({usersId: 67325});

Delete an access group by ID.

Example:

awaitclockodo.deleteAccessGroup({id: 1});

Deletes the customer.

Example:

awaitclockodo.deleteCustomer({id: 343});

Deletes the project.

Example:

awaitclockodo.deleteProject({id: 8});

Deletes the subproject.

Example:

awaitclockodo.deleteSubproject({id: 8});

Deletes the service.

Example:

awaitclockodo.deleteService({id: 94});

Deletes user.

Example:

awaitclockodo.deleteUser({id: 7});

deleteSurchargeModel()

Deletes a surcharge model by ID.

Example:

awaitclockodo.deleteSurchargeModel({id: 31});

Deletes absence (go figure).

Example:

awaitclockodo.deleteAbsence({id: 31});

Deletes a single entry by ID

Example:

awaitclockodo.deleteEntry({id: 543512});

Deletes a lumpsum service by ID.

Example:

awaitclockodo.deleteLumpsumService({id: 94});

Deletes a team by ID

Example:

awaitclockodo.deleteTeam({id: 764});

Deletes a nonbusiness group by ID.

Example:

awaitclockodo.deleteNonbusinessGroup({id: 31});

Delete a user nonbusiness group by ID.

Example:

awaitclockodo.deleteUsersNonbusinessGroup({id: 1});

Deletes a nonbusiness day by ID.

Example:

awaitclockodo.deleteNonbusinessDay({id: 31});

Deletes an overtime carry row by ID.

Example:

awaitclockodo.deleteOvertimecarry({id: 31});

Delete an overtime reduction by ID.

Example:

awaitclockodo.deleteOvertimeReduction({id: 31});

Deletes a holidays quota row by ID.

Example:

awaitclockodo.deleteHolidaysQuota({id: 31});

Deletes a holidays carryover row by ID.

Example:

awaitclockodo.deleteHolidaysCarryover({id: 31});

Deletes one or more entries based on a series of filters that builds an "entry group".

Example:

awaitclockodo.deleteEntryGroup({timeSince: "2017-08-18T00:00:00Z",timeUntil: "2018-02-09T00:00:00Z",text: "chilin everyday",});

Withdraws a work time change request by ID.

Example:

awaitclockodo.withdrawWorkTimesChangeRequest({id: 17});

Creates a new clockodo account.

Example:

awaitclockodo.register({companiesName: "Acme Corporation",name: "Road Runner",email: "runner@acme.com",});

Stops a running clock/entry.

Example for self:

awaitclockodo.stopClock({entriesId: 7082});

Example for another user (needs requesting user to be owner):

awaitclockodo.stopClock({entriesId: 7082,usersId: 123});

Development

To run integration tests you need to create an .env by copying the .env.example and entering credentials of a dev-user, as you don't want to mess up your real clockodo data.

License

MIT

Sponsors

About

Unofficial JavaScript/TypeScript SDK for Clockodo

Topics

Resources

Stars

23 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages