Skip to main content

Send a Message

Sending messages is simple. We have an in-built message sender to get you started quickly and test ServerlessQ. But of course you are free to use any REST client you want to use since we offer a simple REST API.

Let's have a look at the different methods of sending messages to a queue.

Sending Messages from the UI

  • Go to your queues and open on of your queues.
Create a queue
  • Click on Send a Message (top right corner) and a drawer opens on the right.

  • Fill out your desired target, method, headers, and optionally a body.

    • The target is your target HTTP API (for example your Vercel function)
    • Headers are your headers to be forwarded
    • Body is your body you want to forward. From the UI you can only use JSON so far.
    • Method is the method you want to use. The same method will be used on your target.
  • Click on Send

  • Your request will now be sent.

Example with Pokemon API ⚡️

Let's make a quick example. Follow the steps above to open the Send Message UI.

  • Enter the following API for the target: https://pokeapi.co/api/v2/pokemon/ditto

  • In target you define your target HTTP API (for example your Vercel function).

  • In our example we will use the Pokemon API.

  • We don't need any other headers except for the x-api-key which holds the API token.

  • For the method click on POST once to see that an additional body field will appear. You can enter a JSON body here.

Create a queue
  • Switch back to GET (we don't need a body)

  • The final result should look like that:

Create a queue
  • Click on Send Message and your message will be sent to your queue and forwarded to the Pokemon API.

The drawer closes automatically and you will see your message appear in the list.

Congrats 🥳! You have sent your first message to your queue.

Send Messages Programmatically

Of course you don't have to use the UI for sending messages. You can also send the messages programmatically.

It doesn't matter which way of sending the messages you use. You can do it in the programming language you want!

👆🏽 Tip: You can also generate your cURL command in the Send Message pane. If you fill out everything you can click on Export your API Call and we'll generate the cURL for you 😉

cURL

Let's send a message via the CLI tool cURL. With cURL you can simply send requests to APIs.

You define your target as the query parameter target.

Your API token needs to be included in the header x-api-key.

Our example from above looks like that:

curl \
-X GET https://api.serverlessq.com/asdjkfh-hdsjfl-234324-dsfasd?target=https://pokeapi.co/api/v2/pokemon/ditto \
-H 'Accept': 'application/json' \
-H 'x-api-key': 123'

You can copy the link to your queue with your ID included in your queue details.

This will send the exact same request as above.