import latitudesh_python_sdk
from latitudesh_python_sdk import Latitudesh
import os
with Latitudesh(
bearer=os.getenv("LATITUDESH_BEARER", ""),
) as latitudesh:
res = latitudesh.api_keys.regenerate(api_key_id="tok_x1ZJrdx5qg4LV", data={
"id": "tok_x1ZJrdx5qg4LV",
"type": latitudesh_python_sdk.UpdateAPIKeyType.API_KEYS,
"attributes": {
"name": "App Token",
},
})
# Handle response
print(res){
"data": {
"id": "tok_x1ZJrdx5qg4LV",
"type": "api_keys",
"attributes": {
"name": "App Token",
"token": "aeb7b57029087fd4449a8f0fc218d1e17b4c",
"token_last_slice": "17b4c",
"api_version": "2023-06-01",
"read_only": false,
"allowed_ips": null,
"created_at": "2026-01-14T15:56:30+00:00",
"updated_at": "2026-01-14T15:56:30+00:00",
"last_used_at": null,
"user": {
"id": "user_3J8PY3vz8ahap5nLXYmws36rwRE",
"email": "arnette@kutch.test"
}
}
},
"meta": {}
}Rotate an existing API Key, generating a new token. This invalidates the previous key. Use PATCH to update settings without rotating the token.
import latitudesh_python_sdk
from latitudesh_python_sdk import Latitudesh
import os
with Latitudesh(
bearer=os.getenv("LATITUDESH_BEARER", ""),
) as latitudesh:
res = latitudesh.api_keys.regenerate(api_key_id="tok_x1ZJrdx5qg4LV", data={
"id": "tok_x1ZJrdx5qg4LV",
"type": latitudesh_python_sdk.UpdateAPIKeyType.API_KEYS,
"attributes": {
"name": "App Token",
},
})
# Handle response
print(res){
"data": {
"id": "tok_x1ZJrdx5qg4LV",
"type": "api_keys",
"attributes": {
"name": "App Token",
"token": "aeb7b57029087fd4449a8f0fc218d1e17b4c",
"token_last_slice": "17b4c",
"api_version": "2023-06-01",
"read_only": false,
"allowed_ips": null,
"created_at": "2026-01-14T15:56:30+00:00",
"updated_at": "2026-01-14T15:56:30+00:00",
"last_used_at": null,
"user": {
"id": "user_3J8PY3vz8ahap5nLXYmws36rwRE",
"email": "arnette@kutch.test"
}
}
},
"meta": {}
}Was this page helpful?