API Keys API
API Keys API documentation for Python SDK
All URIs are relative to http://localhost:8080
| Method | HTTP request | Description |
|---|---|---|
| create_api_key | POST /v1/apikeys | Create a new API key |
| delete_api_key | DELETE /v1/apikeys/{id} | Delete an API key |
| list_api_keys | GET /v1/apikeys | List API keys |
| update_api_key | PUT /v1/apikeys/{id} | Update an API key |
create_api_key
CreateApiKeyResponse create_api_key(create_api_key_request)
Create a new API key
Creates a new API key for authenticating with the API. New keys start in ACTIVE status and can be used immediately for authentication. The response includes the one-time raw API key value which will not be retrievable later - clients must save this value as it cannot be recovered. Requires CREATE_APIKEY_OWN permission (or CREATE_APIKEY_ANY for admin users). Side effects include generating cryptographically secure key material, recording creation timestamp, and tracking creator ID. Returns INVALID_ARGUMENT if expires_at is set to a time in the past.
Example
- Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.create_api_key_request import CreateApiKeyRequest
from goodmem_client.models.create_api_key_response import CreateApiKeyResponse
from goodmem_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
host = "http://localhost:8080/v1/default"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = goodmem_client.APIKeysApi(api_client)
create_api_key_request = {"labels":{"environment":"development","service":"chat-ui"},"expiresAt":"1735689600000"} # CreateApiKeyRequest | API key configuration
try:
# Create a new API key
api_response = api_instance.create_api_key(create_api_key_request)
print("The response of APIKeysApi->create_api_key:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling APIKeysApi->create_api_key: %s\n" % e)Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| create_api_key_request | CreateApiKeyRequest | API key configuration |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 201 | Successfully created API key with Location header | * Location - URL of the created API key resource |
| 400 | Invalid request - missing required fields or invalid format | - |
| 401 | Unauthorized - invalid or missing API key | - |
| 403 | Forbidden - insufficient permissions to create API keys | - |
delete_api_key
delete_api_key(id)
Delete an API key
Permanently deletes an API key. This operation cannot be undone and immediately invalidates the key for all future authentication attempts. TIP: For reversible deactivation, use PUT /v1/apikeys/{id} with status=INACTIVE instead. Requires DELETE_APIKEY_OWN permission for keys you own (or DELETE_APIKEY_ANY for admin users to delete any user's keys). Side effects include permanently removing the key record from the database and immediate authentication invalidation.
Example
- Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
host = "http://localhost:8080/v1/default"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = goodmem_client.APIKeysApi(api_client)
id = '550e8400-e29b-41d4-a716-446655440000' # str | The unique identifier of the API key to delete
try:
# Delete an API key
api_instance.delete_api_key(id)
except Exception as e:
print("Exception when calling APIKeysApi->delete_api_key: %s\n" % e)Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | str | The unique identifier of the API key to delete |
Return type
void (empty response body)
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: Not defined
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 204 | API key successfully deleted | - |
| 400 | Invalid request - API key ID in invalid format | - |
| 401 | Unauthorized - invalid or missing API key | - |
| 403 | Forbidden - insufficient permissions to delete this API key | - |
| 404 | Not found - API key with the specified ID does not exist | - |
list_api_keys
ListApiKeysResponse list_api_keys()
List API keys
Retrieves a list of API keys belonging to the authenticated user. The list includes metadata about each key but not the actual key values or key hashes for security reasons. Requires LIST_APIKEY_OWN permission (or LIST_APIKEY_ANY for admin users to view keys from any user). This is a read-only operation with no side effects.
Example
- Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.list_api_keys_response import ListApiKeysResponse
from goodmem_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
host = "http://localhost:8080/v1/default"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = goodmem_client.APIKeysApi(api_client)
try:
# List API keys
api_response = api_instance.list_api_keys()
print("The response of APIKeysApi->list_api_keys:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling APIKeysApi->list_api_keys: %s\n" % e)Parameters
This endpoint does not need any parameter.
Return type
Authorization
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successfully retrieved API keys | - |
| 401 | Unauthorized - invalid or missing API key | - |
| 403 | Forbidden - insufficient permissions to list API keys | - |
update_api_key
ApiKeyResponse update_api_key(id, update_api_key_request)
Update an API key
Updates an existing API key with new values for status or labels. IMPORTANT: Key ID, user ownership, key material, and audit fields cannot be modified - only status (ACTIVE/INACTIVE) and labels are mutable. Requires UPDATE_APIKEY_OWN permission for keys you own (or UPDATE_APIKEY_ANY for admin users to modify any user's keys). Side effects include updating the updated_at timestamp and recording the updater's user ID. This operation is idempotent - repeated identical requests have no additional effect.
Example
- Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.api_key_response import ApiKeyResponse
from goodmem_client.models.update_api_key_request import UpdateApiKeyRequest
from goodmem_client.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
host = "http://localhost:8080/v1/default"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'
# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = goodmem_client.APIKeysApi(api_client)
id = '550e8400-e29b-41d4-a716-446655440000' # str | The unique identifier of the API key to update
update_api_key_request = {"status":"ACTIVE","replaceLabels":{"environment":"production","service":"recommendation-engine"}} # UpdateApiKeyRequest | API key update details
try:
# Update an API key
api_response = api_instance.update_api_key(id, update_api_key_request)
print("The response of APIKeysApi->update_api_key:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling APIKeysApi->update_api_key: %s\n" % e)Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | str | The unique identifier of the API key to update | |
| update_api_key_request | UpdateApiKeyRequest | API key update details |
Return type
Authorization
HTTP request headers
- Content-Type: application/json
- Accept: application/json
HTTP response details
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successfully updated API key | - |
| 400 | Invalid request - ID format or update parameters invalid | - |
| 401 | Unauthorized - invalid or missing API key | - |
| 403 | Forbidden - insufficient permissions to update this API key | - |
| 404 | Not found - API key with the specified ID does not exist | - |