Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Service Accounts

Learn how to manage and use service accounts and API keys .

Service accounts in ZenML Pro provide a secure way to authenticate automated systems, CI/CD pipelines, and other non-interactive applications with your ZenML Pro organization. Unlike user accounts, service accounts are designed specifically for programmatic access and can be managed centrally through the Organization Settings interface.

Accessing Service Account Management

To manage service accounts in your ZenML Pro organization, navigate to your ZenML Pro dashboard, click on "Settings" in the organization navigation menu and select "Service Accounts" from the settings sidebar. This is the main interface where you can perform all service account and API key operations.

Service Accounts

Using Service Account API Keys

Once you have created a service account and API key, you can use them to authenticate to the ZenML Pro API and use it to programmatically manage your organization. You can also use the API key to access all the workspaces in your organization to e.g. run pipelines from the ZenML Python client.

ZenML Pro API programmatic access

The API key can be used to authenticate to the ZenML Pro management REST API programmatically. There are two methods to do this - one is simpler but less secure, the other is secure and recommended but more complex:

To authenticate to the REST API, simply pass the API key directly in the Authorization header used with your API calls:

  • using curl:

  • using wget:

  • using python:

Reduce the risk of API key exposure by periodically exchanging the API key for a short-lived API token:

  1. To obtain a short-lived API token using your API key, send a POST request to the /auth/login endpoint. Here are examples using common HTTP clients:

    • using curl:

    • using wget:

    • using python:

This will return a response like this (the short-lived API token is the access_token field):

  1. Once you have obtained a short-lived API token, you can use it to authenticate your API requests by including it in the Authorization header. When the token expires, simply repeat the steps above to obtain a new short-lived API token. For example, you can use the following command to check your current user:

    • using curl:

    • using wget:

    • using python:

See the API documentation for detailed information on programmatic access patterns.

It is also possible to authenticate as the service account using the OpenAPI UI available at https://cloudapi.zenml.io:

OpenAPI UI authentication

The session token is stored as a cookie, which essentially authenticates your entire OpenAPI UI session. Not only that, but you can now open https://cloud.zenml.io and navigate your organization and its resources as the service account.

ZenML Pro UI authentication

Workspace access

You can also use the ZenML Pro API key to access all the workspaces in your organization:

  • with environment variables:

  • with the CLI:

ZenML Pro Workspace API programmatic access

Similar to the ZenML Pro API programmatic access, the API key can be used to authenticate to the ZenML Pro workspace REST API programmatically. This is no different from using the OSS API key to authenticate to the OSS workspace REST API programmatically. There are two methods to do this - one is simpler but less secure, the other is secure and recommended but more complex:

Use the Pro API key directly to authenticate your API requests by including it in the Authorization header. For example, you can use the following command to check your current workspace user:

  • using curl:

  • using wget:

  • using python:

Reduce the risk of Pro API key exposure by periodically exchanging the Pro API key for a short-lived workspace API token.

  1. To obtain a short-lived workspace API token using your Pro API key, send a POST request to the /api/v1/login endpoint. Here are examples using common HTTP clients:

    • using curl:

    • using wget:

    • using python:

This will return a response like this (the workspace API token is the access_token field):

  1. Once you have obtained a short-lived workspace API token, you can use it to authenticate your API requests by including it in the Authorization header. When the short-lived workspace API token expires, simply repeat the steps above to obtain a new one. For example, you can use the following command to check your current workspace user:

    • using curl:

    • using wget:

    • using python:

Service Account Operations

Managing Service Account Roles and Permissions

Service accounts are no different from regular users in that they can be assigned different Organization, Workspace and Project roles to control their access to different parts of the organization and they can be organized into teams. They are marked as "BOT" in the UI, to clearly identify them as non-human users.

Service account Organization roles
Service account Workspace roles

Activating and Deactivating Service Accounts

Service account activation controls whether the account can be used for authentication. Deactivating a service account immediately prevents all associated API keys from working.

Deleting a Service Account

Deleting a service account permanently removes it and all associated API keys from your organization.

API Key Management

API keys are the credentials used by applications to authenticate as a service account. Each service account can have multiple API keys, allowing for different access patterns. When you create a new service account, you have the option to automatically create a default API key for it.

Creating an API Key

Activating and Deactivating API Keys

Individual API keys can be activated or deactivated independently of the service account status.

Rotating API Keys

API key rotation creates a new key value while optionally preserving the old key for a transition period. This is essential for maintaining security without service interruption.

Zero-Downtime Rotation

By setting a retention period, you can update your applications to use the new API key while the old key remains functional. This enables zero-downtime key rotation for production systems.

Deleting API Keys

Security Best Practices

Key Management

  • Regular Rotation: Rotate API keys regularly (recommended: every 90 days for production keys)

  • Principle of Least Privilege: Create separate service accounts for different purposes rather than sharing keys

  • Secure Storage: Store API keys in secure credential management systems, never in code repositories

  • Monitor Usage: Regularly review the "last used" timestamps to identify unused keys

Access Control

  • Descriptive Naming: Use clear, descriptive names for service accounts and API keys to track their purposes

  • Documentation: Maintain documentation of which systems use which service accounts

  • Regular Audits: Periodically review and clean up unused service accounts and API keys

Operational Security

  • Immediate Deactivation: Deactivate service accounts and API keys immediately when they're no longer needed

  • Incident Response: Have procedures in place to quickly rotate or deactivate compromised keys

  • Team Coordination: Coordinate with your team before making changes to production service accounts

Migration of workspace level service accounts

Workspace-level service accounts and API keys in ZenML Pro are deprecated. Existing workspace-level API keys may continue to authenticate temporarily for compatibility, but workloads that keep using workspace-level service account API keys will lose access during a future workspace upgrade. Please migrate them to organization-level service accounts as soon as possible.

The reason for this deprecation is that workspace-level service accounts and API keys cannot be subjected to RBAC rules and therefore always have full access to the workspace.

Use ZenML Pro organization service accounts instead. They are managed centrally in the ZenML Pro control plane and can be used to authenticate both to the ZenML Pro API and to the Workspace API for the workspaces in your organization.

To migrate automation that still uses a workspace-level service account API key, follow these steps:

  1. Create a ZenML Pro organization service account in Organization > Settings > Service Accounts. Use the exact same username as the old workspace-level service account. This allows ZenML Pro to adopt the existing workspace account and preserve its resource ownership and lineage/history. Be aware that the organization-level service account is shared across all workspaces in the organization.

  2. Assign Organization and Workspace roles to the new service account. To preserve the same unrestricted permissions that the workspace-level service account currently has but limited to the affected workspace, grant the Organization Member role at the organization level and the Workspace Admin role in the affected workspace. For better security, we strongly recommend making full use of ZenML Pro RBAC and granting only the specific roles and permissions that the service account actually needs.

  3. Create an API key for the new organization-level service account and update your automation, CI/CD jobs, and pipeline workloads to use that key instead of the old workspace-level API key.

You can keep using the workspace URL as the ZenML store URL:

For self-hosted ZenML Pro API servers, also set the ZenML Pro API URL:

  1. Run the affected workloads once to verify that they authenticate successfully with the organization-level service account.

  2. The first successful workspace authentication with the new organization-level API key adopts the existing workspace service account with the matching username. Creating the organization account alone does not trigger adoption. ZenML links the existing workspace account to the organization identity while keeping the workspace account's internal ID, so existing resource ownership and history remain intact. The adopted account will no longer be listed as a workspace-level service account. Repeat workspace authentication for each workspace you are migrating.

Existing API keys continue to work after adoption

Adopting a workspace-level service account does not invalidate its existing workspace-level API keys. Those keys continue to authenticate to the workspace as the adopted organization-level service account, allowing you to migrate workloads without interruption. This compatibility period also gives you time to identify workloads that still use legacy keys: inspect the Last used timestamp of each workspace-level API key in the UI to see whether it is still authenticating. The keys remain workspace-level credentials and do not become ZenML Pro organization API keys, so you should still replace them with an organization-level API key as part of the migration.

  1. Monitor the Last used timestamp for each existing workspace-level API key in the UI. If a timestamp continues to update after you believe a workload has migrated, that workload is likely still using the old key. Account for infrequent jobs before concluding that a key is unused.

  2. Once the affected workloads work with the new credentials, deactivate the legacy workspace-level API keys and test again. You can reactivate the keys and switch workloads back to them if you need to roll back. After confirming that migration is complete, delete the legacy keys. Adoption reuses the existing workspace account, so there is no separate old account to delete or detach from resources. Keep the organization account in place during credential rollback; deleting it does not reverse adoption.

Adopted service accounts are managed at the organization level. Activate or deactivate their legacy workspace-level keys individually without changing the organization-level service account. Adoption activates the workspace account but does not reactivate any legacy keys you have already deactivated. Workspace-level accounts that have not been adopted can also be deactivated or reactivated. They can be deleted only if they no longer own resources.

Troubleshooting

Common Issues

API Key Not Working

  • Verify the service account is active

  • Verify the specific API key is active

  • Check that the API key hasn't expired (if using rotation with retention)

  • Ensure the API key is correctly formatted in your environment variables

Cannot Delete Service Account

  • Verify you have the necessary permissions in the organization

API Key Creation Failed

  • Ensure you have write permissions in the organization

  • Check that the service account is active

  • Verify the API key name doesn't conflict with existing keys

Need Help?

If you encounter issues with service account management, check the ZenML Pro documentation or contact your organization administrator for assistance with permissions and access control.

ZenML Scarf

Last updated

Was this helpful?