Skip to content

feat(API): Add optional projectId parameter to credential creation - #193

Open
everettbu wants to merge 9 commits into
masterfrom
feat/public-api-credential-project-id
Open

feat(API): Add optional projectId parameter to credential creation#193
everettbu wants to merge 9 commits into
masterfrom
feat/public-api-credential-project-id

Conversation

@everettbu

Copy link
Copy Markdown

Mirror of n8n-io/n8n#21039
Original author: hi120ki


Summary

Previously, credentials created via the Public API were always saved to the user's personal project.
This change adds an optional projectId parameter to the POST /credentials endpoint, allowing credentials to be created in any project where the user has credential:create permission.

The implementation follows the pattern used in the REST API credential creation endpoint.
If projectId is not provided, the credential is saved to the user's personal project, maintaining backward compatibility.

Related Linear tickets, Github issues, and Community forum posts

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

Note

Expose optional projectId in credential creation to create credentials in a specified project with permission checks, updating services, OpenAPI, and tests.

  • Public API:
    • POST /credentials now accepts optional projectId; handler forwards it to saveCredential and returns proper 403/404 on permission/not-found.
    • OpenAPI updated: request/response schemas include projectId; responses add 403 and 404.
  • Services:
    • Credential creation flows switched to ProjectService.getProjectForCredentialCreation to resolve target project and enforce credential:create permissions; removed direct repository checks.
  • Tests:
    • Added tests for saveCredential with/without projectId.
    • Added tests for ProjectService.getProjectForCredentialCreation (success, forbidden, not found, optional transaction).

Written by Cursor Bugbot for commit 512e5d4. This will update automatically on new commits. Configure here.

hi120ki and others added 9 commits October 22, 2025 17:50
Signed-off-by: Hi120ki <12624257+hi120ki@users.noreply.github.com>
Signed-off-by: Hi120ki <12624257+hi120ki@users.noreply.github.com>
Error: src/credentials/__tests__/credentials.service.test.ts(71,3): error TS2554: Expected 12 arguments, but got 13.
Signed-off-by: Hi120ki <12624257+hi120ki@users.noreply.github.com>
… is not part of the project

Signed-off-by: Hi120ki <12624257+hi120ki@users.noreply.github.com>
@everettbu everettbu added core Enhancement outside /nodes-base and /editor-ui community Authored by a community member in linear Issue or PR has been created in Linear for internal review labels Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Authored by a community member core Enhancement outside /nodes-base and /editor-ui in linear Issue or PR has been created in Linear for internal review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants