How to get a Sensor to work in RESTful POST

Hi, Im trying to get a sensor value and POST it to a simple API ive created. I have a template and a rest_command.

If I test in developer tools my api is receiving the below and not the actual value of sensor.power_up_time;

{“status_text”:“sensor.power_up_time”}

How do I get the actual value of my sensor to the API.

Any help is gratefully received!

{"status_text": states('sensor.power_up_time') }

Thanks for the reply!

service: rest_command.post_poweruptimes
data: {"status" : states('sensor.power_up_time')}

My API receives null as the data in the above case.

Here’s my Template / rest_command from my configuration.yaml

template:
  - trigger:
      - platform: event
        event_type: "imap_content"
        id: "custom_event"
        event_data:
          sender: "[email protected]"
    sensor:
      - name: "Power Up Time"
        state: '{{ trigger.event.data["subject"].split("Power-ups: Opt in to Power up for free at ")[1] }}'

rest_command:
  post_poweruptimes:
    url: http://www.xxxxx.com/powerups/
    method: POST
    payload: '{"status_text": "{{ status }}"}'
    content_type:  'application/json; charset=utf-8'

The sensor displays perfectly on my dashboard and works as expected.

The state is just a string of text like this “10:00 AM - 1:00 PM,
Sunday 28/01/24”

I have also tried other sensors the result is the same. If remove states() the JSON is received by my API just fine.

service: rest_command.post_poweruptimes
data:
  status: "{{ states('sensor.power_up_time') }}"

That worked thank you! For anyone integrating with imap watch out for hidden \r or \n in the sensors when pushed to JSON it breaks the format. I had to strip these first before POSTing.