Significant-Gravitas/AutoGPT · error · HTTPException

Unsupported credential type: {request.type}

Error message

Unsupported credential type: {request.type}

What it means

Raised (HTTP 400) by the external create-credentials endpoint when `request.type` (a discriminated union field) is not one of `"api_key"`, `"user_password"`, or `"host_scoped"`. The request model uses a discriminated union, so in practice FastAPI's own 422 validation usually catches bad types first; this branch is a defensive backstop for any payload that passes parsing without a supported type.

Source

Thrown at autogpt_platform/backend/backend/api/external/v1/integrations.py:579

        )
    elif request.type == "user_password":
        credentials = UserPasswordCredentials(
            provider=provider,
            username=SecretStr(request.username),
            password=SecretStr(request.password),
            title=request.title,
        )
    elif request.type == "host_scoped":
        # Convert string headers to SecretStr
        secret_headers = {k: SecretStr(v) for k, v in request.headers.items()}
        credentials = HostScopedCredentials(
            provider=provider,
            host=request.host,
            headers=secret_headers,
            title=request.title,
        )
    else:
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail=f"Unsupported credential type: {request.type}",
        )

    # Store credentials
    try:
        await creds_manager.create(auth.user_id, credentials)
    except Exception:
        logger.exception("Failed to store credentials")
        raise HTTPException(
            status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
            detail="Failed to store credentials",
        )

    logger.info(f"Created {request.type} credentials for provider {provider}")

    return CreateCredentialResponse(
        id=credentials.id,

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Use one of the supported types: `api_key`, `user_password`, or `host_scoped` with the matching body fields.
  2. For OAuth providers, use the `/oauth/authorize` + `/oauth/callback` flow instead of this endpoint.
  3. Upgrade the platform if you need a credential type introduced in a newer version.

Example fix

# before
POST /integrations/github/credentials {"type": "oauth", "access_token": "..."}  # 400/422

# after
POST /integrations/github/credentials {"type": "api_key", "api_key": "ghp_...", "title": "CI token"}
Defensive patterns

Strategy: type-guard

Validate before calling

SUPPORTED = {"api_key", "user_password", "host_scoped"}
assert body["type"] in SUPPORTED, f"type must be one of {SUPPORTED}",
client.post(f"/integrations/{provider}/credentials", json=body)

Type guard

from typing import TypedDict

class ApiKeyBody(TypedDict):
    type: str  # literal "api_key"
    api_key: str
    title: str | None

def is_api_key_body(b: dict) -> bool:
    return b.get("type") == "api_key" and isinstance(b.get("api_key"), str)

Try / catch

try:
    client.post(f"/integrations/{provider}/credentials", json=body)
except HTTPError as e:
    if e.response.status_code in (400, 422) and "credential type" in e.response.text:
        raise ValueError(f"use api_key|user_password|host_scoped; OAuth goes via /oauth/*") from e
    raise

Prevention

When it happens

Trigger: POST `/integrations/{provider}/credentials` with `"type": "oauth"`, `"type": "bearer"`, a typo like `"apikey"`, or an omitted/misnamed discriminator in the JSON body (the latter typically yields 422 instead).

Common situations: Assuming OAuth credentials can be created here (they must go through initiate/complete); new credential types added in a newer platform version being sent to an older backend; hand-built JSON payloads with wrong discriminator values.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/34bd33cf83c9ac89. Report an issue: GitHub.