Skip to content

bug: projects create-platform fails with "Access to this API is forbidden" in CLI v16 #282

@cos43

Description

@cos43

Bug Description

Running appwrite projects create-platform fails with:

Error: Access to this API is forbidden.

And if no appwrite.config.json exists in the current directory, it fails earlier with:

Error: Project is not set. Please run appwrite init project to initialize...

Steps to Reproduce

  1. Install appwrite-cli@16.0.0
  2. Run appwrite login
  3. Run:
    appwrite projects create-platform \
      --project-id <your-project-id> \
      --type web \
      --name "My App" \
      --hostname localhost
  4. Observe: Error: Access to this API is forbidden.

Root Cause

In dist/cli.cjs, getProjectsClient uses sdkForProject() instead of sdkForConsole():

// ❌ Current (broken) — sets x-appwrite-project to local project ID
const getProjectsClient = async () => {
  const sdkClient = await sdkForProject();
  ...
};

The server-side projects.php enforces that x-appwrite-project must be console:

if ($project->getId() !== 'console') {
    throw new Exception(Exception::GENERAL_ACCESS_FORBIDDEN);
}

The fix is to use sdkForConsole(), which correctly sets x-appwrite-project: console. This matches the behavior of the old lib/commands/projects.js before the TypeScript migration.

// ✅ Fix
const getProjectsClient = async () => {
  const sdkClient = await sdkForConsole();
  ...
};

This affects all appwrite projects subcommands (create-platform, list-platforms, create-key, list-keys, etc.).

Environment

  • CLI version: 16.0.0
  • Appwrite server: 1.8.1 (self-hosted)
  • Node: v22.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions