Delete Environment Variable
Delete Environment Variable
Delete an environment variable by its full name from the Agent associated with the API key. This API only deletes variables with an env_ prefix; it does not delete conversation properties or user properties.
Subsequent reads no longer obtain this variable’s global value. Historical messages and existing reference configurations are not rewritten automatically. To use the name again, recreate it with the upsert API.
Request Method
DELETE
Endpoint
https://api-${endpoint}.gptbots.ai/v1/env-variable/delete
Authentication
Refer to API Overview for authentication instructions. Use the current Agent’s API key; no Agent ID, organization ID, or conversation_id is required.
Request
Example Request
curl -X DELETE 'https://api-${endpoint}.gptbots.ai/v1/env-variable/delete?name=env_brand' \
-H 'Authorization: Bearer ${API Key}'
curl -X DELETE 'https://api-${endpoint}.gptbots.ai/v1/env-variable/delete?name=env_brand' \
-H 'Authorization: Bearer ${API Key}'
This code block in the floating window
Request Headers
| Field | Type | Description |
|---|---|---|
| Authorization | Bearer ${API Key} | Use Authorization: Bearer ${API Key} for authentication. Obtain the key from the Agent’s API Key page. |
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | URL query parameter: the full environment variable name, such as env_brand. Must start with env_. |
Response
Example Response
{
"code": 0,
"message": "OK"
}
{
"code": 0,
"message": "OK"
}
This code block in the floating window
Deleting a variable that does not exist returns error code
40000, rather than a success response.
Successful Response
| Field | Type | Description |
|---|---|---|
| code | int | Return code. 0 indicates success. |
| message | string | Description message, such as OK. |
Error Response
| Field | Type | Description |
|---|---|---|
| code | int | Error code. |
| message | string | Error details. |
Error Codes
| Code | Message |
|---|---|
| 40000 | Missing or empty name, a name without the env_ prefix, or a variable that does not exist. |
| 40001 | Request frequency exceeded. Retry later. |
| 40127 | Developer authentication failed. |
| 20059 | Agent has been deleted. |
