API Keys
This endpoint group provides functionality for managing API keys associated with the current user and subscription, including retrieval, creation, updating, and deletion.
Endpoints
POST /api/rpc (Method: ApiKeyRpc.getData)
Description: Retrieves API keys for the current user.
Request Body:
{ "method": "ApiKeyRpc.getData", "params": {} }Parameters:
Name Type Required Description Response:
{ "success": true, "data": { "data": [ { "_id": "string", "subscriptionId": "string", "userId": "string", "prefix": "string", "description": "string", "isEnabled": "boolean", "initialContext": "object | null", "webhookUrl": "string | null", "webhookSecret": "string | null", "webhookStatus": "string", "lastTestedAt": "string | null", "createdAt": "string", "updatedAt": "string" } ], "totalCount": "number" } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "ApiKeyRpc.getData", "params": {} }'
POST /api/rpc (Method: ApiKeyRpc.create)
Description: Creates a new API key.
Request Body:
{ "method": "ApiKeyRpc.create", "params": { "description": "string", "initialContext": "string | null" } }Parameters:
Name Type Required Description descriptionStringYes A description for the API key. Must have a minimum length of 1. initialContextStringNo An optional string representing a JSON object to be used as initial context for the API key. If provided, it must be valid JSON. Response:
{ "success": true, "data": { "_id": "string", "subscriptionId": "string", "userId": "string", "prefix": "string", "keyHash": "string", "encryptedKey": "string", "description": "string", "isEnabled": "boolean", "initialContext": "object | null", "webhookUrl": "string | null", "webhookSecret": "string | null", "webhookStatus": "string", "lastTestedAt": "string | null", "createdAt": "string", "updatedAt": "string", "fullKey": "string" } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "ApiKeyRpc.create", "params": { "description": "My New API Key", "initialContext": "{\"origin\": \"my-app\"}" } }'
POST /api/rpc (Method: ApiKeyRpc.update)
Description: Updates an API key's description and initial context.
Request Body:
{ "method": "ApiKeyRpc.update", "params": { "_id": "string", "description": "string", "initialContext": "string | null" } }Parameters:
Name Type Required Description _idStringYes The ID of the API key to update. descriptionStringNo The new description for the API key. initialContextStringNo The new initial context string for the API key. If provided, it must be valid JSON. Use nullor an empty string to clear the initial context.Response:
{ "success": true, "data": { "_id": "string", "subscriptionId": "string", "userId": "string", "prefix": "string", "description": "string", "isEnabled": "boolean", "initialContext": "object | null", "webhookUrl": "string | null", "webhookSecret": "string | null", "webhookStatus": "string", "lastTestedAt": "string | null", "createdAt": "string", "updatedAt": "string" } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "ApiKeyRpc.update", "params": { "_id": "654321098765432109876543", "description": "Updated Key Description", "initialContext": "{\"source\": \"dashboard\"}" } }'
POST /api/rpc (Method: ApiKeyRpc.delete)
Description: Deletes an API key.
Request Body:
{ "method": "ApiKeyRpc.delete", "params": { "_id": "string" } }Parameters:
Name Type Required Description _idStringYes The ID of the API key to delete. Response:
{ "success": true, "data": { "success": "boolean" } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "ApiKeyRpc.delete", "params": { "_id": "654321098765432109876543" } }'