Create data source
Create a new custom JSON API data source. Optionally supply `fields` to create monitoring fields inline. Triggers an immediate fetch in the background.
POST
/data-sources
Create a new custom JSON API data source. Optionally supply `fields` to create monitoring fields inline. Triggers an immediate fetch in the background.
Authentication
Bearer Token (hu_api_key)
Request Body required
application/jsonname
string
REQUIRED
description
unknown
url
string (uri)
REQUIRED
method
string
Enum:
GET, POSTheaders
unknown
body
unknown
auth_type
unknown
auth_config
unknown
root_path
unknown
fetch_interval_s
integer
timeout_ms
integer
fields
object[]
Array of:
id
string
path
string
REQUIRED
name_template
string
REQUIRED
rule_type
string
REQUIRED
Enum:
equals, in, diff_lte, truthy, http_okrule_config
object
REQUIRED
degraded_rule_config
unknown
display_order
number
Responses
201
Data source created
application/jsondata
object
id
string
400
Validation error
402
Tier limit reached
curl -X POST 'https://happyuptime.com/api/v1/data-sources' \ -H 'Authorization: Bearer YOUR_API_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "name": "My Status API", "url": "https://api.example.com/status", "method": "GET", "fetch_interval_s": 60, "fields": [ { "path": "services.*.status", "name_template": "{{key}}", "rule_type": "equals", "rule_config": { "value": "ok" } } ]}'
const response = await fetch('https://happyuptime.com/api/v1/data-sources', { method: 'POST', headers: { "Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ "name": "My Status API", "url": "https://api.example.com/status", "method": "GET", "fetch_interval_s": 60, "fields": [ { "path": "services.*.status", "name_template": "{{key}}", "rule_type": "equals", "rule_config": { "value": "ok" } } ] })});const data = await response.json();console.log(data);
import requestsheaders = { 'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.post('https://happyuptime.com/api/v1/data-sources', headers=headers, json={ "name": "My Status API", "url": "https://api.example.com/status", "method": "GET", "fetch_interval_s": 60, "fields": [ { "path": "services.*.status", "name_template": "{{key}}", "rule_type": "equals", "rule_config": { "value": "ok" } } ]})print(response.json())
201
Response
{ "data": { "id": "<string>" }}
API Playground
Try this endpoint
POST
/data-sources