Notifications on REST API

Where are they? I can’t find any documentation on how to create a message or notification in the new REST API on my webhook SmartApp… Is it missing? :thinking:

Hi, there! Yes, it is not included in the documents yet, but you can take a look at the example in the post below, it’s a SmartApp that creates a simple notification:

Thank you!

{
  "type": "EVENT_LOGGING",
  "locationId": "<LOCATION_ID>",
  "messages": [
    {
      "en": {
        "body": "Hello world!",
        "title": "Message"
      }
    }
  ]
}

The response I get back:

{"code":"UnauthorizedError","target":null,"message":"Invalid scope","details":[]}}

What’s the required scope for Notifications? Thanks for your help.

EDIT:

I got it, I guess I’ll leave localization to another day.

{
  "type": "AUTOMATION_INFO",
  "message": "Hello World!",
  "title": "Hello",
  "locationId": <LOCATION_ID>
}

==>

{"code":2000000,"message":"SUCCESS"}

Thanks again.

1 Like

Awesome! No problem, remember to mark the post that answered your question as the Solution.
I’ll be around in case you have more questions. Thanks!

1 Like

Thanks, I am still curious about the localization capabilities of this API, since it seems to be hinted at in the SDK.

{en_us: ...},{en_uk: ...}, {default: ...}(?) ect ect seem to be valid under this, but I get an ‘Out of scope.’ Error.

1 Like

I see, let me verify more information about this configuration and I’ll you know.

1 Like

Hey, I’m back. Our engineering team has this feature under review yet, so those extra configurations aren’t available yet.
Once they make an official release, proper documentation for this function will be updated.

Hi any update on the documentation about notifications ? I can not find it yet

That feature is still a work in progress, that’s why no official documentation is available.

Have you checked the example I shared above?

thanks for the reply
no, since I’m not a developer is really hard for me to read that SDK (I tried)
I just need the URL and a json example (with all possible parameters)

the best will be to have a complete description of each parameter what is doing, how is working and possible uses cases… but at least with the parameters we can do error and trial

I have to say is really strange that a sdk exists and no documentation about this (after 1 year)

I can help a teeny bit:

The notification requires a POST to the https://api.smartthings.com/v1/notification/ endpoint with a bearer token with notification scope in the authorization header. I believe you may also have to specify the content type as being JSON. I’ve been playing with this in curl to avoid doing some ironing, and as a command line it is:

curl -X POST --header "Authorization: Bearer 12345678-1234-5678-9012-123456789012" --header "Content-Type: application/json" --data "@body.json" https://api.smartthings.com/v1/notification

A sample of a JSON body would be:

{
  "locationId": "The UUID of your location",
  "type": "AUTOMATION_INFO",
  "messages": [
    {
      "default": {
        "title": "This is the title",
        "body": "This is the body"
      }
    }
  ]
}

The type of the notification affects what the app does with it. The available types seem to be:

  • ALERT
  • SUGGESTED_ACTION
  • EVENT_LOGGING
  • AUTOMATION_INFO
  • WARNING
  • WARNING_CLEAR
  • FLASH_TOAST
  • OPTION

Only the first four of those are shown in the Core SDK, the others appear in the error message when you don’t include a type. I haven’t played with them to see what they do differently.

The default key is actually a locale code so presumably en_US etc work and allow you to specify additional versions of the message. Note also that messages is an array so you can presumably send multiple messages at once.

Hi Graham
Thanks for the example, that helps a lot!

I’ll try it right away :slight_smile:

thanks again