Rules
Create Client Rule
Creates a new worker matching rule for a specific client. Rules filter which workers are eligible for this client’s events based on custom field values, credentials, and tags.
POST
/
clients
/
{id}
/
rules
Create Client Rule
curl --request POST \
--url https://api.roostedhr.com/api/1_12/clients/{id}/rules \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"field_id": 111,
"operator": "is not",
"tag_id": null,
"value": "Value"
}
'import requests
url = "https://api.roostedhr.com/api/1_12/clients/{id}/rules"
payload = {
"field_id": 111,
"operator": "is not",
"tag_id": None,
"value": "Value"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({field_id: 111, operator: 'is not', tag_id: null, value: 'Value'})
};
fetch('https://api.roostedhr.com/api/1_12/clients/{id}/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://api.roostedhr.com/api/1_12/clients/{id}/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([
'field_id' => 111,
'operator' => 'is not',
'tag_id' => null,
'value' => 'Value'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://api.roostedhr.com/api/1_12/clients/{id}/rules"
payload := strings.NewReader("{\n \"field_id\": 111,\n \"operator\": \"is not\",\n \"tag_id\": null,\n \"value\": \"Value\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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://api.roostedhr.com/api/1_12/clients/{id}/rules")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"field_id\": 111,\n \"operator\": \"is not\",\n \"tag_id\": null,\n \"value\": \"Value\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roostedhr.com/api/1_12/clients/{id}/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"field_id\": 111,\n \"operator\": \"is not\",\n \"tag_id\": null,\n \"value\": \"Value\"\n}"
response = http.request(request)
puts response.read_body{
"fields": [
{
"id": "<string>",
"field_id": "<string>",
"field_type": "<string>",
"field_name": "<string>",
"operator": "<string>",
"answers": [
{
"id": "<string>",
"display": "<string>"
}
],
"value": "<string>"
}
],
"credentials": [
{
"id": "<string>",
"credentials_id": "<string>",
"field_id": "<string>",
"field_type": "<string>",
"field_name": "<string>",
"name": "<string>",
"operator": "<string>",
"answers": [
{
"id": "<string>",
"display": "<string>"
}
],
"value": "<string>"
}
],
"has_tags": [
{
"rule_id": "<string>",
"id": "<string>",
"text": "<string>",
"operator": "<string>"
}
],
"does_not_have_tags": [
{
"rule_id": "<string>",
"id": "<string>",
"text": "<string>",
"operator": "<string>"
}
]
}Rules filter which workers are eligible for this client’s events. A rule is defined by a
field_id (referencing a worker custom field) and an operator (is, is not, etc.).
The response includes the full rule structure with resolved field names, credentials, and tags:
fields— Custom field conditions (e.g., “Facial Hair is Yes”).credentials— Credential requirements (e.g., “has Completion certificate”).has_tags— Workers must have these tags.does_not_have_tags— Workers must not have these tags.
Authorizations
Path Parameters
Client ID
Body
application/json
Rule definition. Requires field_id and operator.
Response
Created
A worker matching rule for a client, composed of field conditions, credential requirements, and tag filters.
⌘I
Create Client Rule
curl --request POST \
--url https://api.roostedhr.com/api/1_12/clients/{id}/rules \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"field_id": 111,
"operator": "is not",
"tag_id": null,
"value": "Value"
}
'import requests
url = "https://api.roostedhr.com/api/1_12/clients/{id}/rules"
payload = {
"field_id": 111,
"operator": "is not",
"tag_id": None,
"value": "Value"
}
headers = {
"X-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({field_id: 111, operator: 'is not', tag_id: null, value: 'Value'})
};
fetch('https://api.roostedhr.com/api/1_12/clients/{id}/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://api.roostedhr.com/api/1_12/clients/{id}/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([
'field_id' => 111,
'operator' => 'is not',
'tag_id' => null,
'value' => 'Value'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-KEY: <api-key>"
],
]);
$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://api.roostedhr.com/api/1_12/clients/{id}/rules"
payload := strings.NewReader("{\n \"field_id\": 111,\n \"operator\": \"is not\",\n \"tag_id\": null,\n \"value\": \"Value\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-KEY", "<api-key>")
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://api.roostedhr.com/api/1_12/clients/{id}/rules")
.header("X-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"field_id\": 111,\n \"operator\": \"is not\",\n \"tag_id\": null,\n \"value\": \"Value\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.roostedhr.com/api/1_12/clients/{id}/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"field_id\": 111,\n \"operator\": \"is not\",\n \"tag_id\": null,\n \"value\": \"Value\"\n}"
response = http.request(request)
puts response.read_body{
"fields": [
{
"id": "<string>",
"field_id": "<string>",
"field_type": "<string>",
"field_name": "<string>",
"operator": "<string>",
"answers": [
{
"id": "<string>",
"display": "<string>"
}
],
"value": "<string>"
}
],
"credentials": [
{
"id": "<string>",
"credentials_id": "<string>",
"field_id": "<string>",
"field_type": "<string>",
"field_name": "<string>",
"name": "<string>",
"operator": "<string>",
"answers": [
{
"id": "<string>",
"display": "<string>"
}
],
"value": "<string>"
}
],
"has_tags": [
{
"rule_id": "<string>",
"id": "<string>",
"text": "<string>",
"operator": "<string>"
}
],
"does_not_have_tags": [
{
"rule_id": "<string>",
"id": "<string>",
"text": "<string>",
"operator": "<string>"
}
]
}