Environment tags and dynamic variables
Environment tags are named pointers on a voice agent or chat agent. Each tag points at one published version of the agent, or at no version, and carries its own set of dynamic variable values. Use tags to keep track of which published version is your production or staging configuration and to keep environment-specific values, such as a transfer number, out of your prompts.
The JavaScript SDK supports these operations in @upon-ai/sdk@0.1.8.
The MCP package provides tag and detected-variable summaries, with variable
values omitted. Its optional setAgentEnvironmentTagVersion and
setChatAgentEnvironmentTagVersion tools can move or unassign an existing tag;
they preserve variables and cannot create or delete tags. Enable them explicitly
through UPONAI_MCP_WRITE_OPERATIONS, allow the workspace, and send confirm: true.
Tag rules
- Every agent has the built-in
prodandstagingtags. They cannot be removed. - An agent can have up to 10 tags, including
prodandstaging. - Tag names are lowercase, start with a letter, and contain only letters,
digits,
-, and_, with a maximum of 20 characters. - A tag can only point to a published version. Pointing a tag at a draft
returns
409. Settingversiontonullunassigns the tag. - Publishing a version does not move any tags. Move tags explicitly, either with
the tag operations below or with
environmentTagswhen you publish. - A version that a tag points to cannot be deleted. Move or unassign the tag first.
- Phone numbers remain assigned to specific agent versions. Moving a tag does not change which version a phone number uses; update number assignments separately in the dashboard.
Operations
All operations use your bearer token and require the agent's workspaceId.
Chat agents use the same requests under /api/v1/chat-agents/{agentId}/....
| Task | Voice agent | Chat agent |
|---|---|---|
| List tags | GET /api/v1/agents/{agentId}/environment-tags | GET /api/v1/chat-agents/{agentId}/environment-tags |
| Detect a version's variables | GET /api/v1/agents/{agentId}/environment-tags/detected-variables | GET /api/v1/chat-agents/{agentId}/environment-tags/detected-variables |
| Create, move, or update a tag | PUT /api/v1/agents/{agentId}/environment-tags/{tagName} | PUT /api/v1/chat-agents/{agentId}/environment-tags/{tagName} |
| Delete a custom tag | DELETE /api/v1/agents/{agentId}/environment-tags/{tagName} | DELETE /api/v1/chat-agents/{agentId}/environment-tags/{tagName} |
See the API reference for listAgentEnvironmentTags, detectAgentDynamicVariables, updateAgentEnvironmentTag, and deleteAgentEnvironmentTag for full schemas.
List tags
curl 'https://api.upon-ai.com/api/v1/agents/agent_example/environment-tags?workspaceId=123' \
-H "Authorization: Bearer $UPONAI_API_KEY"
The response contains tags and maxTags. Each tag includes name,
isDefault (true for prod and staging), version (or null), assignedAt,
and dynamicVariables.
Add includeDetectedVariables=true to also receive workingVersion (the latest
draft, or the latest version when there is no draft) and detectedVariables, a
map from version number to the variables that version references. This covers
each tagged version and the working version.
Detect the variables a version uses
Before setting values on a tag, check which dynamic variables the version expects:
curl 'https://api.upon-ai.com/api/v1/agents/agent_example/environment-tags/detected-variables?workspaceId=123&version=4' \
-H "Authorization: Bearer $UPONAI_API_KEY"
The response lists each variable name with the agent's defaultValue, or
null when there is no default. Detection covers variables referenced in the
version's prompts, messages, tools, and default dynamic variables. System
variables and values collected during the conversation are not listed.
Move a tag and set its variables
PUT points a tag at a published version, replaces its variables, or both.
Omitted fields keep their current values; send at least version,
dynamicVariables, or create.
curl -X PUT 'https://api.upon-ai.com/api/v1/agents/agent_example/environment-tags/prod' \
-H "Authorization: Bearer $UPONAI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"workspaceId":123,"version":5,"dynamicVariables":{"transfer_number":"+15550001"}}'
The response contains the updated tag and the agent's full tags list.
How tag variables behave:
dynamicVariablesreplaces the tag's whole variable map. To change one value, send the complete map you want the tag to keep.- Values must be strings.
- Tag variables override the agent's default dynamic variables. A blank value
(
"") replaces the default with an empty value. To keep the agent's default, omit the variable from the tag. - Send
"dynamicVariables": {}to clear all of a tag's variables.
To unassign a tag without deleting it, send "version": null:
curl -X PUT 'https://api.upon-ai.com/api/v1/agents/agent_example/environment-tags/staging' \
-H "Authorization: Bearer $UPONAI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"workspaceId":123,"version":null}'
Create a custom tag
Send "create": true to create a tag that does not exist yet. Without create,
an unknown tag name returns 400. A tag created without version starts
unassigned.
curl -X PUT 'https://api.upon-ai.com/api/v1/agents/agent_example/environment-tags/qa' \
-H "Authorization: Bearer $UPONAI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"workspaceId":123,"create":true,"version":5,"dynamicVariables":{"transfer_number":"+15550002"}}'
Creating a tag beyond the 10-tag limit, or with an invalid name, returns 400.
Delete a custom tag
curl -X DELETE 'https://api.upon-ai.com/api/v1/agents/agent_example/environment-tags/qa?workspaceId=123' \
-H "Authorization: Bearer $UPONAI_API_KEY"
A successful delete returns 204 and removes the tag and its variables. Deleting
prod, staging, or an unknown tag returns 400.
Move tags when publishing
The publish operations (POST /api/v1/agents/{agentId}/versions/{version}/publish
and POST /api/v1/chat-agents/{agentId}/versions/{version}/publish) accept an
optional environmentTags array. After the version is published, each listed
existing tag is pointed at it:
curl -X POST 'https://api.upon-ai.com/api/v1/agents/agent_example/versions/5/publish' \
-H "Authorization: Bearer $UPONAI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"workspaceId":123,"versionTitle":"Spring update","environmentTags":["staging"]}'
When environmentTags is sent, the response is the published agent plus
environmentTagUpdate:
{
"environmentTagUpdate": {
"moved": ["staging"],
"failed": []
}
}
The publish still succeeds if a tag cannot be moved, for example because the tag
does not exist. Check failed, where each entry has tag and error, and retry
those tags with PUT. Tags you do not list stay where they are.
Deleting versions
Deleting an agent version or chat agent version that an environment tag points
to returns 409. Move the tag to another published version, or unassign it with
"version": null, then delete the version.