POST
/
v1
/
search
curl --location --request POST 'https://api.stateset.com/v1/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token <token>' \
--data-raw '{
    "query": "john doe refund",
    "resources": ["orders", "customers", "returns"],
    "filters": {
        "date_range": {
            "field": "created_at",
            "from": "2024-01-01",
            "to": "2024-12-31"
        },
        "status": ["active", "pending"]
    },
    "facets": ["resource_type", "status", "tags"],
    "sort": {
        "field": "created_at",
        "order": "desc"
    },
    "pagination": {
        "page": 1,
        "per_page": 20
    },
    "highlight": true,
    "suggest": true
}'
{
  "results": [
    {
      "id": "ord_123abc",
      "resource_type": "order",
      "score": 0.95,
      "data": {
        "id": "ord_123abc",
        "customer_name": "John Doe",
        "total": 299.99,
        "status": "pending",
        "created_at": "2024-03-15T10:30:00Z"
      },
      "highlights": {
        "customer_name": "<em>John Doe</em>",
        "notes": "Customer requested <em>refund</em> for damaged item"
      }
    },
    {
      "id": "cust_456def",
      "resource_type": "customer",
      "score": 0.88,
      "data": {
        "id": "cust_456def",
        "name": "John Doe",
        "email": "john.doe@example.com",
        "status": "active"
      },
      "highlights": {
        "name": "<em>John Doe</em>"
      }
    }
  ],
  "facets": {
    "resource_type": {
      "order": 5,
      "customer": 3,
      "return": 2
    },
    "status": {
      "active": 6,
      "pending": 4
    },
    "tags": {
      "vip": 2,
      "priority": 3
    }
  },
  "suggestions": [
    {
      "text": "john doe refunded",
      "score": 0.92
    }
  ],
  "total_results": 10,
  "page": 1,
  "per_page": 20,
  "query_time_ms": 23
}

Body

query
string
required
The search query string. Supports fuzzy matching and operators
resources
array
Array of resource types to search. If empty, searches all resources. Options: [“orders”, “customers”, “products”, “inventory”, “returns”, “warranties”, “tickets”]
filters
object
Advanced filters to narrow search results
facets
array
Fields to generate facet counts for
sort
object
Sort configuration
pagination
object
Pagination configuration
highlight
boolean
Whether to include highlighted snippets in results
suggest
boolean
Whether to include search suggestions for typos

Response

results
array
Array of search results
facets
object
Facet counts for requested fields
suggestions
array
Search suggestions for possible typos
total_results
number
Total number of results found
page
number
Current page number
per_page
number
Results per page
query_time_ms
number
Time taken to execute the query in milliseconds
curl --location --request POST 'https://api.stateset.com/v1/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token <token>' \
--data-raw '{
    "query": "john doe refund",
    "resources": ["orders", "customers", "returns"],
    "filters": {
        "date_range": {
            "field": "created_at",
            "from": "2024-01-01",
            "to": "2024-12-31"
        },
        "status": ["active", "pending"]
    },
    "facets": ["resource_type", "status", "tags"],
    "sort": {
        "field": "created_at",
        "order": "desc"
    },
    "pagination": {
        "page": 1,
        "per_page": 20
    },
    "highlight": true,
    "suggest": true
}'
{
  "results": [
    {
      "id": "ord_123abc",
      "resource_type": "order",
      "score": 0.95,
      "data": {
        "id": "ord_123abc",
        "customer_name": "John Doe",
        "total": 299.99,
        "status": "pending",
        "created_at": "2024-03-15T10:30:00Z"
      },
      "highlights": {
        "customer_name": "<em>John Doe</em>",
        "notes": "Customer requested <em>refund</em> for damaged item"
      }
    },
    {
      "id": "cust_456def",
      "resource_type": "customer",
      "score": 0.88,
      "data": {
        "id": "cust_456def",
        "name": "John Doe",
        "email": "john.doe@example.com",
        "status": "active"
      },
      "highlights": {
        "name": "<em>John Doe</em>"
      }
    }
  ],
  "facets": {
    "resource_type": {
      "order": 5,
      "customer": 3,
      "return": 2
    },
    "status": {
      "active": 6,
      "pending": 4
    },
    "tags": {
      "vip": 2,
      "priority": 3
    }
  },
  "suggestions": [
    {
      "text": "john doe refunded",
      "score": 0.92
    }
  ],
  "total_results": 10,
  "page": 1,
  "per_page": 20,
  "query_time_ms": 23
}