Publish

POST {{BASE_URL}}/topics/:cacheName/:topicName

Oh hello.

Good to see you here. You're about to publish a message to a topic in Momento, that's pretty neat!

Let's walk through how this request works really quick.

Parameters

Like all APIs (ok, most APIs) you need an API key or auth token before sending a request. The easiest way to do that is to click in the address bar then hitting the Setup new authorization button that appears. Qodex will then guide you through getting an API key over here. Pretty slick.

You also need to configure the cacheName and topicName variables in the collection. So click on the collection, head over to the Variables tab, and fill in the values. The cacheName variable needs to be an existing cache in the same region your API token is from, kinda makes sense.

The topicName variable can be anything you want. That's one of the best things about Momento Topics - no resource management!

The base_url property is set automatically via the collection pre-request script. It will decode your API token and set the base url appropriate for the region you are using.

What to send

You can send whatever you want via a topic. Many use cases will publish a stringified JSON object to subscribers, so we set that up for you. If you'd like, you can create your own JSON object in the pre-request script of this request and it will be stringified and passed to the request automatically.

If you'd rather do your own thing - no problem! Go to the Body tab and type in whatever you want. You could even send in binary data if you wanted to.

Did it work?

Did you do it? Did you publish a message? If you're unsure if the request worked, we understand. We have included some tests that validate you received a 204 No Content status code on success, but you're probably wondering how you can tell that something actually happened.

We got you.

You can head to the Topics dashboard in our console to get that validation.

Select the matching region (the one from your API key), cache, and topic name from this request and hit the Subscribe button.

NOW go ahead and run this request again. Did you see your message come through in the dashboard? Pretty sweet, right?

Time to build

Ok, now that we're all squared away it's time to go build. If you have any questions, feel free to reach out to the Momento team on Discord - we're a pretty fun bunch.

Anyway, hope you had fun and see you later!