Can we export all entires of a Clockify account and import them to another Clockify account?

Hi all,

I’m experiencing a scenario as this topic’s title.

I have a personal Clockify account which I have been using for quite a long time.
After evaluating Clockify, my company now sets up Clockify and invite me there using my work email.
Now, I want to import all my previous time entries in my personal account to my work account. Is it possible currently (as I cannot find it)?

Hi lamle, and welcome to Clockify forum!

Currently, it’s not possible to import data (only export), but we plan to add this option in the future.

The only way to import data at the moment is if you write a script that takes data and pushes it to Clockify via API.

It is possible to move entries from one workspace to another within a single Clockify account (but not between accounts), so there might be a workaround in your case.

Since you have been invited using your work email, that’s a completely separate Clockify account. If you haven’t tracked any time on this account you can delete it and then go back to your personal Clockify account and change its email to your work email in your Profile settigns.

This way your example@personal.com Clockify account becomes an example@company.com Clockify account.

Then your company would have to invite you again to the workspace they have set up. Once you accept the invite, you will have two workspaces: personal workspace and company’s workspace (but one Clockify account).

Workspaces are completely separate regarding data, so entries from your personal workspace are not visible to users in your company’s workspace, but you can move entries from one workspace to another (you can see here how).

1 Like

Hi jovana,
Thank you for your response.
The workaround you suggested seems great, but I am a bit late to do that… My new work account has already had a lot of entries.
Anyways, I think I will have a look at the APIs to see if I can manage to do that by scripts. Will share it back here when I find a solution.

1 Like

I was able to move all of my entries from my old account to my new one using Powershell and Clockify API.

Below is the script I developed and used. Feel free to take it for references and adapt to your situation if you have the same scenario.

#Required custom parameters
$oldAccountApiKey = "{Your_Old_Account_API_Key}"
$oldWorkspaceId = "{Move_From_This_Workspace}"

$newAccountApiKey = "{Your_New_Account_API_Key}"
$newWorkspaceId = "{Move_To_This_Workspace}"
$newProjectId = "{Move_To_This_New_Project}"

### Get time entries from the old Clockify account and update the data with the new workspace Id and project Id.
$OldAccountHeaders = @{
    "content-type"="application/json";
    "X-Api-Key"= $oldAccountApiKey
}

$getUserInfoUri = "https://api.clockify.me/api/v1/user"
$oldUserId = ((Invoke-WebRequest -Headers $OldAccountHeaders -Method GET -Uri $getUserInfoUri -UseBasicParsing).Content | ConvertFrom-Json).Id

$getAllTimeEntriesUri = "https://api.clockify.me/api/v1/workspaces/$oldWorkspaceId/user/$oldUserId/time-entries"
$allTimeEntries = (Invoke-WebRequest -Headers $OldAccountHeaders -Method GET -Uri $getAllTimeEntriesUri -UseBasicParsing).Content | ConvertFrom-Json

$allTimeEntries | % { 
    $_.workspaceId = $newWorkspaceId;
    $_.projectId = $newProjectId;
    $_.taskId = $null; 
    $_ | Add-Member -NotePropertyName start -NotePropertyValue $_.timeInterval.start;
    $_ | Add-Member -NotePropertyName end -NotePropertyValue $_.timeInterval.end;
} 

### Send post requests to create new time entries on the new account.
$NewAccountHeaders = @{
    "content-type"="application/json";
    "X-Api-Key"=$newAccountApiKey
}
$newEntryUri = "https://api.clockify.me/api/v1/workspaces/$newWorkspaceId/time-entries"
foreach ($timeEntry in $allTimeEntries)
{
    $timeEntry = $timeEntry | ConvertTo-Json -depth 32

    Write-Host "Posting time entry (with Json as below): "
    $timeEntry

    $result = Invoke-WebRequest -Headers $NewAccountHeaders -Method POST -Uri $newEntryUri -Body $timeEntry
    if ($result.StatusCode -eq 201) { 
        Write-Host "Result: 201 Created." 
    } 
    else {
        Write-Host "Result: Failed to create this entry."
    }
    Write-Host "-----------------"
}
1 Like