Need help for Exporting credentials in worflow

Hi Team,

Have some doubts about export credentials in the workflow.

if one workflow has two or more credentials, I need to get all credentials of the one workflow, not all workflows. How do we do that?

**CLI : **
sudo docker exec -it -u node n8n-test n8n export:credentials --id=15 --output=/xxx-xx/crdes.json

Note:
Need to export one workflow with those credentials(two or more), not all the credentials.

Thanks.

Hi @rajesh-kumar, this is a bit beyond what the n8n CLI offers at the moment I am afraid. As you can see from the docs there is no option to only export the credentials associated with a specific workflow.

So to make this work, you’d need to first export the workflow in question, then find all credential IDs and then call n8n export:credentials --id=<ID> using the identified IDs.

Yes, @MutedJam.

the same thing currently doing.

Thanks for the time.

You are most welcome! If you need to do this regularly and through a script of any kind, you could try automating the process of extracting the IDs of credentials using a tool like jq.

For example, on I could extract the IDs of the credentials used in my workflow with ID 6 using a command like this (where n8n is the name of both my container and the command, hence the duplicate):

docker exec -ti n8n n8n export:workflow --id=6 | jq -r '.[].nodes[].credentials | select( . != null ) | first(.[]).id'

This would return just the IDs:

You could also output the entire credential object by removing the part after the last pipe: