Override username and icon_url using posts request REST API

Hello there,
I creating a bot using REST API. I create an admin user in Mattermost with a personal token and allow overriding pictures and names in integrations.
I need to override the username and icon_url in api/v4/posts when post message using REST API.
But seems that in this case, it didn’t work.
I was spent quite a lot of time figuring out in the internet and doing requests by myself - but no luck.

I am wonder - do we have option to override username and icon_url in api/v4/posts?

Hello @taras.budzyn and sorry for the delay in replying.

I have posted a question to our engineers to confirm, but I don’t believe overriding the username and profile picture is supported via the posts API call due to privacy reasons. We don’t want users to be able to personify other members in the system.

That said, with the two settings enabled (overriding profile pictures and usernames), you can use webhooks and slash commands to create new posts with username and icon of your choice.

You may also use our plugin system, which allows you to completely override the formatting of posts, including the username and profile pictures. More on plugins here: https://developers.mattermost.com/extend/plugins/

Let me know if you have any questions

Thank you, yes - then i will use webhook for my needs.

Hey @taras.budzyn, this is in fact supported - you can include "from_webook": "true" in the props of the API call and this should work for you.

2 Likes

thanks
I already rewrite code to do it with webhook, but anyway good to know that you have this option in API :slightly_smiling_face: