> For the complete documentation index, see [llms.txt](https://docs.uptiq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uptiq.ai/platform/platform-resources/agent-executor/secure-access.md). Agents can also search and read this documentation through its [MCP server](https://docs.uptiq.ai/~gitbook/mcp).

# Connect a website or app securely

Call a 1.5 agent from your server with an API key, and give browsers and apps short-lived access tokens.

## How access works <a href="#how-access-works" id="how-access-works"></a>

Executor 1.5 doesn't accept widget keys. A request with a widget key returns `401 WIDGET_KEY_NOT_SUPPORTED`.

* Your backend holds the agent's API key and secret. It can call the agent directly, or exchange the key and secret for a short-lived access token.
* A browser or mobile front end uses the access token, never the API key or secret, to chat with the agent.
* Never put the API key or its secret in front-end code.

## Migrate a widget integration <a href="#migrate-a-widget-integration" id="migrate-a-widget-integration"></a>

1. Create an API key for the agent. See [Authentication](https://docs.uptiq.ai/platform/console/agent-builder/deploy/authentication.md).
2. Copy the secret when it is shown. It is shown only once.
3. Store the key and secret securely on your backend, for example as environment variables.
4. Add a backend operation that [requests an access token](#request-an-access-token) for the app's end user.
5. Open [Integrate Agent](https://docs.uptiq.ai/platform/console/agent-builder/deploy/agent-integration.md) and select the **Embedded Chat** tab for the widget setup.
6. Update the front end to use the token from your backend, and remove the widget key.
7. Have your backend request a new token when the current one expires.
8. Before you make the integration available, test a new chat, a follow-up message, token expiry and deactivating the API key.

Servers that call the agent directly send the `x-api-key` and `x-api-key-secret` headers. OpenAI-compatible clients can send `Authorization: Bearer <api-key>:<api-secret>` instead.

## Request an access token <a href="#request-an-access-token" id="request-an-access-token"></a>

```http
POST /agent-executor/1.5/agents/:agentId/access-tokens
```

Send the agent's API key and secret in the headers, and the end user the token is for in the body:

```bash
curl -X POST "<BASE_URL>/agent-executor/1.5/agents/:agentId/access-tokens" \
  -H "x-api-key: <api-key>" \
  -H "x-api-key-secret: <api-secret>" \
  -H "Content-Type: application/json" \
  -d '{ "uid": "user_123" }'
```

The response has `accessToken`, `tokenType` (`Bearer`), `expiresIn` and `expiresAt`. The browser or app sends the token as `Authorization: Bearer <token>`, or as the `token` field when it opens the socket.

* A token lasts 15 minutes.
* Deactivating the API key invalidates the tokens issued from it at once, including in an open chat. An expired or invalidated token returns `401 INVALID_ACCESS_TOKEN`; request a new one from your backend.
* A token can't request another token, and can't refresh a platform sign-in session.

## Access-token restrictions <a href="#access-token-restrictions" id="access-token-restrictions"></a>

A token issued from an API key works for one agent and acts for one end user.

| Allowed                                                          | Not allowed                                                     |
| ---------------------------------------------------------------- | --------------------------------------------------------------- |
| Start and continue that user's conversations with that agent     | List, open, summarize or continue another user's conversations  |
| Make OpenAI-compatible chat and response requests for that agent | List the workspace's agents, or list models                     |
| Upload files for that agent                                      | Retrieve a response by its ID through the OpenAI-compatible API |

A2A takes only the API key, not a token. For end users of these tokens, access to integrations follows the agent's and the app's access rules. Rules for workspace people and teams aren't applied as if the end user were a signed-in workspace member.

## Import agents and move between versions <a href="#import-agents-and-move-between-versions" id="import-agents-and-move-between-versions"></a>

* A 1.5 agent, whether new or imported, gets no default widget key, and you can't create one for it.
* Agents created or imported on versions below 1.5 get a default widget key.
* Moving from 1.5 back to 1.4 restores widget keys. See [Move back to 1.4](https://docs.uptiq.ai/pages/vx1INm6meuRZBQmL9H3S#move-back-to-1.4).
* Existing widget keys keep working on versions below 1.5. Upgrading other agents doesn't revoke them.
* The **Fleet** setting stays on versions below 1.5, and comes back when you move an agent back.

For an agent below 1.5, the **Embedded Chat** setup shows its widget key, or says that the agent has no widget key. A marketplace playground that can't try an agent with a widget key shows a message instead of opening a working chat.

***

{% columns %}
{% column width="83.33333333333334%" %}

<p align="right"><em>Maintained by</em> <mark style="color:green;">Abhishek Paul</mark><br><code>AI-assisted, human-approved</code></p>
{% endcolumn %}

{% column width="16.666666666666664%" %}

<div align="left"><img src="https://1326225582-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0qmgQjJ5aArDTj2ACFHG%2Fuploads%2Fgit-blob-d034645b4f8f8ee661985f5306b60ded3289653c%2Fmaintainer-abhishek-paul.png?alt=media" alt="" width="60"></div>
{% endcolumn %}
{% endcolumns %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uptiq.ai/platform/platform-resources/agent-executor/secure-access.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
