Skip to Content
🎉 New release with new features and improvements! V0.0.2 Release →

Generate API Key

Generate a new API key for programmatic access to the BSH Engine API.

POST /api/api-keys

Request Body

{ "name": "My API Key", "type": "MACHINE", "duration": 30, "description": "API key for production integration", "scopes": [ "BshUsers:read", "BshUsers:update", "BshEntities:read" ] }
PropertyTypeRequiredDescription
namestringyesA descriptive name
typePERSONAL, MACHINEnoChoose Personal or Machine type (default: PERSONAL)
durationnumberyesExpiration period in days (must be greater than 0)
descriptionstringnoAdditional notes about the key’s purpose
scopesarray of stringsyes (for MACHINE)Entity and action permissions in format EntityName:ACTION

Response

Success Response (201 Created):

{ "data": [ { "id": 123, "apiKey": "bsh_abcd1234efgh5678ijkl9012mnop3456qrst7890", "name": "My API Key", "type": "MACHINE", "status": "ACTIVE", "duration": 30, "startedAt": "2025-01-15T10:30:00Z", "expiresAt": "2025-02-14T10:30:00Z", "userId": "user-123" } ], "status": "CREATED", "code": 201, "timestamp": 1234567890, "meta": {} }
PropertyTypeDescription
idnumberUnique identifier for the API key
apiKeystringThe full API key value (only shown once during creation)
namestringThe name assigned to the API key
typestringThe type of API key (PERSONAL, MACHINE)
statusstringCurrent status of the key (ACTIVE, REVOKED, DISABLED)
durationnumberExpiration period in days
startedAtstringISO 8601 timestamp when the key was created
expiresAtstringISO 8601 timestamp when the key will expire
userIdstringID of the user who created the key

Important Notes

⚠️ Save your API key immediately! The full apiKey value is only returned once in the response. After this, the key will be masked as bsh_******** in all subsequent API calls for security purposes.

For MACHINE type keys, you must provide at least one scope. For PERSONAL type keys, scopes are not required as they inherit all user permissions.