LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdkauthtypeson
    Class●Since v0.1

    on

    Copy
    on()

    Attributes

    Classes

    View source on GitHub
    attribute
    value
    class
    threads
    class
    assistants
    class
    crons
    class
    store

    Namespace for type definitions of different API operations.

    This class organizes type definitions for create, read, update, delete, and search operations across different resources (threads, assistants, crons).

    Usage

    Start by denying all requests by default, then add handlers to allow access:

    from langgraph_sdk import Auth
    
    auth = Auth()
    
    # Default deny: reject all requests without a specific handler
    @auth.on
    async def deny_all(ctx: Auth.types.AuthContext, value: Auth.on.value):
        return False
    
    # Allow thread creation, stamping the owner
    @auth.on.threads.create
    async def allow_thread_create(ctx: Auth.types.AuthContext, value: Auth.on.threads.create.value):
        value.setdefault("metadata", {})["owner"] = ctx.user.identity
    
    # Allow assistant search, scoped to user's resources
    @auth.on.assistants.search
    async def allow_assistant_search(ctx: Auth.types.AuthContext, value: Auth.on.assistants.search.value):
        return {"owner": ctx.user.identity}

    Types for thread-related operations.

    Types for assistant-related operations.

    Types for cron-related operations.

    Types for store-related operations.