[PR #12106] [CLOSED] feat - Add API key management routes for users #38479

Closed
opened 2026-04-25 11:28:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/12106
Author: @shohamyamin
Created: 3/27/2025
Status: Closed

Base: devHead: feat-add-users-api-endpoints


📝 Commits (2)

  • a38a575 Add API key management routes for users
  • 031c440 Merge branch 'dev' into feat-add-users-api-endpoints

📊 Changes

1 file changed (+76 additions, -2 deletions)

View changed files

📝 backend/open_webui/routers/users.py (+76 -2)

📄 Description

Description

This pull request introduces three new routes for managing API keys for users. These routes allow administrators to create, retrieve, and delete API keys for specific users. The changes include appropriate logging and error handling to ensure robust functionality.

Added

  • POST /{user_id}/api_key: Allows administrators to generate an API key for a user.
  • DELETE /{user_id}/api_key: Enables administrators to delete a user's API key.
  • GET /{user_id}/api_key: Provides administrators with the ability to retrieve a user's API key.

Changed

  • Added logging for API key creation, retrieval, and deletion actions.
  • Enhanced error handling for scenarios where users or API keys are not found.

Fixed

  • N/A

Security

  • Ensures only administrators can manage API keys by using Depends(get_admin_user) for route dependencies.

Additional Information

  • These changes are part of the effort to improve user management capabilities in the Open WebUI backend.
  • No new dependencies were introduced.
  • Documentation updates may be required to reflect the new API key management functionality.
  • Related discussion #12105

Screenshots or Videos

  • N/A

Pull Request Checklist

  • Target branch: This pull request targets the dev branch.
  • Description: Provided a concise description of the changes made in this pull request.
  • Changelog: Added a changelog entry following the format of Keep a Changelog.
  • Documentation: Relevant documentation updates are pending.
  • Dependencies: No new dependencies were introduced.
  • Testing: Tested the new routes for functionality and error handling.
  • Code review: Performed a self-review of the code to ensure adherence to coding standards.
  • Prefix: Prefixed the pull request title with feat to categorize it as a new feature.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/12106 **Author:** [@shohamyamin](https://github.com/shohamyamin) **Created:** 3/27/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `feat-add-users-api-endpoints` --- ### 📝 Commits (2) - [`a38a575`](https://github.com/open-webui/open-webui/commit/a38a57537df4afa1a5d2b9c7026584f1d829f2a9) Add API key management routes for users - [`031c440`](https://github.com/open-webui/open-webui/commit/031c440618029bd09bc7424993c0fb9c1ca5f941) Merge branch 'dev' into feat-add-users-api-endpoints ### 📊 Changes **1 file changed** (+76 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/routers/users.py` (+76 -2) </details> ### 📄 Description ### Description This pull request introduces three new routes for managing API keys for users. These routes allow administrators to create, retrieve, and delete API keys for specific users. The changes include appropriate logging and error handling to ensure robust functionality. ### Added - **POST /{user_id}/api_key**: Allows administrators to generate an API key for a user. - **DELETE /{user_id}/api_key**: Enables administrators to delete a user's API key. - **GET /{user_id}/api_key**: Provides administrators with the ability to retrieve a user's API key. ### Changed - Added logging for API key creation, retrieval, and deletion actions. - Enhanced error handling for scenarios where users or API keys are not found. ### Fixed - N/A ### Security - Ensures only administrators can manage API keys by using `Depends(get_admin_user)` for route dependencies. --- ### Additional Information - These changes are part of the effort to improve user management capabilities in the Open WebUI backend. - No new dependencies were introduced. - Documentation updates may be required to reflect the new API key management functionality. - Related discussion [#12105](https://github.com/open-webui/open-webui/discussions/12105) ### Screenshots or Videos - N/A --- # Pull Request Checklist - [x] **Target branch:** This pull request targets the `dev` branch. - [x] **Description:** Provided a concise description of the changes made in this pull request. - [x] **Changelog:** Added a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/). - [ ] **Documentation:** Relevant documentation updates are pending. - [x] **Dependencies:** No new dependencies were introduced. - [x] **Testing:** Tested the new routes for functionality and error handling. - [x] **Code review:** Performed a self-review of the code to ensure adherence to coding standards. - [x] **Prefix:** Prefixed the pull request title with `feat` to categorize it as a new feature. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 11:28:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#38479