Skip to content

Latest commit

 

History

History
70 lines (58 loc) · 1.84 KB

topic-endpoint.mdx

File metadata and controls

70 lines (58 loc) · 1.84 KB
title
Create Topics and Endpoints

QStash allows you to group multiple APIs together into a single namespace, called a topic. Read more about topics here.

There are two ways to create endpoints and topics: The UI and the REST API.

UI

Go to console.upstash.com/qstash and click on the Topics tab. Afterwards you can create a new topic by giving it a name. Keep in mind that topic names are restricted to alphanumeric, underscore, hyphen and dot characters.

After creating the topic, you can add endpoints to it:

API

You can create a topic and endpoint using the console or REST API.

```bash cURL curl -XPOST https://qstash.upstash.io/v2/topics/:topicName/endpoints \ -H "Authorization: Bearer " \ -H "Content-Type: application/json" \ -d '{ "endpoints": [ { "name": "endpoint1", "url": "https://example.com" }, { "name": "endpoint2", "url": "https://somewhere-else.com" } ] }' ``` ```typescript Typescript import { Client } from "@upstash/qstash";

const client = new Client({ token: "<QSTASH_TOKEN>" }); const topics = client.topics(); await topics.addEndpoints({ name: "topicName", endpoints: [ { name: "endpoint1", url: "https://example.com" }, { name: "endpoint2", url: "https://somewhere-else.com" }, ], });

```python Python
from upstash_qstash import QStash

qstash = QStash("<QSTASH_TOKEN>")
qstash.url_group.upsert_endpoints(
    url_group="url-group-name",
    endpoints=[
        {"name": "endpoint1", "url": "https://example.com"},
        {"name": "endpoint2", "url": "https://somewhere-else.com"},
    ],
)