How to pass config data when creating an extension.

I’m trying to create Slack extensions using the API. I would like to re-use the slack access_token information (they all go to the same channel, as the same user). However that information is in the “config” section of the extension which doesn’t appear to be a parameter in the api https://v2.developer.pagerduty.com/page/api-reference#!/Extensions/post_extensions

Is there a way to do this or am I stuck with manually going to the website to finish the configuration of these extension?

Thanks,
Anthony

Hi Anthony,

Note: The config object explored below is an undocumented part of PagerDuty API, so unfortunately it is not fully supported.

You are using the correct endpoint to create extensions, but the config parameter for Slack doesn’t seem to be included in the Request Schema of the developer documentation. I’m guessing it’s because the Request Schema doesn’t include specific extension parameters.

Since you want to re-use the config information, I recommend the following:

  1. Find the extension ID of the existing Slack extension using the GET /extension endpoint, documented here.
  2. Retrieve the config object and information by using the GET /extensions/{extension-id} endpoint, documented here.
  3. Once you have the config object with the Slack information, use the POST /extensions endpoint, documented here, to create the Slack extension.

Below is an object skeleton of the config object which I used to create a Slack extension using the steps above:

"config": {
            "restrict": "any",
            "notify_types": {
                "resolve": true,
                "acknowledge": true,
                "assignments": true
            },
            "ok": true,
            "scope": "identify,bot,incoming-webhook,channels:read,groups:read,im:read,users:read,users:read.email,chat:write:bot,groups:write",
            "user_id": "<SLACK-INFO>",
            "team_name": "<SLACK-INFO>",
            "team_id": "<SLACK-INFO>",
            "incoming_webhook": {
                "channel": "#<SLACK-INFO>",
                "channel_id": "<SLACK-INFO>",
                "configuration_url": "<SLACK-INFO>",
                "url": "<SLACK-INFO>"
            },
            "bot": {
                "bot_user_id": "<SLACK-INFO>"
            },
            "access_token": "<SLACK-ACCESS-TOKEN>"
        }

This config object should be a value within the extension object.

Note that I recommend to copy and paste the config object of an already existing Slack extension to find the Slack information.

I hope this helps, but let me know if you’d benefit from receiving the full request body to create a Slack extension via the API.

Thanks,

Jay

1 Like

Jay,
I got it working with your tip, thanks!

So I got pushback at work for relying on an undocumented feature, which I can fully appreciate. Any chance of getting the “config” added as an optional param in the docs? What we don’t want is to have this be treated as a bug later and “fixed”…

Or some way to put it in through the schema?

I know each service likely will have different data in the config section so… trying to find the best way forward.

Hi Anthony,

I will certainly pass along your feedback as a feature request.

I understand that you don’t want this undocumented feature to disappear in the future, but unfortunately we can only fully support documented endpoints.

In any case, I’d added your vote to the feature request.

Let me know if you have further questions or concerns.

Thanks,

Jay