Can't send post request to create a device event

Hello,
I am trying to post an event to a Door sensor device using API.
My access token has all the permissions and I can successfully use the API for other endpoints.
My device is a “Simulated Contact Sensor”. I also tried with a “Contact Sensor Capability” device.

Following this post, I tried the following body:

{
  "deviceEvents": [
    {
      "component": "main",
      "capability": "contactSensor",
      "attribute": "contact",
      "value": "open"
    }
  ]
}

However, I get everytime an error 403 Unhautorized and I can’t send the event.
Did I miss something somwhere?
Thanks a lot for your help,

One of the ways a device can be integrated is by using a SmartApp and that post is in that context. It is how the SmartApp sets the device status.

I suspect that you want to execute a command on a device.

Thanks.
But I am working with a sensor, and we can’t/execute a command on a sensor (link).
If I understood correctly, this should be done using events. Am I correct?

Historically device type handlers included custom commands. The modern approach is custom capabilities.

I have only seen deviceEvents used in two circumstances. One is with devices of type APP where the device integration is an app and the deviceEvents call is the equivalent of a createEvent/sendEvent in a DTH or emitting events in an Edge driver, that is to say it originates internally to the integration.

The other is with devices of type VIRTUAL, which haven’t really been introduced to us yet, where the deviceEvents can indeed be used in the way you describe, that is originating externally to the device integration.

It’s never really occurred to me that you might be able to do it more generally.

Let’s tag @nayelyz here as she might be able to clarify things.

Welcome to the SmartThings Community, @tiger223_tiger223!

@orangebucket is right, those events are for devices managed by a SmartApp Connector, this means an Access token that doesn’t belong to the SmartApp that controls the device can’t send this type of event.
Also, as this capability doesn’t have a command we can use, the device integration should handle the generation of the events.

Did you create the “Simulated Contact Sensor” through the IDE?
There are other ways to create a virtual device where you would have control over the events:

Also, the complete info about virtual devices hasn’t been provided by the team as Graham mentioned, but, the ST CLI has some commands available to create and send events to virtual devices, I just made a test for a contact sensor and it worked:

--create
smartthings virtualdevices:create-standard -N contact-test

--send event
smartthings virtualdevices:events deviceId contactSensor:contact open