Is there support for creating webhooks using Mattermost API?

Hello

We are implementing Mattermost into our Angular app but one of the things we want to provide our users with are webhooks but I do not immediately see this in the api documentation at https://api.mattermost.com/. Is this there or is it coming soon?

Overall working with the API (once the server setup was done) was not overly difficult.

Thank you.

Keith

1 Like

I am able to inject a new webhook record directly into the database but I do not see an api call to do this? Unless I am missing something?

Hi @keithg,

There are actually APIs for adding webhooks, but our documentation is incomplete at this time. It includes most of the commonly used ones, but still doesn’t contain everything used by the web app.

For incoming webhooks, there are a few routes that either require a user on the team or a team admin/system admin depending on if Integrations > Custom Integrations > Restrict managing integrations to Admins is enabled in the System console.

  • api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks/incoming/create (POST) which takes a JSON-formatted IncomingWebhook as the body and returns it with its ID field set
  • api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks/incoming/delete (POST) which takes a JSON object like {id: ID} as the body and returns its argument
  • api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks/incoming/list (GET) which returns a list of all incoming webhooks for that team

For outgoing webhooks, the routes are mostly the same with the same permissions except for an additional route to regenerate an outgoing webhook’s token

  • api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks/outgoing/create (POST) which takes a JSON-formatted OutgoingWebhook as the body and returns it with its ID field set
  • api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks/outgoing/delete (POST) which takes a JSON object like {id: ID} as the body and returns its argument
  • api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks/outgoing/list (GET) which returns a list of all outgoing webhooks for that team
  • api/v3/teams/{team_id:[A-Za-z0-9]+}/hooks/outgoing/regen_token (POST) which takes a JSON object like {id: ID} as the body and returns the webhook with its updated token field set

Awesome. Thank you.

Is there somewhere that lists all of the available api calls? Not necessarily details like in the documentation but just a list like you copied above?

The best place to look for every API call is Go client driver or our Javascript client driver as references. You might need to read the code to figure out the exact routes, but they’re usually pretty straightforward

@keithg, after you’re figured out the right APIs, would you be open to helping the open source project by making a pull request to document the ones you used? https://github.com/mattermost/mattermost-api-reference

I would be happy to help yes. It will need to wait until after Nov 9 as we have a project deadline looming.