Column Specific Update Webhook Examples

I have successfully enabled a webhook to communicate with an Azure HTTP Trigger function which will run a Python script and perform other actions. This webhook only looks for row adds. I need a webhook for looking for an update to one column but don't understand the API documentation for scope and subscope.

Does anyone have success writing webhooks with subscope of updates to a column?

Best Answer

  • Brett Wyrick
    Brett Wyrick ✭✭✭✭
    Answer ✓

    Hey Dennis -

    Agreed that more examples would make things easier when using the API.

    Here's an example of a payload (HTTP POST) to create a webhook that will get updates ONLY when changes are made on particular columns (this is from the Smartsheet API documentation, which is now hosted on redoc.ly):

    URI:

    https://api.smartsheet.com/2.0/webhooks
    

    Headers:

    Content type: application/json
    Authorization: Bearer {API TOKEN}
    

    Body:

    {
        "name": "Dennis's webhook for individual columns",
        "callbackUrl": "https://www.Azure.com/webhookCallbackURL",
        "scope": "sheet",
        "scopeObjectId": {SHEETID},
        "events": [
            "*.*"
        ],
        "version": 1,
        "subscope": {
            "columnIds": [
                1234567578910123,
                1234567578910124
    
            ]
        }
    }
    


    To figure out what to put for "columnIds" above: What I always do is run a "GET Sheet" to then filter out the column's ID by searching for the column's title, then matching the applicable Column ID. For example, if I'm looking for changes on a columnID that has a title of "Status", I then run a filter action to get only the column ID with the "title" of "Status". Then I run the "Create webhook" using that columnID.

    Some limitations and things to note though, before you get going (things that I wish I would have known prior to starting my API journey):

    1. Make sure you send back an acknowledgement that the API has been received via an HTTP POST showing Status 200 (see step 3). Otherwise Smartsheet will retry 14 times to send the data over and over.
    2. You can't limit this by something like "if Status equals 'Complete'" only. It's all or nothing with the API. So you'll get "events" for when a columnID is both updated and when it is created. They each count as an "event".
    3. Changes in columns often come in batches. For example, if I have 5 rows with a "Status" column and I change 4 of them to "In Progress", then press save, Smartsheet saves each "event" in one API push to your selected callbackUrl. So rather than getting line-by-line updates, you get a bunch of updates at once that will need sorted out if you're looking for particular data.

    I hope this helps, let me know!

    If this answer answers your question, please press "Yes" above - it helps the community (and those random Googlers out there 👀) find solutions like yours faster.

    Love,

    Brett Wyrick | Connect with me on LinkedIn.

    ------------------------------------------------------------------------------

    2023 update: I'm no longer working on Smartsheet stuff. I started working at Microsoft in 2022, plus I have 1-year-old twins at home and frankly, I don't have enough time to do Smartsheet anymore. It's been real, Smartsheeters!

Answers

  • Brett Wyrick
    Brett Wyrick ✭✭✭✭

    Hey @Dennis Knipfer,

    Are you using Microsoft's Power Automate to trigger the Azure HTTP Trigger function?

    When you say "scope" and "subscope", what do you mean exactly?

    It sounds like you're wanting to set up a webhook for any time a particular column is changed. Is that right?

    If this answer answers your question, please press "Yes" above - it helps the community (and those random Googlers out there 👀) find solutions like yours faster.

    Love,

    Brett Wyrick | Connect with me on LinkedIn.

    ------------------------------------------------------------------------------

    2023 update: I'm no longer working on Smartsheet stuff. I started working at Microsoft in 2022, plus I have 1-year-old twins at home and frankly, I don't have enough time to do Smartsheet anymore. It's been real, Smartsheeters!

  • I'm not using Power Automate; I've deployed the HTTP Trigger directly to Azure using VS Code.

    Attached is the documentation for Webhook Scope & Events, found at https://smartsheet.redoc.ly/tag/webhooksDescription#section/Intro-to-Webhooks/Webhook-Scope-and-Events. I can't tell if the API does or does not support more granular changes beyond scope = "sheet" events = "*.*", which is basically just any changes. You are correct, I'd like to trigger the webhook any time a change is made to a certain column.

    For example, I have a schedule status column with options ["", "requested", "preliminary", "finalized"]. When a schedule is needed the user will request it. The webhook would flow, triggering my HTTP function on Azure. My python script would run and either build the needed schedule or not, depending on the value in the schedule status column.

    A complaint about Smartsheet's API documentation: The API doc and Github examples are really nice if you'd like to do the most basic API work. They show you the simplest coding examples while explaining in the writeup that much more can be done. How? They don't explain or show you anywhere, so you have to check with everyone else to find if they've figured it out.



  • Brett Wyrick
    Brett Wyrick ✭✭✭✭
    Answer ✓

    Hey Dennis -

    Agreed that more examples would make things easier when using the API.

    Here's an example of a payload (HTTP POST) to create a webhook that will get updates ONLY when changes are made on particular columns (this is from the Smartsheet API documentation, which is now hosted on redoc.ly):

    URI:

    https://api.smartsheet.com/2.0/webhooks
    

    Headers:

    Content type: application/json
    Authorization: Bearer {API TOKEN}
    

    Body:

    {
        "name": "Dennis's webhook for individual columns",
        "callbackUrl": "https://www.Azure.com/webhookCallbackURL",
        "scope": "sheet",
        "scopeObjectId": {SHEETID},
        "events": [
            "*.*"
        ],
        "version": 1,
        "subscope": {
            "columnIds": [
                1234567578910123,
                1234567578910124
    
            ]
        }
    }
    


    To figure out what to put for "columnIds" above: What I always do is run a "GET Sheet" to then filter out the column's ID by searching for the column's title, then matching the applicable Column ID. For example, if I'm looking for changes on a columnID that has a title of "Status", I then run a filter action to get only the column ID with the "title" of "Status". Then I run the "Create webhook" using that columnID.

    Some limitations and things to note though, before you get going (things that I wish I would have known prior to starting my API journey):

    1. Make sure you send back an acknowledgement that the API has been received via an HTTP POST showing Status 200 (see step 3). Otherwise Smartsheet will retry 14 times to send the data over and over.
    2. You can't limit this by something like "if Status equals 'Complete'" only. It's all or nothing with the API. So you'll get "events" for when a columnID is both updated and when it is created. They each count as an "event".
    3. Changes in columns often come in batches. For example, if I have 5 rows with a "Status" column and I change 4 of them to "In Progress", then press save, Smartsheet saves each "event" in one API push to your selected callbackUrl. So rather than getting line-by-line updates, you get a bunch of updates at once that will need sorted out if you're looking for particular data.

    I hope this helps, let me know!

    If this answer answers your question, please press "Yes" above - it helps the community (and those random Googlers out there 👀) find solutions like yours faster.

    Love,

    Brett Wyrick | Connect with me on LinkedIn.

    ------------------------------------------------------------------------------

    2023 update: I'm no longer working on Smartsheet stuff. I started working at Microsoft in 2022, plus I have 1-year-old twins at home and frankly, I don't have enough time to do Smartsheet anymore. It's been real, Smartsheeters!