Docs
Contents

Console SDK(Python)

Replace <APPBASE_ENDPOINT_WITH_V1>, <APPBASE_CONSOLE_ORIGIN>, and <APPBASE_CONSOLE_HOST> where used with values for the intended environment before running the examples.

The Python management-surface SDK (pip package agentbase-console-python-sdk, import namespace agentbase_console) covers the Console / management-surface API: organization and project governance, Key issuance, cross-project operations, and can coexist in the same environment with the Server package (../server-sdk/python.md). For the Node / Java / Go surfaces, see nodejs.md / java.md / go.md in the same directory.

Artifacts and installation

The artifact has not been published to PyPI: extract the Console wheel from the agentbase-sdks release ZIP and install it with pip; for the complete commands, see the "Obtaining and Installing" section of ../examples/python.md.

Initialization and auth mounting

The Console login response body does not contain the session secret (it is only in the a_session_console cookie); first log in via raw HTTP to get the cookie, then attach it to the Console SDK client:

import re

import requests
from agentbase_console.client import Client as ConsoleClient

resp = requests.post(
    '<APPBASE_ENDPOINT_WITH_V1>/account/sessions/email',
    headers={'X-Appwrite-Project': 'console', 'Content-Type': 'application/json'},
    json={'email': CONSOLE_EMAIL, 'password': CONSOLE_PASSWORD},
    allow_redirects=False,
    timeout=10,
)
if resp.status_code != 201:
    raise RuntimeError(f'Console sign-in failed with HTTP {resp.status_code}')
secret = re.search(r'a_session_console=([^;]+)', resp.headers['set-cookie']).group(1)

console_client = (
    ConsoleClient()
    .set_endpoint('<APPBASE_ENDPOINT_WITH_V1>')
    .set_project('console')
)
console_client.add_header('origin', '<APPBASE_CONSOLE_ORIGIN>')
console_client.add_header('x-forwarded-host', '<APPBASE_CONSOLE_HOST>')
console_client.add_header('Cookie', f'a_session_console={secret}')

Send the login request to the configured Console API endpoint. It must return HTTP 201; automatic redirects are disabled to keep the login body at that endpoint. Store newly issued keys directly in your secret manager.

Typical governance calls

The service plane (agentbase_console.services) includes account, teams, projects, users, proxy, migrations, etc.; method names are snake_case, the same as the Server package:

from agentbase_console.services.projects import Projects
from agentbase_console.services.teams import Teams

teams = Teams(console_client)
projects = Projects(console_client)

teams.create(team_id='my-team', name='My Team', roles=['owner'])
project = projects.create(project_id='unique()', name='My Project', team_id='my-team')
key = projects.create_key(
    project_id=project.id,
    name='server key',
    scopes=['users.read', 'users.write', 'teams.read', 'teams.write'],
    key_id='unique()',
)

Console-only operations such as organizations, members, and platform registration cannot use a project API Key.

Feature surface navigation

For the complete mapping of governance domains to services see nodejs.md "Feature surface navigation"; feature pages per domain: Organizations, Projects and Keys, Quotas, Usage, Sites and Domains, Platform Operations.

Errors and boundaries

Examples by language

The following presents examples by language for each functional domain; each card can switch languages (synced across the full page).

Create a team, project, and issue a Key

Python method names are snake_case, Go uses a facade New* constructor + With* options. This domain has no direct REST call tab; for direct REST calls, see the "Quotas and rate limits" card below.

Before running this example, provide a short-lived management JWT for the target Console in APPBASE_ADMIN_JWT.

import { Client, Teams, Projects, ID, Scopes } from 'agentbase-console-sdk';

const token = process.env.APPBASE_ADMIN_JWT;
if (!token) throw new Error('Set APPBASE_ADMIN_JWT for the target Console');

const client = new Client()
    .setEndpoint(process.env.APPBASE_ENDPOINT!)           // <APPBASE_ENDPOINT_WITH_V1>
    .setProject(process.env.APPBASE_CONSOLE_PROJECT_ID ?? 'console')
    .setJWT(token);

const originalPrepareRequest = client.prepareRequest;
if (typeof originalPrepareRequest !== 'function') throw new Error('Redirect control unavailable');
client.prepareRequest = function (...args) {
    const request = originalPrepareRequest.apply(this, args);
    request.options.redirect = 'error';
    return request;
};

const teams = new Teams(client);
const team = await teams.create({ teamId: ID.unique(), name: 'My Team' });

const projects = new Projects(client);
const project = await projects.create({
    projectId: ID.unique(),
    name: 'todo-app',
    teamId: team.$id,
});

const key = await projects.createKey({
    projectId: project.$id,
    name: 'setup-script',
    scopes: [Scopes.UsersRead, Scopes.UsersWrite]   // minimize scope
});
// key.secret is returned only once at creation

Usage queries

Three-level aggregation (the most recent 30 UTC days) and the legacy scheme are two separate systems; method names cannot be guessed from each other (see usage).

// account / organizations / projects are Console SDK service instances
await account.listUsageAggregates();
await organizations.listUsageAggregates({ organizationId: '<organizationId>' });
await projects.listUsageAggregates({ projectId: '<projectId>' });

Quotas and rate limits (direct REST calls)

The Python Console plane likewise has no typed quota/ratelimit evidence; use the unified REST endpoints:

# Query current quota and rate limits:
curl -sS "$APPBASE_ENDPOINT/projects/<projectId>/limits" \
  -H "X-Appwrite-Project: $APPBASE_CONSOLE_PROJECT_ID" \
  -H "X-Appwrite-Key: $APPBASE_CONSOLE_API_KEY"
# Settings: PATCH the same path, body is flat rate-limit + quota fields; Quota 0 = unlimited, RateLimit must be a positive integer
curl -sS -X PATCH "$APPBASE_ENDPOINT/projects/<projectId>/limits" \
  -H 'Content-Type: application/json' \
  -H "X-Appwrite-Project: $APPBASE_CONSOLE_PROJECT_ID" \
  -H "X-Appwrite-Key: $APPBASE_CONSOLE_API_KEY" \
  -d '{"databaseStorageLimit": 0}'
# See limits.mdx for the full field set and field-name pitfalls

Example Guide