Skip to main content
This guide covers the complete lifecycle of a violation in RES, from initial creation through escalation and delivery to brands.

What is a violation?

A violation is a record of a detected rule breach. When a detection action finds objects that match the configured criteria, and the workflow’s consolidation logic evaluates to true, a violation is created. Violation data includes:
FieldDescription
branch_rule_idThe rule that triggered the violation
started_at / ended_atWhen the violation occurred
main_attachmentVideo clip or full image URLs
sub_attachmentDetection crop or thumbnail URLs
timestampCreation time
noteAdditional context from the detection
statusCurrent status for escalation tracking

Creating violations

The create_violation action

The create_violation business action collects attachments from previous detection actions and creates violation records. It iterates through all non-business actions in the workflow, extracts their attachments, uploads them to Supabase storage, and creates violation records via the insert-violation edge function. For detailed information about the create_violation action, see the create violation documentation.

Attachment modes

By default, each detection creates a separate violation. This creates a one-to-one mapping between detections and violations.Example flow:
  • Detection 1 produces attachment 1 → Violation 1 created
  • Detection 2 produces attachment 2 → Violation 2 created
  • Detection 3 produces attachment 3 → Violation 3 created
This is useful when you want to track each detection separately for individual review.

Attachment types

The violation system supports multiple attachment formats:
TypeDescriptionExample
fileLocal file path/data/detect/abc123_detection.jpg
urlAlready-uploaded URLhttps://storage.supabase.co/...
base64Base64-encoded imageInline image data
All attachments are uploaded to Supabase storage before the violation is created, ensuring they’re accessible via public URLs.

Escalation process

Violations can be escalated to brands through multiple channels based on configuration. The escalation flow checks each configured integration and sends notifications accordingly.

Escalation flow

  1. Violation created - The create_violation action completes successfully
  2. Check brand configuration - The system checks which integrations are enabled for the brand
  3. Send notifications - Each enabled integration receives the violation data

Integration priority

When multiple integrations are configured, they execute in this order:
PriorityIntegrationPurpose
1WebhookImmediate programmatic notification to external systems
2EmailHuman-readable notification to configured recipients
3ZohoTicket creation in Zoho Desk for tracking
Each method is independent - if one fails, others still execute.

Integration methods

Webhook integration

Send violation data to an external system via HTTP POST.
Configure the webhook URL on the brand settings:
FieldDescription
webhook_urlThe endpoint URL to receive violation data
webhook_secretOptional secret for request signing

Email integration

Send violation alerts via email to configured recipients. Email contents:
  • Video or image attachment (embedded or linked)
  • Detection detail thumbnail
  • Violation timestamp
  • Rule description
  • Branch and brand information
Configuration requirements:
FieldDescription
business_action_emailRecipient email address on the brand
SMTP credentialsServer configuration for sending

Zoho integration

Create support tickets in Zoho Desk for violations, enabling brands to track and manage violations through their existing ticketing workflow.
Configure Zoho OAuth credentials on the brand:
FieldDescription
zoho.enabledMust be true to enable integration
zoho.org_idZoho organization ID
zoho.department_idTarget department for tickets
zoho.contact_idContact to associate with tickets
zoho.client_idOAuth client ID
zoho.client_secretOAuth client secret
zoho.refresh_tokenOAuth refresh token
zoho.api_regionAPI region (e.g., “sa” for Saudi Arabia)

Configuring integrations

Per-brand configuration

Each brand can have different integration settings. Configure these in the brand settings:
IntegrationRequired fields
Emailbusiness_action_email
Zohozoho.enabled, zoho.org_id, zoho.department_id, zoho.contact_id, OAuth credentials
Webhookwebhook_url, optionally webhook_secret

Testing integrations

Before deploying to production:
  1. Email - Send a test violation to verify delivery and formatting
  2. Zoho - Create a test ticket to verify OAuth and department configuration
  3. Webhook - Use a tool like webhook.site to inspect payload format

Error handling and troubleshooting

Check:
  • Did the detection action return is_success = true?
  • Did consolidation logic evaluate to true?
  • Were attachments successfully uploaded to Supabase?
Look for insert-violation calls in the logs to see the response.
Verify:
  • business_action_email is set on the brand
  • Attachment URLs are valid (not local paths)
  • SMTP credentials are correct
Common error: “No attachments found” means previous actions didn’t produce valid attachment paths.
Check:
  • zoho.enabled is true on the brand
  • OAuth tokens are valid (not expired)
  • Department ID and contact ID exist in Zoho
If getting 401 errors, the refresh token may need to be regenerated in Zoho.

Monitoring violations

Key metrics to track

MetricDescription
Violations per hourRate of violation creation
Attachment upload success ratePercentage of successful uploads
Integration delivery rateSuccess rate for each notification method
Average processing timeTime from detection to violation creation

Execution logs

Each violation creation is logged with details including:
  • Number of violations created
  • Attachment URLs
  • Integration delivery status
  • Any errors encountered
Review these logs to troubleshoot issues and monitor system health.