Credentials update using api

I have a flow in n8n that pulls from GitLab using an API token, set up as a Predefined Credential. The token is renewed weekly, so I need to update it in n8n’s credentials.

The issue is that there’s no option to simply update the credentials using an API call; I can only create or delete them.

I tried deleting the credential and re-creating it with the exact same name. However, my scheduled flow then gives this error:

Credential with ID "L7Vr2RxKSfIEYL1o" does not exist for type "gitlabApi".

Does anyone know of a workaround or a better way to handle this issue?

credentials rely on ids, not names. if you recreate the credential, you need to also update all workflow which are using it to point to the new id of the freshly created credential.

There is no point in using API for credentials if we can’t update. It’s a blocker for automation, which is the main purpose of n8n.

Is there an option to update workflows with API to use the new credentials?

There is an update workflow endpoint

which can be used to update the workflow.

What you would need to implement is find workflows which use certain credential, get the workflow object, update the credential ref:

2 Likes

Even though this will work, it is a hassle to loop over all the workflows to see which all workflows use old credentials and update the new “id” in that workflow.

Updating the credentials should be made available. Don’t understand why “update credentials” is not possible with API but possible with webUI.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.