Skip to main content
POST
/
v0
/
sourceRules
Create Rule
curl --request POST \
  --url https://api.paygentic.io/v0/sourceRules \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "conditions": [
    {
      "operator": "equals",
      "type": "date",
      "value": "<string>"
    }
  ],
  "description": "<string>",
  "enabled": true,
  "name": "<string>",
  "order": 0,
  "sourceId": "<string>"
}'
{
  "id": "rule_789012",
  "conditions": [
    {
      "operator": "lessThan",
      "type": "amount",
      "value": 100
    }
  ],
  "createdAt": "2024-03-05T12:00:00Z",
  "createdBy": "usr_merchant",
  "description": "Automatically approve events with amount less than $100",
  "enabled": true,
  "evaluationCount": 0,
  "lastEvaluatedAt": null,
  "matchCount": 0,
  "name": "Auto-approve small amounts",
  "order": 1,
  "sourceId": "src_x3y4z5a6b7c8d9e0",
  "updatedAt": "2024-03-05T12:00:00Z"
}

Authorizations

Authorization
string
header
required

API key authentication

Body

application/json
conditions
object[]
required

Conditions that must ALL be met (AND logic) for auto-acceptance. Sample values: customerEmail domain='@trusted.com' AND amount lessThan=1000, customerId equals='org_abc123' AND billableMetricId equals='bm_tokens', subscriptionId equals='sub_xyz789' AND quantity greaterThan=100

Required array length: 1 - 10 elements
name
string
required

Human-readable name for the source rule

sourceId
string
required

Unique identifier for a source

description
string

Detailed description of what this source rule does

enabled
boolean
default:true

Whether this rule should be active immediately

order
integer
default:0

Evaluation priority (0-999). Lower numbers are evaluated first. First matching rule triggers auto-acceptance.

Required range: x >= 0

Response

Rule created

An auto-acceptance rule that automatically approves source events matching specified conditions. Rules help automate the approval process for trusted customers or specific transaction patterns.

id
string

Unique identifier for the rule

conditions
object[]

List of conditions that must ALL be met (AND logic)

createdAt
string<date-time>

When the rule was created

createdBy
string | null

User ID who created the rule

description
string

Detailed description of what this source rule does

enabled
boolean

Whether this rule is currently active

evaluationCount
integer

Total number of times this rule has been evaluated

lastEvaluatedAt
string<date-time> | null

Last time this rule was evaluated against an invoice

matchCount
integer

Number of times this rule has matched and auto-accepted an invoice

name
string

Human-readable name for the source rule

order
integer

Priority order for rule evaluation (lower numbers are evaluated first)

sourceId
string

ID of the source this rule belongs to

updatedAt
string<date-time>

When the rule was last updated