API Keys
Create and manage API keys for your projects.
Daytona API keys authenticate requests from the SDKs, the CLI, and the API to the resources in a project. To pass a key, see authentication.
Organization API keys cover organization-level operations that are not tied to a project.
Every project API key belongs to exactly one project and carries an explicit list of permissions; its requests are confined to both. Keys can carry an expiry. Revocation applies to new requests; a regional proxy can accept a revoked key for up to 30 seconds.
Create an API key
Create an API key to authenticate Daytona SDK and API requests.
- Go to Daytona Dashboard ↗
- Select the project in the header switcher
- Click Create API Key
- Enter a Key Name, optionally set an expiry, and select permissions
- Click Create API Key
- Copy the API key to your clipboard and use it to authenticate requests
daytona key mint --project PROJECT_ID \
--name my-api-key \
--permission write:sandboxes,delete:sandboxes \
--expires 2027-01-01T00:00:00Z| Flag | Type | Description |
|---|---|---|
--permission | string | A comma-separated list of permissions. |
--expires | string | An RFC 3339 timestamp or a Go duration such as 720h, counted from now. |
| Field | Description |
|---|---|
name | Display name for the key. Optional; defaults to default. |
project_permissions | Required, non-empty list of permissions. Unknown values are rejected with 400 error status code. |
expires_at | Optional RFC 3339 timestamp in the future. Omit for a key that never expires. |
service_account_id | Optional. Mint the key for a service account instead of yourself. Service account keys must be named. |
Credentials
Daytona accepts two bearer credentials, named differently in this page's API examples:
| Credential | Description |
|---|---|
| API KEY | A project API key created as described above. It authenticates SDK, toolbox, and sandbox requests, and the few management routes that accept it, such as getting the current key. This is the credential the SDKs and the DAYTONA_API_KEY variable carry. See authentication for how to pass it to the SDKs, the CLI, and API requests. |
| OIDC TOKEN | The session token of a signed-in user (an OIDC bearer JWT, the credential the dashboard uses). Management routes that act on behalf of a person require it and reject API keys with 401: creating, listing, and revoking keys, service accounts, organizations, projects, and billing. Obtain it by signing in with the dashboard or daytona login; the CLI commands in those sections use the saved session for you. |
Organization API keys (dtno_...) are a third kind, scoped to an organization rather than a project; that section lists the scopes they can hold.
Permissions & Scopes
| Resource | Scope | Description |
|---|---|---|
| Sandboxes | read:sandboxes | View sandboxes and use the toolbox |
write:sandboxes | Create/modify sandboxes | |
delete:sandboxes | Delete sandboxes | |
| Snapshots | read:snapshots | View snapshots |
write:snapshots | Create/modify snapshots | |
delete:snapshots | Delete snapshots | |
| Images | read:images | View images |
write:images | Create/modify images | |
delete:images | Delete images | |
| Volumes | read:volumes | View volumes |
write:volumes | Create/modify volumes | |
delete:volumes | Delete volumes | |
| Registries | read:registries | View registries |
write:registries | Create/modify registries | |
delete:registries | Delete registries | |
| Secrets | read:secrets | View secrets |
write:secrets | Create/modify secrets | |
delete:secrets | Delete secrets | |
| Spending | read:spending | View project spending |
| Limits | read:limits | View project limits (reserved) |
| Runners | read:runners | View runner capacity |
Operations
List API keys
List the API keys of a project. The list never contains tokens. Revoked keys are hidden unless requested; Daytona deletes revoked and expired keys 7 days after they stop working.
daytona key list --project PROJECT_ID --include-revokedGet by ID
curl 'https://api.daytona.com/api-keys/KEY_ID' \
--header 'Authorization: Bearer YOUR_OIDC_TOKEN'Get the current API key
Get the API key that authenticates the request, including the project and organization it acts in and the permissions it carries. The response never contains the token.
from daytona import Daytona
daytona = Daytona()
key = daytona.v2.current_api_key()
print(key.name, key.project_name, key.org_name)
print(key.project_permissions)Exchange a token
Exchange a signed-in user's session token for a short-lived access token scoped to one project. The access token carries the user's own permissions in that project and authenticates workload requests in place of a project API key. Organization API keys cannot be exchanged.
curl 'https://api.daytona.com/auth/token' \
--request POST \
--header 'Authorization: Bearer YOUR_OIDC_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
"subject_token": "YOUR_OIDC_TOKEN",
"subject_token_type": "urn:ietf:params:oauth:token-type:access_token",
"project_id": "PROJECT_ID"
}'{
"access_token": "eyJ...",
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
"token_type": "Bearer",
"expires_in": 300
}| Field | Type | Description |
|---|---|---|
grant_type | string | Required. urn:ietf:params:oauth:grant-type:token-exchange. |
subject_token | string | Required. Must be the same token as the bearer in the Authorization header; otherwise the request returns 400. |
subject_token_type | string | Required. urn:ietf:params:oauth:token-type:access_token or urn:ietf:params:oauth:token-type:jwt. |
project_id | string | Required. The project the access token is scoped to. An unknown project, or one you are not a member of, returns 404. |
Revoke an API key
Revoke an API key. Revocation cannot be undone. New requests made with the key fail, except at a regional proxy, which can accept the key for up to 30 seconds after revocation. Daytona deletes the revoked key 7 days later.
- Go to Daytona Dashboard ↗
- Click Revoke next to the API key you want to revoke
- Confirm the revocation
daytona key revoke KEY_IDService accounts
Service accounts are non-human identities in your organization. Use them to own API keys for automation so that the keys are not tied to a person's membership.
Create a service account
daytona service-account create my-service-account --role developer --org ORG_ID| Flag | Type | Description |
|---|---|---|
--role | string | A comma-separated list of role slugs. |
Create a service account key
Create an API key owned by a service account. The key keeps working when its creator leaves the organization. Outside the default project, the service account must first be added to the project, and the key can carry only permissions you and the service account both hold.
- Go to Daytona Dashboard ↗
- Click Create API Key
- Under Owner, select the service account
- Enter a Key Name, select permissions, and click Create API Key
daytona key mint --project PROJECT_ID \
--name my-service-account-key \
--permission write:sandboxes \
--service-account SERVICE_ACCOUNT_ID \
--org ORG_IDList service accounts
daytona service-account list --org ORG_ID
# Include archived service accounts
daytona service-account list --org ORG_ID --include-archivedGet a service account
daytona service-account get SERVICE_ACCOUNT_IDUpdate a service account
Update a service account's name, description, or roles. Fields you leave out stay unchanged, and new roles replace the whole role set. When the new roles are narrower, Daytona revokes the account's project API keys that exceed them.
# The CLI updates the name (--name) and roles (--role); it cannot set the description
daytona service-account update SERVICE_ACCOUNT_ID --role maintainerArchive a service account
Archive a service account. This revokes every project API key it owns. An archived account cannot be updated, added to projects, or given new keys, and lists hide it by default.
daytona service-account delete SERVICE_ACCOUNT_IDOrganization API keys
Organization API keys authenticate organization-level operations that are not tied to a project.
| Resource | Scope | Description |
|---|---|---|
| Audit logs | read:audit | View audit logs |
| Billing | read:wallet, write:wallet | View and manage the organization wallet |
| SSO | read:sso, write:sso | View and manage SSO |
| BYOC infrastructure | read:regions, write:regions, delete:regions | View and manage regions |
write:runners, delete:runners | Register and remove runners |
# Create
daytona org-key mint --org ORG_ID --name my-org-key --permission read:audit
# List
daytona org-key list --org ORG_ID --include-revoked
# Revoke
daytona org-key revoke KEY_ID| Flag | Type | Description |
|---|---|---|
--name | string | Required. |