> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: getContextIds() - INTERNAL

## Article: getContextIds

## Article Link: https://dev.wix.com/docs/sdk/host-modules/workspace/legacy/get-context-ids-internal.md

## Article Content:

<blockquote class="warning">
  <strong> Do not publish: </strong> This module is only available for app made by Wix and isn't supported for self-hosted apps. It's intended for internal Wix platform usage.
</blockquote>

# getContextIds()

Retrieves context identifiers for the current administrative session, including account ID, user ID, site ID, and app ID.

This method provides access to important contextual information that can be used to identify the current session's administrative context within the Wix platform.

<blockquote class="important">
  <strong>Note:</strong> This method requires the admin host to be available and properly initialized. Make sure to use an updated version of the host initialization package.
</blockquote>

## Method Declaration
```js
function getContextIds(): {
  accountId: string;
  userId: string;
  siteId?: string;
  appId?: string;
};
```

## Parameters

This method takes no parameters.

## Returns

An object containing the context identifiers:

| Property | Type | Description |
| -------- | ---- | ----------- |
| `accountId` | string | The account identifier for the current session. |
| `userId` | string | The user identifier for the current session. |
| `siteId` | string (optional) | The site identifier, if available for the current session. |
| `appId` | string (optional) | The app identifier, if available for the current session. |

## Example

Get context identifiers for the current session:

```ts
declare global {
  interface SDKExposureToggle {
    alpha: true;
  }
}

import { legacy } from "@wix/admin";

const contextIds = legacy.getContextIds();
console.log("Account ID:", contextIds.accountId);
console.log("User ID:", contextIds.userId);
```

## Error Handling

The method may throw errors in the following cases:

- When the admin host is not available on the current host environment
- When the `getContextIds` method is not available on the host (requires updated host initialization package)
- When the method fails to retrieve context information