curl --request POST \
--url https://eu.phrase.com/styleguide/api/v1/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"rule": "Avoid passive voice in all user-facing content.",
"allContentGroups": false,
"contentGroupIds": [
"<string>"
],
"allLanguages": false,
"languages": [
"<string>"
],
"active": true,
"aiCheckEnabled": true
}
'import requests
url = "https://eu.phrase.com/styleguide/api/v1/rules"
payload = {
"rule": "Avoid passive voice in all user-facing content.",
"allContentGroups": False,
"contentGroupIds": ["<string>"],
"allLanguages": False,
"languages": ["<string>"],
"active": True,
"aiCheckEnabled": True
}
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({
rule: 'Avoid passive voice in all user-facing content.',
allContentGroups: false,
contentGroupIds: ['<string>'],
allLanguages: false,
languages: ['<string>'],
active: true,
aiCheckEnabled: true
})
};
fetch('https://eu.phrase.com/styleguide/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://eu.phrase.com/styleguide/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([
'rule' => 'Avoid passive voice in all user-facing content.',
'allContentGroups' => false,
'contentGroupIds' => [
'<string>'
],
'allLanguages' => false,
'languages' => [
'<string>'
],
'active' => true,
'aiCheckEnabled' => true
]),
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://eu.phrase.com/styleguide/api/v1/rules"
payload := strings.NewReader("{\n \"rule\": \"Avoid passive voice in all user-facing content.\",\n \"allContentGroups\": false,\n \"contentGroupIds\": [\n \"<string>\"\n ],\n \"allLanguages\": false,\n \"languages\": [\n \"<string>\"\n ],\n \"active\": true,\n \"aiCheckEnabled\": true\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://eu.phrase.com/styleguide/api/v1/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rule\": \"Avoid passive voice in all user-facing content.\",\n \"allContentGroups\": false,\n \"contentGroupIds\": [\n \"<string>\"\n ],\n \"allLanguages\": false,\n \"languages\": [\n \"<string>\"\n ],\n \"active\": true,\n \"aiCheckEnabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://eu.phrase.com/styleguide/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 \"rule\": \"Avoid passive voice in all user-facing content.\",\n \"allContentGroups\": false,\n \"contentGroupIds\": [\n \"<string>\"\n ],\n \"allLanguages\": false,\n \"languages\": [\n \"<string>\"\n ],\n \"active\": true,\n \"aiCheckEnabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "01900000-0000-7000-8000-000000000001",
"rule": "Avoid passive voice in all user-facing content.",
"active": true,
"aiCheckEnabled": true,
"critical": true,
"allContentGroups": true,
"allLanguages": true,
"contentGroups": [
{
"id": "cg-marketing-en"
}
],
"languages": [
{
"bcpCode": "en-GB",
"description": "English (United Kingdom)",
"language": "cs",
"region": "gb",
"script": "LATN"
}
],
"createdAt": "2024-01-15T10:30:00Z",
"lastModifiedAt": "2024-06-01T14:22:00Z",
"name": "No passive voice",
"omittedReason": "<string>",
"eligibilityCheckedAt": "2024-06-01T14:22:05Z",
"styleGuide": null,
"createdBy": null,
"lastModifiedBy": null
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}Create a Rule
Creates a Rule for the authenticated organization.
Active-rule and AI-check limits
Each organization has a limit on active rules and on active, AI-check-enabled rules per
(Content Group, Language) pair. Whether the created rule counts against those limits — and
whether an over-limit request fails or is silently adjusted — depends on whether active /
aiCheckEnabled were explicitly set in the request:
active in request | Active-rule limit reached for scope? | Result |
|---|---|---|
true (explicit) | No | Created active |
true (explicit) | Yes | 409 RULE_ACTIVE_LIMIT_REACHED |
false (explicit) | — | Created inactive |
| omitted | No | Auto-decided: created active |
| omitted | Yes | Auto-decided: created inactive (no error) |
aiCheckEnabled in request | Resulting active | AI-check limit reached for scope? | Result |
|---|---|---|---|
true (explicit) | false | — | 400 INVALID_ARGUMENT (AI-check requires an active rule) |
true (explicit) | true | No | Created with AI-check enabled |
true (explicit) | true | Yes | 409 RULE_AI_CHECK_LIMIT_REACHED |
false (explicit) | any | — | Created with AI-check disabled |
| omitted | false | — | AI-check disabled (no auto-enable) |
| omitted | true | No | Auto-decided: AI-check enabled |
| omitted | true | Yes | Auto-decided: AI-check disabled (no error) |
The active-rule limit is checked before the AI-check limit, so an explicit active=true
that is already over the active-rule limit fails without evaluating the AI-check limit at all.
The “All Groups” system content group
Passing the organization’s Control Hub “All Groups” system content group ID as the sole entry
in contentGroupIds is equivalent to setting allContentGroups=true — the rule is created
with allContentGroups=true and an empty contentGroupIds, the same as if the system content
group ID had never been mentioned. Combining the system content group ID with any other
content group ID in the same request is rejected with 400 INVALID_ARGUMENT.
Activation lock
Limit checks are performed under a per-organization activation lock to prevent race
conditions between concurrent create/update requests. If the lock cannot be acquired,
the request fails with 503 RULE_ACTIVATION_LOCK_UNAVAILABLE — retry the request.
curl --request POST \
--url https://eu.phrase.com/styleguide/api/v1/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"rule": "Avoid passive voice in all user-facing content.",
"allContentGroups": false,
"contentGroupIds": [
"<string>"
],
"allLanguages": false,
"languages": [
"<string>"
],
"active": true,
"aiCheckEnabled": true
}
'import requests
url = "https://eu.phrase.com/styleguide/api/v1/rules"
payload = {
"rule": "Avoid passive voice in all user-facing content.",
"allContentGroups": False,
"contentGroupIds": ["<string>"],
"allLanguages": False,
"languages": ["<string>"],
"active": True,
"aiCheckEnabled": True
}
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({
rule: 'Avoid passive voice in all user-facing content.',
allContentGroups: false,
contentGroupIds: ['<string>'],
allLanguages: false,
languages: ['<string>'],
active: true,
aiCheckEnabled: true
})
};
fetch('https://eu.phrase.com/styleguide/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://eu.phrase.com/styleguide/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([
'rule' => 'Avoid passive voice in all user-facing content.',
'allContentGroups' => false,
'contentGroupIds' => [
'<string>'
],
'allLanguages' => false,
'languages' => [
'<string>'
],
'active' => true,
'aiCheckEnabled' => true
]),
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://eu.phrase.com/styleguide/api/v1/rules"
payload := strings.NewReader("{\n \"rule\": \"Avoid passive voice in all user-facing content.\",\n \"allContentGroups\": false,\n \"contentGroupIds\": [\n \"<string>\"\n ],\n \"allLanguages\": false,\n \"languages\": [\n \"<string>\"\n ],\n \"active\": true,\n \"aiCheckEnabled\": true\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://eu.phrase.com/styleguide/api/v1/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rule\": \"Avoid passive voice in all user-facing content.\",\n \"allContentGroups\": false,\n \"contentGroupIds\": [\n \"<string>\"\n ],\n \"allLanguages\": false,\n \"languages\": [\n \"<string>\"\n ],\n \"active\": true,\n \"aiCheckEnabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://eu.phrase.com/styleguide/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 \"rule\": \"Avoid passive voice in all user-facing content.\",\n \"allContentGroups\": false,\n \"contentGroupIds\": [\n \"<string>\"\n ],\n \"allLanguages\": false,\n \"languages\": [\n \"<string>\"\n ],\n \"active\": true,\n \"aiCheckEnabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "01900000-0000-7000-8000-000000000001",
"rule": "Avoid passive voice in all user-facing content.",
"active": true,
"aiCheckEnabled": true,
"critical": true,
"allContentGroups": true,
"allLanguages": true,
"contentGroups": [
{
"id": "cg-marketing-en"
}
],
"languages": [
{
"bcpCode": "en-GB",
"description": "English (United Kingdom)",
"language": "cs",
"region": "gb",
"script": "LATN"
}
],
"createdAt": "2024-01-15T10:30:00Z",
"lastModifiedAt": "2024-06-01T14:22:00Z",
"name": "No passive voice",
"omittedReason": "<string>",
"eligibilityCheckedAt": "2024-06-01T14:22:05Z",
"styleGuide": null,
"createdBy": null,
"lastModifiedBy": null
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}{
"code": "<string>",
"message": "<string>",
"detail": "<string>"
}Body
Request to create a new Rule
Language codes this rule applies to (e.g., en, en-GB). Equivalent representations such as en_US are accepted and normalised to canonical BCP-47 (en-US). Must be non-empty when allLanguages is false. Must be absent or empty when allLanguages is true.
1001Response
Rule created successfully
Rule details
When the automated AI-check eligibility check last completed for this rule. Null means it hasn't run yet: eligibility is still pending, so a client should treat the AI-check state as 'checking' rather than eligible. Once set, a null omittedReason means eligible and a non-null omittedReason means omitted.
"2024-06-01T14:22:05Z"
Was this page helpful?