Text of code.visualstudio.com › api › references › vscode-api as Styx crawled it on Oct 9, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

VS Code API | Visual Studio Code Extension API

AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. 🎬 Watch The Story of VS Code! VS Code is now on Instagram, follow @vscode.ig for updates, tips, and more. Rewatch GitHub Copilot Day. VS Code API View as Markdown Ask in VS Code Ask in VS Code Insiders VS Code API is a set of JavaScript APIs that you can invoke in your Visual Studio Code extension.

This page lists all VS Code APIs available to extension authors. API namespaces and classes This listing is compiled from the vscode.d.ts file from the VS Code repository. authentication Namespace for authentication. Events onDidChangeSessions : Event < AuthenticationSessionsChangeEvent > An Event which fires when the authentication sessions of an authentication provider have been added, removed, or changed. Functions getAccounts ( providerId : string ) : Thenable <readonly AuthenticationSessionAccountInformation []> Get all accounts that the user is logged in to for the specified provider.

Use this paired with getSession in order to get an authentication session for a specific account. Currently, there are only two authentication providers that are contributed from built in extensions to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'. Note: Getting accounts does not imply that your extension has access to that account or its authentication sessions.

You can verify access to the account by calling getSession . Parameter Description providerId : string The id of the provider to use Returns Description Thenable <readonly AuthenticationSessionAccountInformation []> A thenable that resolves to a readonly array of authentication accounts. getSession ( providerId : string , scopeListOrRequest : readonly string [] | AuthenticationWwwAuthenticateRequest , options : AuthenticationGetSessionOptions & {createIfNone: true | AuthenticationGetSessionPresentationOptions } ) : Thenable < AuthenticationSession > Get an authentication session matching the desired scopes or satisfying the WWW-Authenticate request.

Rejects if a provider with providerId is not registered, or if the user does not consent to sharing authentication information with the extension. If there are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use. Built-in auth providers include: 'github' - For GitHub.com 'microsoft' For both personal & organizational Microsoft accounts (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds Parameter Description providerId : string The id of the provider to use scopeListOrRequest : readonly string [] | AuthenticationWwwAuthenticateRequest A scope list of permissions requested or a WWW-Authenticate request.

These are dependent on the authentication provider. options : AuthenticationGetSessionOptions & {createIfNone: true | AuthenticationGetSessionPresentationOptions } The AuthenticationGetSessionOptions to use Returns Description Thenable < AuthenticationSession > A thenable that resolves to an authentication session getSession ( providerId : string , scopeListOrRequest : readonly string [] | AuthenticationWwwAuthenticateRequest , options : AuthenticationGetSessionOptions & {forceNewSession: true | AuthenticationGetSessionPresentationOptions } ) : Thenable < AuthenticationSession > Get an authentication session matching the desired scopes or request.

Rejects if a provider with providerId is not registered, or if the user does not consent to sharing authentication information with the extension. If there are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use. Built-in auth providers include: 'github' - For GitHub.com 'microsoft' For both personal & organizational Microsoft accounts (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds Parameter Description providerId : string The id of the provider to use scopeListOrRequest : readonly string [] | AuthenticationWwwAuthenticateRequest A scope list of permissions requested or a WWW-Authenticate request.

These are dependent on the authentication provider. options : AuthenticationGetSessionOptions & {forceNewSession: true | AuthenticationGetSessionPresentationOptions } The AuthenticationGetSessionOptions to use Returns Description Thenable < AuthenticationSession > A thenable that resolves to an authentication session getSession ( providerId : string , scopeListOrRequest : readonly string [] | AuthenticationWwwAuthenticateRequest , options ? : AuthenticationGetSessionOptions ) : Thenable < AuthenticationSession > Get an authentication session matching the desired scopes or request.

Rejects if a provider with providerId is not registered, or if the user does not consent to sharing authentication information with the extension. If there are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use. Built-in auth providers include: 'github' - For GitHub.com 'microsoft' For both personal & organizational Microsoft accounts (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds Parameter Description providerId : string The id of the provider to use scopeListOrRequest : readonly string [] | AuthenticationWwwAuthenticateRequest A scope list of permissions requested or a WWW-Authenticate request.

These are dependent on the authentication provider. options ? : AuthenticationGetSessionOptions The AuthenticationGetSessionOptions to use Returns Description Thenable < AuthenticationSession > A thenable that resolves to an authentication session or undefined if a silent flow was used and no session was found registerAuthenticationProvider ( id : string , label : string , provider : AuthenticationProvider , options ? : AuthenticationProviderOptions ) : Disposable Register an authentication provider.

There can only be one provider per id and an error is being thrown when an id has already been used by another provider. Ids are case-sensitive. Parameter Description id : string The unique identifier of the provider. label : string The human-readable name of the provider. provider : AuthenticationProvider The authentication provider provider. options ? : AuthenticationProviderOptions Additional options for the provider.

Returns Description Disposable A Disposable that unregisters this provider when being disposed. chat Namespace for chat functionality. Users interact with chat participants by sending messages to them in the chat view. Chat participants can respond with markdown or other types of content via the ChatResponseStream . Functions createChatParticipant ( id : string , handler : ChatRequestHandler ) : ChatParticipant Create a new chat participant instance.

Parameter Description id : string A unique identifier for the participant. handler : ChatRequestHandler A request handler for the participant. Returns Description ChatParticipant A new chat participant commands Namespace for dealing with commands. In short, a command is a function with a unique identifier. The function is sometimes also called command handler . Commands can be added to the editor using the registerCommand and registerTextEditorCommand functions.

Commands can be executed manually or from a UI gesture. Those are: palette - Use the commands -section in package.json to make a command show in the command palette . keybinding - Use the keybindings -section in package.json to enable keybindings for your extension. Commands from other extensions and from the editor itself are a

The rest of this page is on the live site.