---
schema_version: "1"
id: 51234c448e051519f76884992d2562719beffece81d310a11ea506592e4d29b7
title: $Api
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/variables/pages-variables-global-api.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-variables-global-api.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 7106ff3f23467eab976c09547f9f567ab36a98f3f20e8adbf2743f72c770ad16
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# $Api

A global merge field type to use when referencing API URLs.

## Usage

Use dot notation to specify an API URL from either the Enterprise or Partner WSDL, or to return the session ID.

**important:** `$Api.Session_ID` and `GETSESSIONID()` return the same value, an identifier for the current session in the current context. This context varies depending on where the global variable or function is evaluated. For example, if you use either in a custom formula field, and that field is displayed on a standard page layout in Salesforce Classic, the referenced session is a basic Salesforce session. That same field (or the underlying variable or formula result), when used in a Visualforce page, references a Visualforce session instead.

Session contexts are based on the domain of the request. That is, the session context changes whenever you cross a hostname boundary, such as from .salesforce.com to .vf.force.com or .lightning.force.com.

Session identifiers from different contexts, and the sessions themselves, are different. When you transition between contexts, the old session is replaced by the new one, and the old session is no longer valid. The session ID also changes at this time.

Normally Salesforce transparently handles session hand-off between contexts, but if you’re passing the session ID around yourself, you might need to re-access `$Api.Session_ID` or `GETSESSIONID()` from the new context to ensure a valid session ID.

Not all sessions are created equal. In particular, sessions obtained in a Lightning Experience context have reduced privileges, and don't have API access. You can't use these session IDs to make API calls. `{!$Api.Session_ID}` isn’t generated for guest users.

If you use a JWT-based access token for session authentication, you can’t use `$Api.Session_ID`. To use `$Api.Session_ID`, use an opaque access token instead. Make sure that the “Issue JSON Web Token (JWT)-based access tokens for named users” setting isn’t selected for your external client app or connected app.

## Example

-   `{!$Api.Enterprise_Server_URL__xxx}`: The Enterprise WSDL SOAP endpoint where _xxx_ represents the version of the API. For example, `{!$Api.Enterprise_Server_URL_260}` is the expression for the endpoint for version 26.0 of the API.
-   `{!$Api.Partner_Server_URL__xxx}`: The Partner WSDL SOAP endpoint where _xxx_ represents the version of the API. `{!$Api.Partner_Server_URL_250}` is the expression for the endpoint for version 25.0 of the API.
-   `{!$Api.Session_ID}`: The session ID.

