If your n8n http request node returns 401 when uploading animations, documents or videos to the Telegram Bot API, the fix is one of four causes: wrong token or Authorization header, using the download endpoint instead of the upload endpoint, incorrect binary handling in n8n, or manually overriding Content-Type and other headers. Fix those four and uploads will work.
Why n8n http request node returns 401
A 401 Unauthorized from Telegram usually means Telegram does not accept the credentials or the request shape. For uploads the common culprits are: you put the bot token in an Authorization header instead of in the URL, you are hitting the wrong hostname, n8n is not attaching a valid binary file, or you overrode multipart headers so Telegram cannot read the file. All produce a 401 rather than a 400 in many cases.
Step-by-step fix you can reproduce now
- Verify the token by calling a simple API method with curl or an n8n HTTP Request node:
If this returns user info, the token is correct. If it returns 401, re-copy the token, watch for leading or trailing spaces, and confirm the bot token from BotFather.curl -s -X POST "https://api.telegram.org/bot/getMe" - Check you are using the upload endpoint. For sending files you must call methods like
/bot<TOKEN>/sendDocument,/bot<TOKEN>/sendAnimationor/bot<TOKEN>/sendVideo. Do not use thehttps://api.telegram.org/file/bot<TOKEN>/...path, because that path is for file downloads and will not accept uploads. - Open the n8n node named
HTTP Requestand set these fields exactly:Method: POSTURL:https://api.telegram.org/bot<TOKEN>/sendDocument(replace method name as needed)Response Format: JSONBody Content Typeor equivalent: Form-Data (multipart)- Enable
Send Binary Dataand setBinary Propertyto the binary key from the previous node, for exampledataorfile - Add a form-data field with the exact field name Telegram expects, for example
documentfor sendDocument,animationfor sendAnimation
- Do not set or override the
Content-Typeheader manually. If you added a customAuthorizationheader, remove it. Telegram expects the token only in the URL path, not in a Bearer header, unless you intentionally configured header auth. In n8n, setAuthenticationtoNoneunless using a specific header scheme. - Test with a minimal known-good file. Use a small PDF, PNG or MP4 under a few MB to rule out large file or streaming issues. If you still get 401, enable node execution logging and inspect the request headers and form boundary that n8n created.
- If you use external binary storage (S3 or similar), confirm the binary property exists on the item and n8n actually attached the binary. An empty or missing binary property will produce malformed multipart data or no file part, which Telegram can respond to with 401 in some cases.
n8n specific node settings and header overrides
Here are the exact n8n controls to check. Open the HTTP Request node and verify the following UI fields:
- URL:
https://api.telegram.org/bot<TOKEN>/sendDocumentor the method you need. - Method:
POST. - Body Content Type: select
Form-Dataor the option that supports multipart. - Send Binary Data: checked.
- Binary Property: the name of the binary key from the previous node, for example
fileordata. - Form-Data Parameter: add a row where
Nameisdocumentoranimation, and leave the value mechanism to n8n so it attaches the binary property. - Headers: remove any custom
AuthorizationorContent-Typeentries. Let n8n set the multipart boundary header automatically.
If you must add headers, only add non-content headers such as Accept: application/json. Never add Content-Type: multipart/form-data manually because you will miss the required boundary parameter.
Quick curl test to confirm the token, outside n8n
curl -F "document=@/path/to/file.pdf" "https://api.telegram.org/bot<TOKEN>/sendDocument"
If curl works and n8n fails, the problem is how n8n is attaching binary data or headers. Re-check the Binary Property setting and the item passed to the HTTP Request node.
Common error cases and exact fixes
- Token vs header mismatch: If you used an
Authorization: Bearerheader or setAuthenticationin the node, remove it and use the token in the URL. Confirm no extra characters in the token string. - Wrong upload endpoint: Switch any
/file/botURLs to/bot<TOKEN>/sendXmethods. Upload requests must go to the API method endpoints. - Binary handling: Ensure the input item actually contains binary data. Inspect the previous node output. If you used S3 external binary storage, make sure n8n has downloaded or attached the binary before the HTTP node.
- File header mistakes: Remove manual
Content-Typeheader. Let n8n create the multipart header with correct boundary.
How to stop this happening again
- Keep a small test workflow that does a
getMecall and a smallsendDocumentusing a static test token for quick verification after changes. - Use named credentials in n8n if available, so you never paste tokens into ad hoc nodes and accidentally add headers.
- Add an execution check step before uploads that verifies
Boolean($binary)or that the binary property exists. Fail early with a clear error instead of sending a malformed request. - Document the rule in your team: token only in URL, no manual Content-Type, use
Send Binary Data.
When to get help
If you confirmed the token and curl tests work but n8n still returns 401 after adjusting the above, capture the node request and response and share them with the n8n community. The n8n forum thread where users reported this exact symptom is useful for context: see the report about HTTP Request node returns 401 when sending animation or document/video. If binary storage is involved, check the related S3 binary storage thread for symptoms that look like missing binary payloads: S3 external binary storage issues.
If you prefer one-line triage, run curl to /getMe, then curl to a simple /sendDocument with a small file. If both succeed, the issue is n8n node configuration. If curl fails, the token or bot setup is the problem.
To learn more automations and stable patterns for API uploads, join Automate Naija training and workshops. You can also read our post on keeping n8n polling triggers reliable for other production protections: N8n polling trigger stops, heartbeat and watchdog fix.
Learn to build automations like this with Automate Naija.
Frequently asked questions
Why do I get 401 from Telegram but curl works locally?
If curl succeeds but n8n returns 401, the problem is how n8n builds the HTTP request. Check that you enabled Send Binary Data , set the correct Binary Property , used the method endpoint like /bot TOKEN /sendDocument , and removed any manual Content-Type or Authorization headers.
Can I put the token in an Authorization header instead of the URL?
Telegram expects the bot token in the URL path for the standard Bot API endpoints. If you place a Bearer or Authorization header, Telegram may not accept it and you can see a 401. Use https://API.telegram.org/bot TOKEN /METHOD or follow Telegram documentation for alternative auth.
What if my file is stored in S3 or external storage?
If binary is external, ensure n8n has resolved and attached the binary to the workflow item before the HTTP Request node. An empty or missing binary property creates malformed multipart data. Check the previous node output for a valid binary key and size.
I still see 401 after following this guide, what should I share when asking for help?
Share the curl output that works or fails, the n8n HTTP Request node screenshots of settings, the outgoing request headers and body summary from execution logs, and the exact response body and status text. That lets helpers check token placement, form-data, and headers quickly.
Build it with us. The community is free and the build track teaches this kind of automation week by week: see pricing or join the community.