Create subscription
Create a new Pub/Sub subscription. Subscriptions receive messages published to a topic and can deliver them via pull or push mechanisms.
curl -X POST "https://api.mythic-analytics.com/api/v1/admin/pubsub/subscriptions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"name": "analytics-events-processor",
"topic": "analytics.events",
"push_endpoint": "example_string",
"ack_deadline_seconds": 42,
"max_delivery_attempts": 42,
"filter": {
"event_type": "pageview"
}
}'
import requests
import json
url = "https://api.mythic-analytics.com/api/v1/admin/pubsub/subscriptions"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
}
data = {
"name": "analytics-events-processor",
"topic": "analytics.events",
"push_endpoint": "example_string",
"ack_deadline_seconds": 42,
"max_delivery_attempts": 42,
"filter": {
"event_type": "pageview"
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.mythic-analytics.com/api/v1/admin/pubsub/subscriptions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
},
body: JSON.stringify({
"name": "analytics-events-processor",
"topic": "analytics.events",
"push_endpoint": "example_string",
"ack_deadline_seconds": 42,
"max_delivery_attempts": 42,
"filter": {
"event_type": "pageview"
}
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"name": "analytics-events-processor",
"topic": "analytics.events",
"push_endpoint": "example_string",
"ack_deadline_seconds": 42,
"max_delivery_attempts": 42,
"filter": {
"event_type": "pageview"
}
}`)
req, err := http.NewRequest("POST", "https://api.mythic-analytics.com/api/v1/admin/pubsub/subscriptions", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.mythic-analytics.com/api/v1/admin/pubsub/subscriptions')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.body = '{
"name": "analytics-events-processor",
"topic": "analytics.events",
"push_endpoint": "example_string",
"ack_deadline_seconds": 42,
"max_delivery_attempts": 42,
"filter": {
"event_type": "pageview"
}
}'
response = http.request(request)
puts response.body
{
"success": true,
"data": {
"id": "sub_5kN2mPqR",
"name": "analytics-events-processor",
"topic": "analytics.events",
"status": "active",
"push_endpoint": "example_string",
"ack_deadline_seconds": 60,
"max_delivery_attempts": 5,
"filter": {},
"created_at": "2024-04-01T10:00:00.000Z"
}
}
{
"error": "Bad Request",
"message": "The request contains invalid parameters or malformed data",
"code": 400,
"details": [
{
"field": "email",
"message": "Invalid email format"
}
]
}
{
"error": "Unauthorized",
"message": "Authentication required. Please provide a valid API token",
"code": 401
}
{
"error": "Conflict",
"message": "The request conflicts with the current state of the resource",
"code": 409,
"details": "Resource already exists"
}
/admin/pubsub/subscriptions
Admin API key as bearer token. Format: Bearer YOUR_ADMIN_KEY
Bearer YOUR_ADMIN_KEYThe media type of the request body
Unique subscription name.
Topic to subscribe to.
Optional push delivery URL. If omitted, use pull delivery.
Time in seconds to acknowledge a message before redelivery. Default 60.
Maximum delivery attempts before dead-lettering. Default 5.
Message attribute filter.
Request Preview
Response
Response will appear here after sending the request
Authentication
Bearer token. Admin API key as bearer token. Format: Bearer YOUR_ADMIN_KEY
Body
Unique subscription name.
Topic to subscribe to.
Optional push delivery URL. If omitted, use pull delivery.
Time in seconds to acknowledge a message before redelivery. Default 60.
Maximum delivery attempts before dead-lettering. Default 5.
Message attribute filter.
Responses
Last updated today