Skip to content

feat: support multiple API keys (profiles) for managing multiple Dokploy organizations #44

Open

Description

@lamualfa

Problem

The CLI currently stores a single {url, token} credential pair (via dokploy auth, env vars, or .env). There is no way to manage multiple organizations or multiple Dokploy instances without manually swapping credentials each time.

Current workaround: re-run dokploy auth -u <url> -t <token> or swap DOKPLOY_API_KEY / DOKPLOY_URL environment variables every time you need to target a different organization or server.

This is painful for users who:

  • Manage multiple Dokploy instances (e.g., staging vs production, or different clients)
  • Belong to multiple organizations within the same Dokploy instance (where API keys are org-scoped via the metadata.organizationId field in user.createApiKey)
  • Work in CI/CD pipelines that deploy to different environments

Proposed Solution

Introduce a profile system (similar to aws-cli profiles, kubectl contexts, or gcloud configurations).

CLI interface

# Save a named profile
dokploy auth --profile prod -u https://panel.example.com -t <api-key>
dokploy auth --profile staging -u https://staging.example.com -t <api-key>
dokploy auth --profile client-acme -u https://panel.example.com -t <org-scoped-key>

# List profiles
dokploy profiles list
#  * prod       https://panel.example.com
#    staging    https://staging.example.com
#    client-acme https://panel.example.com

# Switch active profile
dokploy profiles use staging

# Show current profile
dokploy profiles current

Config file (~/.dokploy/config.json)

{
  "currentProfile": "prod",
  "profiles": {
    "prod": {
      "url": "https://panel.example.com",
      "token": "<api-key>"
    },
    "staging": {
      "url": "https://staging.example.com",
      "token": "<api-key>"
    },
    "client-acme": {
      "url": "https://panel.example.com",
      "token": "<org-scoped-api-key>"
    }
  }
}

Key changes

  1. client.ts — readAuthConfig() resolves credentials in this order:

    • --profile <name> global flag (highest priority)
    • DOKPLOY_PROFILE env var
    • DOKPLOY_URL + DOKPLOY_API_KEY env vars (backward compatible)
    • Active profile from config (stored in ~/.dokploy/config.json or similar)
    • Legacy config.json next to the package (backward compatible)
  2. commands/auth.ts — Add optional --profile <name> flag. When omitted, saves to a default profile for backward compatibility.

  3. New profiles command group — list, use, current, remove.

  4. Global --profile flag — Allow overriding the active profile on any command: dokploy --profile staging project list.

Benefits

  • Backward compatible: existing single-key usage continues to work unchanged
  • No credential juggling: switch contexts with one command instead of re-authenticating
  • CI/CD friendly: use DOKPLOY_PROFILE=staging dokploy project list or --profile staging
  • Aligns with server capabilities: the Dokploy server already supports org-scoped API keys; the CLI just needs a way to use them conveniently

Related

  • The server API already supports organization-scoped API keys via user.createApiKey with metadata.organizationId
  • 22 CLI commands already accept --organizationId flags, meaning the server is multi-org aware but the CLI auth layer is not

Activity

  1. ImBIOS commented on Aug 17, 2026

    @ImBIOS

    Temporary workaround: dokploy-account — manage multiple Dokploy accounts for the dokploy CLI

    Usage:
    dokploy-account add -u -t Save a new account
    dokploy-account list List saved accounts
    dokploy-account remove Delete an account
    dokploy-account current Print the currently active account
    dokploy-account <args...> Run dokploy with the given account
    dokploy-account use Switch the default account (symlink)

    Accounts are stored in: /home/imbios/.dokploy-accounts wrapper

    If you need multi-account support today while #50 is reviewed, you can use the standalone wrapper:

    pnpx github:ImBIOS/dokploy-account#canary

    Requires to be installed globally.

    Usage

    dokploy-account add prod -u https://panel.dokploy.com -t YOUR_API_KEY
    dokploy-account add staging -u https://staging.example.com -t OTHER_KEY
    
    dokploy-account list
    dokploy-account use staging
    
    # Run dokploy as a specific account
    dokploy-account prod project all
    dokploy-account staging application deploy --applicationId xxx
    
    # Or just use the current default
    dokploy-account project all

    Accounts are stored in ~/.dokploy-accounts/<name>.env.

    This is a temporary workaround — the native profile support in PR #50 is the proper solution and should land once reviewed.

  2. added a commit that references this issue on Aug 26, 2026
    c9092a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions