Skip to main content

Jobs API

The Jobs API allows you to create and manage scheduled synchronization jobs that automatically sync data from source tables to knowledge bases at regular intervals.

Overview​

Jobs provide an automated way to keep your knowledge bases up-to-date by continuously syncing data from your database tables. You can configure filters, specify content columns, and set custom schedules to meet your data synchronization needs.


Create a Job​

Creates a new scheduled job to sync data from a source table to a knowledge base.

Endpoint​

POST /jobs/create

Request Body​

The request body should contain a JSON object with the following properties:

ParameterTypeRequiredDescription
job_namestring✅Unique identifier for the job
source_tablestring✅Source table in format database.table
kb_namestring✅Target knowledge base name
content_columnsarray<string>✅Columns to include in the sync
filter_columnstring✅Column used for filtering data
intervalstring✅Sync frequency (e.g., "10 MINUTES", "1 HOUR")
start_timestring✅Job start time in ISO format
end_timestring✅Job end time in ISO format

Example Request​

{
"job_name": "sync_orders",
"source_table": "orders_db.orders",
"kb_name": "orders_kb",
"content_columns": ["product", "description"],
"filter_column": "created_at",
"interval": "10 MINUTES",
"start_time": "2025-06-19T18:00:00",
"end_time": "2025-06-20T18:00:00"
}

Response​

Success Response​

Status Code: 201 Created

{
"success": true,
"message": "Job created successfully",
"data": {
"job_id": "job_12345",
"job_name": "sync_orders",
"status": "scheduled",
"created_at": "2025-06-19T12:00:00Z",
"next_run": "2025-06-19T18:00:00Z"
}
}

Error Response​

Status Code: 400 Bad Request

{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Invalid job configuration",
"details": [
"job_name is required",
"invalid interval format"
]
}
}

cURL Example​

curl -X POST "http://127.0.0.1:8000/jobs/create" \
-H "Content-Type: application/json" \
-d '{
"job_name": "sync_orders",
"source_table": "orders_db.orders",
"kb_name": "orders_kb",
"content_columns": ["product", "description"],
"filter_column": "created_at",
"interval": "10 MINUTES",
"start_time": "2025-06-19T18:00:00",
"end_time": "2025-06-20T18:00:00"
}'

Python Example​

import requests
import json

url = "http://127.0.0.1:8000/jobs/create"
payload = {
"job_name": "sync_orders",
"source_table": "orders_db.orders",
"kb_name": "orders_kb",
"content_columns": ["product", "description"],
"filter_column": "created_at",
"interval": "10 MINUTES",
"start_time": "2025-06-19T18:00:00",
"end_time": "2025-06-20T18:00:00"
}

response = requests.post(url, json=payload)
print(response.json())

JavaScript Example​

const response = await fetch('http://127.0.0.1:8000/jobs/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
job_name: 'sync_orders',
source_table: 'orders_db.orders',
kb_name: 'orders_kb',
content_columns: ['product', 'description'],
filter_column: 'created_at',
interval: '10 MINUTES',
start_time: '2025-06-19T18:00:00',
end_time: '2025-06-20T18:00:00'
})
});

const data = await response.json();
console.log(data);

Interval Formats​

The interval parameter accepts various time formats:

FormatDescriptionExample
X MINUTESEvery X minutes"5 MINUTES", "30 MINUTES"
X HOURSEvery X hours"1 HOUR", "6 HOURS"
X DAYSEvery X days"1 DAY", "7 DAYS"
HOURLYEvery hour"HOURLY"
DAILYEvery day"DAILY"
WEEKLYEvery week"WEEKLY"

Error Codes​

CodeDescription
INVALID_REQUESTRequest body validation failed
DUPLICATE_JOBJob with the same name already exists
INVALID_TABLESource table does not exist or is inaccessible
INVALID_KBKnowledge base does not exist
INVALID_INTERVALInterval format is not supported
INVALID_DATETIMEStart or end time format is invalid

Notes​

  • Job names must be unique across the system
  • The start_time and end_time should be in ISO 8601 format
  • Jobs will automatically stop running after the end_time
  • The filter_column is typically a timestamp column used to identify new or updated records
  • All specified content_columns must exist in the source table

Rate Limits​

  • Maximum of 100 active jobs per account
  • Minimum interval is 1 minute
  • Maximum job duration is 30 days