---
updatedAt: 2025-01-08T23:23:24.000Z
agentTools:
  projectIndex: https://dev.frontapp.com/llms.txt
---

# Context API

The plugin SDK exposes an API to interact with Front.\
Because the interactions are depending on the current context, the API is defined on the `context` received via `Front.contextUpdates`.

While it is recommended to use the functions from the context, you can also call the functions directly on the main `Front` object.

To learn more about the `context` available to plugins, refer to the [Context](https://dev.frontapp.com/reference/plugin-sdk-context) topic.

> 📘
>
> When calling an API function on `Front`, the **latest context** will be used.

```javascript
const button = document.getElementById('example-button');

/*
 * Bad.
 */
let latestContext;
Front.contextUpdates.subscribe(context => {
  latestContext = context;
});
button.addEventListener('click', () => {
  if (!latestContext)
    throw new Error('Cannot process before receiving a context');

  latestContext.openUrl('https://example.com');
}

/*
 * Good.
 */
button.addEventListener('click', () => Front.openUrl('https://example.com'));
```