Credentials - Custom Auth with API

Describe the problem/error/question

Hello,
i want to Update Credentials with the n8n API (PATCH Request).
This is the Body:
{
“data”: {
“json”: {
“headers”: {
“Authorization”: “Bearer 1234”
}
}
}
}
The Update works fine, the data is updated in the UI. But if i want to use the Credentials i get the Error “error”: “Invalid Custom Auth JSON”.
I need to open the Credentials in the UI add for example only add an space at the End and klick Save (without any other Changes) Then the Credentials works perfectly fine.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

[
{
“error”: “Invalid Custom Auth JSON”
}
]

Information on your n8n setup

  • n8n version: 2.10.4
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Debian 13

Hey, the Custom Auth credential stores that header config as a JSON string internally, not as a nested object. So when you PATCH via the API your data field should have json as a stringified JSON value, not an actual nested object. Thats why re-saving in the UI fixes it — the UI serializes it correctly on save.

1 Like

Oh, thank you. That worked :slight_smile:

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