REST API
import { Render } from "~/components";
Use the AI Search REST API to manage instances and sync jobs over HTTP.
Authentication
API paths
AI Search scopes Instance APIs to a namespace:
| Path | Description |
|---|---|
/accounts/{account_id}/ai-search/namespaces/{namespace}/instances/{id} |
Operates on instances within a namespace |
Every account has a default namespace. Use default unless you created a custom namespace. For the full specification, refer to the Namespace API reference.
Instances
Create, list, get, update, and delete AI Search instances. For the full specification, refer to the Instances API reference.
| Operation | Method | Description |
|---|---|---|
| Create | POST |
Create a new instance |
| List | GET |
List all instances |
| Get | GET |
Get an instance by ID |
| Update | PUT |
Update instance configuration |
| Delete | DELETE |
Delete an instance |
| Stats | GET |
Get indexing statistics |
Example: Create an instance
Create an instance in the default namespace:
curl -X POST "https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/ai-search/namespaces/default/instances" \
-H "Authorization: Bearer <API_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"id": "my-instance"
}'
Jobs
Trigger and monitor sync jobs that scan your data source and index new or updated content. For the full specification, refer to the Jobs API reference.
| Operation | Method | Description |
|---|---|---|
| Create | POST |
Trigger a new sync job |
| List | GET |
List all jobs for an instance |
| Get | GET |
Get job details |
| Logs | GET |
View job logs |
Example: Trigger a sync job
Start a new sync job for an instance:
curl -X POST "https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/ai-search/namespaces/default/instances/<INSTANCE_NAME>/jobs" \
-H "Authorization: Bearer <API_TOKEN>"
这篇文档对你有帮助吗?
谢谢你的反馈!