API Keys API
API Keys API documentation for JavaScript SDK
All URIs are relative to http://localhost:8080
| Method | HTTP request | Description |
|---|---|---|
| createApiKey | POST /v1/apikeys | Create a new API key |
| deleteApiKey | DELETE /v1/apikeys/{id} | Delete an API key |
| listApiKeys | GET /v1/apikeys | List API keys |
| updateApiKey | PUT /v1/apikeys/{id} | Update an API key |
createApiKey
CreateApiKeyResponse createApiKey(createApiKeyRequest)
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
import GoodMemClient from '@pairsystems/goodmem-client';
let apiInstance = new GoodMemClient.APIKeysApi();
let createApiKeyRequest = {"labels":{"environment":"development","service":"chat-ui"},"expiresAt":"1735689600000"}; // CreateApiKeyRequest | API key configuration
apiInstance.createApiKey(createApiKeyRequest).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| createApiKeyRequest | CreateApiKeyRequest | API key configuration |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json
deleteApiKey
deleteApiKey(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
import GoodMemClient from '@pairsystems/goodmem-client';
let apiInstance = new GoodMemClient.APIKeysApi();
let id = "550e8400-e29b-41d4-a716-446655440000"; // String | The unique identifier of the API key to delete
apiInstance.deleteApiKey(id).then(() => {
console.log('API called successfully.');
}, (error) => {
console.error(error);
});Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The unique identifier of the API key to delete |
Return type
null (empty response body)
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: Not defined
listApiKeys
ListApiKeysResponse listApiKeys()
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
import GoodMemClient from '@pairsystems/goodmem-client';
let apiInstance = new GoodMemClient.APIKeysApi();
apiInstance.listApiKeys().then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});Parameters
This endpoint does not need any parameter.
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: Not defined
- Accept: application/json
updateApiKey
ApiKeyResponse updateApiKey(id, updateApiKeyRequest)
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
import GoodMemClient from '@pairsystems/goodmem-client';
let apiInstance = new GoodMemClient.APIKeysApi();
let id = "550e8400-e29b-41d4-a716-446655440000"; // String | The unique identifier of the API key to update
let updateApiKeyRequest = {"status":"ACTIVE","replaceLabels":{"environment":"production","service":"recommendation-engine"}}; // UpdateApiKeyRequest | API key update details
apiInstance.updateApiKey(id, updateApiKeyRequest).then((data) => {
console.log('API called successfully. Returned data: ' + data);
}, (error) => {
console.error(error);
});Parameters
| Name | Type | Description | Notes |
|---|---|---|---|
| id | String | The unique identifier of the API key to update | |
| updateApiKeyRequest | UpdateApiKeyRequest | API key update details |
Return type
Authorization
No authorization required
HTTP request headers
- Content-Type: application/json
- Accept: application/json