Create an online rule
const url = 'http://localhost:8080/api/v1/projects/example/online-rules';const options = { method: 'POST', headers: { cookie: 'cetra_session=<cetra_session>', 'Content-Type': 'application/json' }, body: '{"budget_period":"day","budget_usd":1,"enabled":true,"evaluator_id":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","filter":"example","name":"example","sample_rate":1,"target":"trace","variable_mapping":{"additionalProperty":"example"}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/api/v1/projects/example/online-rules \ --header 'Content-Type: application/json' \ --cookie cetra_session=<cetra_session> \ --data '{ "budget_period": "day", "budget_usd": 1, "enabled": true, "evaluator_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "filter": "example", "name": "example", "sample_rate": 1, "target": "trace", "variable_mapping": { "additionalProperty": "example" } }'Project members and above. API keys cannot call it. 403 plan_limit when the org is at its active-rule limit.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Project UUID, URL-encoded org-slug/project-slug, or current.
Request Bodyrequired
Section titled “Request Bodyrequired”POST /api/v1/projects/{project}/online-rules body. Absent optional fields take their defaults.
Optional fields refuse null (spec 09 § Conventions). Its Debug is derived: a rule holds
configuration only, no payload or secret.
object
Period of the budget. Required with budget_usd.
Budget per period, in USD. Judge evaluators only.
Whether the rule runs. Default true.
The evaluator the rule runs.
Filter over the target’s view. Absent means no filter.
Display name, 1 to 128 characters after trimming.
Share of the matching targets to evaluate, in (0, 1]. Default 1.
What the rule matches. Immutable once created.
Prompt variable to mapping expression, 1 to 32 variables.
object
Responses
Section titled “Responses”The created rule.
An online rule. Spec 09 § Evaluation & alerts.
object
Period of the budget. Present exactly when budget_usd is.
Budget per period, in USD. Omitted when the rule has none.
Creation time. JSON is RFC 3339.
User who created the rule. Omitted when that user is unknown.
Live matches dropped by the hourly cap in the current UTC hour. Counted in memory, so 0 after a restart.
Whether the rule runs.
The evaluator the rule runs. Immutable.
Filter over the target’s view. Omitted when the rule has none.
Rule id.
Jobs of the rule created in the last 24 hours, by status.
object
Finished jobs with a score.
Jobs that failed for good.
Jobs waiting to run.
Jobs running now.
Jobs left out before they ran.
Display name, 1 to 128 characters.
When the rule was paused. Omitted when it is not paused.
Detail of the pause: an error text or a fixed text. Never payload content.
Why the rule is paused. Omitted when it is not paused.
Share of the matching targets that are evaluated, in (0, 1].
Budget spend of the current period. Omitted when the rule has no budget.
object
Start of the current UTC day or month.
Estimated cost of the running jobs, in USD.
Cost of the finished jobs in the period, in USD.
What the rule matches. Immutable.
Last change time. JSON is RFC 3339.
Prompt variable to mapping expression.
object
Example
{ "budget_period": "day", "paused_reason": "budget", "target": "trace"}The request is malformed or a filter is invalid.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}No credentials, or the credentials are invalid.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}The credentials do not allow this operation, or the organization’s plan does not include it (code plan_required).
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}The resource does not exist.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}The request conflicts with the current state.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}Too many requests.
RFC 7807 problem document.
Spec 09 § Conventions.
object
Machine-readable error code.
Extra explanation. Omitted when absent.
Field errors. Omitted when empty, because RFC 7807 clients expect the member to be absent.
One field that failed validation.
Spec 09 § Conventions.
object
Request field, query parameter, or expression the error refers to.
What is wrong with the field.
Location inside the field value, for filter and SQL errors.
object
1-based column number, in characters.
1-based line number, in characters.
HTTP status code.
Short human-readable summary, the reason phrase of status.
Problem type URI. Always about:blank in this version.
Example
{ "code": "bad_request"}