Skip to main content
POST
/
api
/
v1
/
rules
Create a new campaign contact rule
curl --request POST \
  --url https://{subdomain}.mihu.ai/api/v1/rules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Aggressive call rule",
  "type": "call",
  "max_calls_per_day": 3,
  "max_total_calls": 10,
  "retry_interval_minutes": 120,
  "start_time": "09:00",
  "end_time": "18:00",
  "dnc_check": true,
  "remove_on_opt_out": true,
  "escalation_after_failed_attempts": 0,
  "escalation_type": "<string>",
  "escalation_target": "<string>"
}
'
import requests

url = "https://{subdomain}.mihu.ai/api/v1/rules"

payload = {
"name": "Aggressive call rule",
"type": "call",
"max_calls_per_day": 3,
"max_total_calls": 10,
"retry_interval_minutes": 120,
"start_time": "09:00",
"end_time": "18:00",
"dnc_check": True,
"remove_on_opt_out": True,
"escalation_after_failed_attempts": 0,
"escalation_type": "<string>",
"escalation_target": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Aggressive call rule',
type: 'call',
max_calls_per_day: 3,
max_total_calls: 10,
retry_interval_minutes: 120,
start_time: '09:00',
end_time: '18:00',
dnc_check: true,
remove_on_opt_out: true,
escalation_after_failed_attempts: 0,
escalation_type: '<string>',
escalation_target: '<string>'
})
};

fetch('https://{subdomain}.mihu.ai/api/v1/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{subdomain}.mihu.ai/api/v1/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Aggressive call rule',
'type' => 'call',
'max_calls_per_day' => 3,
'max_total_calls' => 10,
'retry_interval_minutes' => 120,
'start_time' => '09:00',
'end_time' => '18:00',
'dnc_check' => true,
'remove_on_opt_out' => true,
'escalation_after_failed_attempts' => 0,
'escalation_type' => '<string>',
'escalation_target' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://{subdomain}.mihu.ai/api/v1/rules"

payload := strings.NewReader("{\n \"name\": \"Aggressive call rule\",\n \"type\": \"call\",\n \"max_calls_per_day\": 3,\n \"max_total_calls\": 10,\n \"retry_interval_minutes\": 120,\n \"start_time\": \"09:00\",\n \"end_time\": \"18:00\",\n \"dnc_check\": true,\n \"remove_on_opt_out\": true,\n \"escalation_after_failed_attempts\": 0,\n \"escalation_type\": \"<string>\",\n \"escalation_target\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://{subdomain}.mihu.ai/api/v1/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Aggressive call rule\",\n \"type\": \"call\",\n \"max_calls_per_day\": 3,\n \"max_total_calls\": 10,\n \"retry_interval_minutes\": 120,\n \"start_time\": \"09:00\",\n \"end_time\": \"18:00\",\n \"dnc_check\": true,\n \"remove_on_opt_out\": true,\n \"escalation_after_failed_attempts\": 0,\n \"escalation_type\": \"<string>\",\n \"escalation_target\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{subdomain}.mihu.ai/api/v1/rules")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Aggressive call rule\",\n \"type\": \"call\",\n \"max_calls_per_day\": 3,\n \"max_total_calls\": 10,\n \"retry_interval_minutes\": 120,\n \"start_time\": \"09:00\",\n \"end_time\": \"18:00\",\n \"dnc_check\": true,\n \"remove_on_opt_out\": true,\n \"escalation_after_failed_attempts\": 0,\n \"escalation_type\": \"<string>\",\n \"escalation_target\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "message": "Rule created successfully",
  "data": {
    "uuid": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "name": "Aggressive call rule",
    "max_calls_per_day": 3,
    "max_total_calls": 10,
    "retry_interval_minutes": 120,
    "start_time": "09:00:00",
    "end_time": "18:00:00",
    "dnc_check": true,
    "remove_on_opt_out": true,
    "escalation_after_failed_attempts": 0,
    "escalation_type": "<string>",
    "escalation_target": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  }
}

Authorizations

Authorization
string
header
required

Use a Bearer token to access these API endpoints. Example: "Bearer {your-token}"

Body

application/json
name
string
required

Human-readable label for the rule. 3-255 characters. Not required to be unique.

Required string length: 3 - 255
Example:

"Aggressive call rule"

type
enum<string>

Determines task scheduling behavior. 'call' rules honor retry interval and working-hours window. 'text' rules are forced to one-shot semantics: max_total_calls and max_calls_per_day are coerced to 1, and retry_interval_minutes / end_time / escalation_* are nulled. Default: 'call'.

Available options:
call,
text
Example:

"call"

max_calls_per_day
integer

Maximum number of attempts to the same contact per calendar day, evaluated in the contact's local timezone. Ignored when type='text' (forced to 1). Default: 3 for call, 1 for text.

Required range: x >= 1
Example:

3

max_total_calls
integer

Hard cap on total attempts to the same contact across the campaign's full date range. Once reached, no further tasks are scheduled for that contact. Default: 10 for call, 1 for text.

Required range: x >= 1
Example:

10

retry_interval_minutes
integer | null

Minimum minutes between successive attempts to the same contact. Honored only for type='call'. Null for type='text'. Default: 120.

Required range: x >= 1
Example:

120

start_time
string

Earliest allowed local time of day (HH:MM, 24h) the system may attempt to reach a contact. Interpreted in the contact's local timezone, not server time. Default: '09:00'.

Example:

"09:00"

end_time
string | null

Latest allowed local time of day (HH:MM, 24h). Honored only for type='call'. Null for type='text'. Default: '18:00'.

Example:

"18:00"

dnc_check
boolean

When true, contacts on the Do Not Call list are skipped at task-creation time. Default: true.

Example:

true

remove_on_opt_out
boolean

When true, an inbound opt-out (STOP keyword, unsubscribe webhook) automatically removes the contact from active pool items. Default: true.

Example:

true

escalation_after_failed_attempts
integer | null

Trigger threshold for escalation_type. After this many consecutive failed attempts on a contact, the escalation hook fires. 0 disables escalation. Default: 0.

Required range: x >= 0
Example:

0

escalation_type
string | null

Free-form identifier consumed by your downstream escalation logic. Common values: 'notify_manager', 'reassign_to_human', 'mark_failed'. Null disables.

Maximum string length: 255
escalation_target
string | null

Free-form payload paired with escalation_type — typically a manager email, a team UUID, or human-readable instructions. Interpretation is up to your handler.

Response

Rule created.

success
boolean
Example:

true

message
string
Example:

"Rule created successfully"

data
object

Campaign contact rule. Drives task cadence, retry interval, working-hours window, and escalation policy when attached to a campaign.