Skip to content

Examples

Complete code examples for creating, starting, updating, and ending activities in curl, Python, Go, and JavaScript.

Info

Most examples use the generic template; the tap-actions example below uses alert. Replace hlk_YOUR_KEY with your integration key. See Live Activities for template-specific fields.

curl

Create activity
curl -X POST https://api.pushward.app/activities \
  -H "Authorization: Bearer hlk_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"slug": "my-build", "name": "My Build"}'
Start activity
curl -X PATCH https://api.pushward.app/activities/my-build \
  -H "Authorization: Bearer hlk_YOUR_KEY" \
  -H "Content-Type: application/merge-patch+json" \
  -d '{
    "state": "ongoing",
    "content": {
      "template": "generic",
      "progress": 0.0,
      "state": "Starting...",
      "icon": "arrow.triangle.branch",
      "accent_color": "cyan"
    }
  }'
Update progress
curl -X PATCH https://api.pushward.app/activities/my-build \
  -H "Authorization: Bearer hlk_YOUR_KEY" \
  -H "Content-Type: application/merge-patch+json" \
  -d '{
    "state": "ongoing",
    "content": {
      "template": "generic",
      "progress": 0.75,
      "state": "Running tests...",
      "icon": "arrow.triangle.branch",
      "accent_color": "cyan"
    }
  }'
End activity
curl -X PATCH https://api.pushward.app/activities/my-build \
  -H "Authorization: Bearer hlk_YOUR_KEY" \
  -H "Content-Type: application/merge-patch+json" \
  -d '{
    "state": "ended",
    "content": {
      "template": "generic",
      "progress": 1.0,
      "state": "Complete",
      "icon": "checkmark.circle.fill",
      "accent_color": "green"
    }
  }'

Tap actions: silent-acknowledge an alert

This example fires an alert Live Activity whose primary button silently POSTs to an acknowledgement webhook (no app launch) and whose secondary button opens the Grafana panel in Safari. See Tap actions for the full schema.

Fire an alert with tap actions
curl -X PATCH https://api.pushward.app/activities/cpu-high \
  -H "Authorization: Bearer hlk_YOUR_KEY" \
  -H "Content-Type: application/merge-patch+json" \
  -d '{
    "state": "ongoing",
    "content": {
      "template": "alert",
      "progress": 0.0,
      "state": "CPU usage is 94.2%",
      "icon": "exclamationmark.triangle.fill",
      "subtitle": "Grafana · nas-01",
      "severity": "warning",
      "accent_color": "red",
      "url_action": {
        "url": "https://hooks.example.com/grafana/ack",
        "method": "POST",
        "headers": { "Authorization": "Bearer hooks_xxx" },
        "body": "{\"alert\":\"cpu-high\",\"acked\":true}",
        "title": "Acknowledge",
        "icon": "checkmark.circle"
      },
      "secondary_url_action": {
        "url": "https://grafana.example.com/d/abc123?viewPanel=1",
        "foreground": true,
        "title": "Open panel",
        "icon": "chart.bar"
      }
    }
  }'
💡 Tip

The Acknowledge button fires the HTTP request from the widget process without launching your app — perfect for one-tap pager acknowledgements. The Open panel button opens Safari (because foreground: true) so the user can investigate.

Python

pushward.py
import requests

BASE_URL = "https://api.pushward.app"
TOKEN = "hlk_YOUR_KEY"
HEADERS = {
    "Authorization": f"Bearer {TOKEN}",
    "Content-Type": "application/json",
}

# Create activity
requests.post(f"{BASE_URL}/activities", headers=HEADERS, json={
    "slug": "my-build",
    "name": "My Build",
})

# Start activity
requests.patch(f"{BASE_URL}/activities/my-build", headers=HEADERS, json={
    "state": "ongoing",
    "content": {
        "template": "generic",
        "progress": 0.0,
        "state": "Starting...",
        "icon": "arrow.triangle.branch",
        "accent_color": "cyan",
    },
})

# Update progress
requests.patch(f"{BASE_URL}/activities/my-build", headers=HEADERS, json={
    "state": "ongoing",
    "content": {
        "template": "generic",
        "progress": 0.75,
        "state": "Running tests...",
        "icon": "arrow.triangle.branch",
        "accent_color": "cyan",
    },
})

# End activity
requests.patch(f"{BASE_URL}/activities/my-build", headers=HEADERS, json={
    "state": "ended",
    "content": {
        "template": "generic",
        "progress": 1.0,
        "state": "Complete",
        "icon": "checkmark.circle.fill",
        "accent_color": "green",
    },
})

Go

main.go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
)

const (
	baseURL = "https://api.pushward.app"
	token   = "hlk_YOUR_KEY"
)

func main() {
	// Create activity
	post("/activities", map[string]any{
		"slug": "my-build",
		"name": "My Build",
	})

	// Start activity
	patch("/activities/my-build", map[string]any{
		"state": "ongoing",
		"content": map[string]any{
			"template":     "generic",
			"progress":     0.0,
			"state":        "Starting...",
			"icon":         "arrow.triangle.branch",
			"accent_color": "cyan",
		},
	})

	// Update progress
	patch("/activities/my-build", map[string]any{
		"state": "ongoing",
		"content": map[string]any{
			"template":     "generic",
			"progress":     0.75,
			"state":        "Running tests...",
			"icon":         "arrow.triangle.branch",
			"accent_color": "cyan",
		},
	})

	// End activity
	patch("/activities/my-build", map[string]any{
		"state": "ended",
		"content": map[string]any{
			"template":     "generic",
			"progress":     1.0,
			"state":        "Complete",
			"icon":         "checkmark.circle.fill",
			"accent_color": "green",
		},
	})
}

func post(path string, body map[string]any) {
	doRequest("POST", path, body)
}

func patch(path string, body map[string]any) {
	doRequest("PATCH", path, body)
}

func doRequest(method, path string, body map[string]any) {
	data, _ := json.Marshal(body)
	req, _ := http.NewRequest(method, baseURL+path, bytes.NewReader(data))
	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", "application/json")
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
		return
	}
	defer resp.Body.Close()
	fmt.Printf("%s %s -> %d\n", method, path, resp.StatusCode)
}

JavaScript

pushward.js
const BASE_URL = "https://api.pushward.app";
const TOKEN = "hlk_YOUR_KEY";

const headers = {
  Authorization: `Bearer ${TOKEN}`,
  "Content-Type": "application/json",
};

// Create activity
await fetch(`${BASE_URL}/activities`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    slug: "my-build",
    name: "My Build",
  }),
});

// Start activity
await fetch(`${BASE_URL}/activities/my-build`, {
  method: "PATCH",
  headers,
  body: JSON.stringify({
    state: "ongoing",
    content: {
      template: "generic",
      progress: 0.0,
      state: "Starting...",
      icon: "arrow.triangle.branch",
      accent_color: "cyan",
    },
  }),
});

// Update progress
await fetch(`${BASE_URL}/activities/my-build`, {
  method: "PATCH",
  headers,
  body: JSON.stringify({
    state: "ongoing",
    content: {
      template: "generic",
      progress: 0.75,
      state: "Running tests...",
      icon: "arrow.triangle.branch",
      accent_color: "cyan",
    },
  }),
});

// End activity
await fetch(`${BASE_URL}/activities/my-build`, {
  method: "PATCH",
  headers,
  body: JSON.stringify({
    state: "ended",
    content: {
      template: "generic",
      progress: 1.0,
      state: "Complete",
      icon: "checkmark.circle.fill",
      accent_color: "green",
    },
  }),
});