GoodMem
ReferenceClient SDKsPython SDK

API Keys API

API Keys API documentation for Python SDK

All URIs are relative to http://localhost:8080

MethodHTTP requestDescription
create_api_keyPOST /v1/apikeysCreate a new API key
delete_api_keyDELETE /v1/apikeys/{id}Delete an API key
list_api_keysGET /v1/apikeysList API keys
update_api_keyPUT /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

NameTypeDescriptionNotes
create_api_key_requestCreateApiKeyRequestAPI key configuration

Return type

CreateApiKeyResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Successfully created API key with Location header* Location - URL of the created API key resource
400Invalid request - missing required fields or invalid format-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to create API keys-

↑ Back to Python SDK

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

NameTypeDescriptionNotes
idstrThe unique identifier of the API key to delete

Return type

void (empty response body)

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

HTTP response details

Status codeDescriptionResponse headers
204API key successfully deleted-
400Invalid request - API key ID in invalid format-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to delete this API key-
404Not found - API key with the specified ID does not exist-

↑ Back to Python SDK

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

ListApiKeysResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Successfully retrieved API keys-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to list API keys-

↑ Back to Python SDK

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

NameTypeDescriptionNotes
idstrThe unique identifier of the API key to update
update_api_key_requestUpdateApiKeyRequestAPI key update details

Return type

ApiKeyResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Successfully updated API key-
400Invalid request - ID format or update parameters invalid-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to update this API key-
404Not found - API key with the specified ID does not exist-

↑ Back to Python SDK