Get or create API key for user
POST /api/service/users/{user_id}/orgs/{org_id}/api-keys
Get or create an API key for a user on behalf of the automations service. If a key with the given name already exists for the user/org and is not expired, returns the existing key. Otherwise, creates a new key. The created/returned keys are system keys and are: - Not visible to the user in their API keys list - Not deletable by the user - Never expire Args: user_id: The user ID org_id: The organization ID request: Request body containing name (required) x_service_api_key: Service API key header for authentication Returns: CreateUserApiKeyResponse: The API key and metadata Raises: HTTPException: 401 if service key is invalid HTTPException: 404 if user not found HTTPException: 403 if user is not a member of the specified org
Parameters
| Name | In | Type | Required | Description |
|---|
user_id | path | string | yes | — |
org_id | path | string | yes | — |
X-Service-API-Key | header | `string | null` | no |
Request body
| Field | Type | Required | Description |
|---|
name | string | yes | — |
Responses
| Status | Description |
|---|
200 | Successful Response |
422 | Validation Error |
Response body
| Field | Type | Required | Description |
|---|
key | string | yes | — |
user_id | string | yes | — |
org_id | string | yes | — |
name | string | yes | — |
Operation ID: get_or_create_api_key_for_user_api_service_users__user_id__orgs__org_id__api_keys_post