Give each tool its own least-privilege API token
A monitoring script, an AI assistant and a BI tool each need to talk to Gluesync, but none of them needs your full access. A Personal API Token lets a tool act as you without your password, and its permission scopes decide what it may do. This guide creates one token per tool with a single scope, proves with real requests what each token refuses, limits a token to one agent, and revokes a token that is no longer needed.
In this guide
You will learn how to create a token in Settings → Account → Personal API Tokens, which scope fits which tool, what Core Hub answers when a token goes beyond its scope over the REST API and over MCP, how to limit a token to some agents, and how to revoke and delete a token.
The steps were run on Core Hub with a SQL Server to PostgreSQL pipeline. For calling the REST API and MCP with a token in an automation, see Automate Gluesync with the REST API, MCP and webhooks.
Quick information
Goal |
Give every client its own token that can do only what it needs, and take it away when it is no longer needed |
Audience |
Gluesync administrators and anyone who connects scripts, AI assistants or BI tools to Gluesync |
Level |
Beginner |
Time required |
About 20 minutes |
Area |
Control Plane → user menu → Settings → Account → Personal API Tokens |
Applies to |
Gluesync 2.3 |
Before you begin
Make sure that:
-
You can sign in to the Control Plane. A token never has more access than your role: scopes can only narrow it. See User management and role-based access control;
-
For the checks, you have
curland the address of Core Hub. Here it ishttps://localhost:18444, with a self-signed certificate, so the examples usecurl -k.
Which scope for which tool
| Tool | Scope in the Control Plane | What the token may do |
|---|---|---|
Monitoring script, report |
API read |
REST |
Automation that starts, stops or changes pipelines |
Full API |
The whole REST API, with your role’s permissions |
AI assistant that only reads |
MCP server (read-only) |
The MCP server; tools that change something are refused |
AI assistant that also changes things |
MCP server |
The MCP server with every tool. It is not read-only |
BI tool, SQL client |
JDBC gateway |
The Query Forge JDBC gateway only, always read-only |
Caller of Courier inbound routes |
HTTPS agent |
Courier inbound routes only |
Every scope, with its exact rules, is in Personal API Tokens and scopes.
Guide steps
UI
-
Open the user menu, select Settings, then Account and the tab Personal API Tokens;
-
Select New token;
-
Enter a Token name that says who uses it, here
monitoring-script; -
Choose the Expiry: 7 days, 30 days, 90 days or Never. Here 30 days;
-
Under Permission scopes, tick only API read, then select Create.
Create the other tokens the same way, each with one scope: ai-assistant with MCP server (read-only) and bi-tool with JDBC gateway, both for 90 days.
Selecting Create with no scope ticked shows Choose at least one permission scope.: every token needs at least one.
CLI
Store the address and the token in your shell, from your secret manager, then send a few requests:
GLUESYNC_URL=https://localhost:18444
GLUESYNC_TOKEN=<the monitoring-script token>
# what the token is allowed to do
curl -sk -H "Authorization: Bearer $GLUESYNC_TOKEN" "$GLUESYNC_URL/api-tokens/current-scope"
# a read: allowed
curl -sk -o /dev/null -w '%{http_code}\n' -H "Authorization: Bearer $GLUESYNC_TOKEN" "$GLUESYNC_URL/pipelines"
# a change: refused
curl -sk -X POST -H "Authorization: Bearer $GLUESYNC_TOKEN" -H 'Content-Type: application/json' \
-d '{"name":"x"}' "$GLUESYNC_URL/pipelines"
# creating a token with a token: refused, whatever the scope
curl -sk -X POST -H "Authorization: Bearer $GLUESYNC_TOKEN" -H 'Content-Type: application/json' \
-d '{"name":"x","permissionScopes":["gluesync.api"]}' "$GLUESYNC_URL/api-tokens"
The ai-assistant and bi-tool tokens cannot call the REST API at all. GET /pipelines with them answers HTTP 403 with This token’s permission scopes (gluesync.mcp_read) do not allow this request. It needs gluesync.api_read or gluesync.api., and the same with gluesync.jdbc_gateway.
CLI
Connect an MCP client to https://<core hub>/mcp/http with the ai-assistant token as Authorization: Bearer, then call a tool that reads and one that changes something. Here the calls were sent with curl: initialize, then tools/call for list_pipelines and for create_pipeline.
The list of tools that the read-only token gets also names tools that change things. The scope is enforced when a tool is called, so the AI assistant sees them but cannot run them.
To connect an AI client, see Core Hub MCP server.
CLI
A token can also be limited to some (pipeline, agent) pairs. The New token dialog does not set them: create such a token with the REST API from a signed-in session, as described in Automate Gluesync with the REST API, MCP and webhooks, or with the connection wizard of Query Forge. Here a report token was limited to the SQL Server agent of the pipeline:
{"name":"report-sqlserver-only","expiresInDays":30,"permissionScopes":["gluesync.api_read"],
"scopes":[{"pipelineId":"4c8cb118","agentId":"e07a0141"}]}
The token list shows the permission scope of such a token, not its agents: give the token a name that says what it is limited to.
UI + CLI
When a tool is retired, or a token may have leaked, revoke it:
-
In Personal API Tokens, open the menu of the token in Actions and select Revoke;
-
Read the confirmation and select Revoke.
To remove a revoked token from the list for good, select Delete in the same menu.
Keep tokens under control
-
One token per tool. Revoking one token then stops one tool, not all of them, and Last used tells you which tool is still active.
-
The narrowest scope. API read for monitoring, MCP server (read-only) for an assistant that reads, JDBC gateway for BI tools.
-
An expiry. Prefer 30 or 90 days to Never, and create a new token before the old one expires.
-
Tokens are managed from the Control Plane. No token can create, revoke or delete tokens, so a leaked token cannot make itself a broader one.
-
Replace legacy tokens. A token created before scopes existed shows Full access (legacy): create a scoped one, then revoke it. See Tokens without permission scopes.
Troubleshooting
| Problem | Possible cause | What to do |
|---|---|---|
|
No scope is ticked |
Tick the scope the tool needs |
HTTP 403: |
The token’s scope does not allow the request, for example a change with API read |
Use a token with the scope the message names, or keep the tool read-only |
HTTP 403: |
The token is for MCP or the JDBC gateway and cannot call the REST API |
Use a token with API read or Full API for REST calls |
|
An MCP client with a read-only token called a tool that changes something |
Use a token with MCP server if the assistant must change things |
HTTP 403: |
A token was used to manage tokens |
Manage tokens from the Control Plane, or from a signed-in session |
HTTP 403: |
The token has agent scopes that do not include this agent |
Create a token whose agent scopes include it |
HTTP 401: |
The token was revoked, deleted, has expired, or is mistyped |
Check its Status in Personal API Tokens, and create a new token if needed |
I’ve copied it, close stays disabled |
The token has not been copied |
Select Copy first |