Authentication overview

Clockify offers an API that allows developers to integrate time tracking data and project management functionalities into other applications. Access to this API requires authentication to ensure that requests are authorized and data remains secure. The primary method for authenticating with the Clockify API is through the use of API keys, which are unique identifiers assigned to individual user accounts.

API keys serve as a token that verifies the identity of the requesting application or user. When a request is made to the Clockify API, the API key must be included in the request headers. This mechanism enables the Clockify server to validate the request against a registered user account and apply appropriate permissions, ensuring data integrity and preventing unauthorized access to time entries, projects, and other sensitive information. The API supports various operations, including retrieving time entries, managing projects, and updating user data, all of which require a valid API key for successful execution.

Supported authentication methods

Clockify primarily supports API Key authentication for its programmatic interfaces. This method is common for web APIs where direct user interaction for authentication (like OAuth flows) might be less practical for server-to-server or application-to-API communication. The API key acts as a secret token that grants access on behalf of the user who generated it.

Clockify API Authentication Methods
Method When to Use Security Level
API Key Programmatic access, server-to-server integrations, personal scripts. Moderate (requires secure handling of the key).

While API keys are the standard for the Clockify API, it's important to differentiate this from how users log into the Clockify web or desktop applications, which typically involve username/password credentials, and potentially Single Sign-On (SSO) options for enterprise accounts. For API interactions, the API key is the designated credential.

Getting your credentials

To interact with the Clockify API, you need to generate an API key from your Clockify account. This process is performed within the Clockify web application's user settings.

  1. Log in to Clockify: Access your Clockify account through the web application on the Clockify homepage.
  2. Navigate to Profile Settings: Once logged in, click on your profile icon or name, usually located in the top-right corner, and select 'Profile Settings' or a similar option.
  3. Locate API Key Section: Within your profile settings, scroll down to find a section labeled 'API Key' or 'API Dashboard'.
  4. Generate New API Key: If you don't have an existing API key, or if you need to revoke and generate a new one for security reasons, there will be an option to 'Generate API Key' or 'Regenerate API Key'. Click this button.
  5. Copy Your API Key: Once generated, your API key will be displayed. It is a long alphanumeric string. Copy this key immediately and store it securely. For security, Clockify typically displays the key only once upon generation. If you lose it, you may need to regenerate a new one, which will invalidate the old key.

Clockify provides detailed instructions on generating and managing API keys within their Clockify Help Center, which includes guidance on API usage.

Authenticated request example

Once you have obtained your API key, you can use it to make authenticated requests to the Clockify API. The API key must be included in the X-Api-Key HTTP header for every request.

Here is an example using curl to fetch your user data:

curl -X GET \
  'https://api.clockify.me/api/v1/user' \
  -H 'X-Api-Key: YOUR_API_KEY_HERE' \
  -H 'Content-Type: application/json'

In this example:

  • YOUR_API_KEY_HERE should be replaced with the actual API key you generated from your Clockify profile.
  • GET is the HTTP method, indicating a request to retrieve data.
  • https://api.clockify.me/api/v1/user is the API endpoint for retrieving information about the authenticated user.
  • -H 'X-Api-Key: YOUR_API_KEY_HERE' sets the custom HTTP header containing your API key.
  • -H 'Content-Type: application/json' specifies that the request body (if any) is JSON, although for a GET request to this endpoint, it's often not strictly necessary but good practice.

For more complex operations, such as creating time entries or projects, you would typically use POST requests and include a JSON request body with the necessary data. The Clockify API documentation provides specific examples for various endpoints and operations, detailing required parameters and expected responses.

Security best practices

When working with API keys for Clockify, adhering to security best practices is crucial to protect your account and data. API keys grant access to your Clockify data, so treating them as sensitive credentials is paramount.

  • Keep API Keys Confidential: Never hardcode API keys directly into client-side code (e.g., JavaScript in a web browser) or publicly accessible repositories. API keys should be stored and managed securely.
  • Use Environment Variables: For server-side applications, store API keys as environment variables rather than directly in your codebase. This prevents them from being exposed if your code repository is compromised.
  • Secure Storage: If you must store API keys, use secure storage mechanisms like secret management services (e.g., AWS Secrets Manager, Google Secret Manager, Azure Key Vault) or encrypted configuration files. Avoid storing them in plain text.
  • Restrict Access: Limit who has access to your API keys. Only individuals or systems that absolutely require access for their function should have it.
  • Regenerate Keys Periodically: Regularly regenerate your API keys, especially if there's any suspicion of compromise or if a team member leaves. Regenerating a key invalidates the old one, forcing any compromised access to cease.
  • Implement Least Privilege: While Clockify API keys are typically tied to a user's full permissions, ensure that the user account associated with the API key has only the minimum necessary permissions within Clockify if possible. This mitigates the impact of a compromised key.
  • Monitor API Usage: Regularly review your API usage logs (if available) for any unusual activity that might indicate unauthorized access or misuse of your API key.
  • Secure Communication: Always use HTTPS for all API interactions. This encrypts data in transit, protecting your API key and other sensitive information from interception. The IETF RFC 7230 specifies HTTP/1.1 requirements, including the use of Transport Layer Security (TLS) for secure connections.
  • Error Handling: Implement robust error handling in your applications to gracefully manage authentication failures without exposing sensitive information.

By following these best practices, you can significantly reduce the risk of unauthorized access to your Clockify data through its API.