API Key Methods
HTTP Endpoints
- POST /keys
Creates a new API keys for the authenticated user.
The user is identified by the ‘user_id’ in the request context. Requests must include a JSON body with a “name” and “description”.
- Request Headers:
Authorization – Bearer token for user authentication
- Status Codes:
200 OK – Success. Returns the API key as a string.
400 Bad Request – Error processing request body
409 Conflict – API key with the same name already exists.
500 Internal Server Error – Unknown error occurred during processing.
Request Syntax:
{ "name": "string" "description" "string" }
Response Syntax:
"<key>"
- Raises:
May raise exceptions related to database operations.
- GET /keys
List all API keys for the authenticated user.
This endpoint retrieves all API keys associated with the authenticated user. The user is identified by the ‘user_id’ in the request context.
- Request Headers:
Authorization – Bearer token for user authentication
- Status Codes:
200 OK – Success. Returns a list of API keys.
500 Internal Server Error – Unknown error occurred during processing.
Example response:
[ { "name": "API Key Name", "description": "Key Description", "dateCreated": "2024-07-16 10:30:00", "dateExpired": "2024-08-15 10:30:00" } ]
- Raises:
May raise exceptions related to database operations.
- DELETE /keys/(key_id)
Deletes the specified API key.
The user is identified by the ‘user_id’ in the request context. Requests must include a JSON body with a “name” and “description”.
- Request Headers:
Authorization – Bearer token for user authentication
- Status Codes:
200 OK – Success.
500 Internal Server Error – Unknown error occurred during processing.
- Raises:
May raise exceptions related to database operations.