Skip to main content

Use Case

Search company records with guarded OpenSearch Query DSL. Discover valid fields first, inspect top values for one field, then run the paginated search.
  1. GET /search/filter-capabilities
  2. POST /search/filter-field-values
  3. POST /search/start-filter-search

Headers

NameTypeRequiredDescription
x-api-keystringYesYour Sixtyfour API key.
Content-TypestringFor POST requestsMust be application/json.

Filter Capabilities

GET https://api.sixtyfour.ai/search/filter-capabilities
Returns the live field contract for company direct-filter search. Use value_fields to determine which fields support POST /search/filter-field-values.

value_fields entry

FieldTypeDescription
fieldstringCanonical field name to use in API requests.
aggregation_fieldstring or nullUnderlying field used for top-values aggregation.
nested_pathstring or nullNested path for nested fields.
value_typestringMapping-derived value type such as keyword, boolean, number, or date.
supports_top_valuesbooleanWhether POST /search/filter-field-values supports this field.
supports_exact_filter_snippetbooleanWhether the response can include deterministic exact-match snippets.

Field Values

POST https://api.sixtyfour.ai/search/filter-field-values
Returns top values for one field, ranked by descending scoped company count. There is no batch variant.

Request Body

FieldTypeRequiredDescription
modestringNoMust be "company". Defaults to "company".
fieldstringYesField to inspect. The field must exist in value_fields and support top values.
top_kintegerNoNumber of values to return. Range 1..100. Default 25.
filtersobjectNoOptional scoped query. Only filters.query is allowed.

Scoped Query

  • Omit filters for global scope.
  • Send only filters.query for scoped discovery.
  • filters.sort and filters.size are not allowed on this endpoint.
{
  "filters": {
    "query": { "...": "..." }
  }
}

Request Example

Global:
{
  "mode": "company",
  "field": "hq_country_iso2",
  "top_k": 10
}
Scoped:
{
  "mode": "company",
  "field": "industry",
  "top_k": 20,
  "filters": {
    "query": {
      "bool": {
        "filter": [
          { "term": { "hq_country_iso2": "US" } },
          { "range": { "employees_count": { "gte": 200, "lte": 5000 } } },
          { "term": { "ownership_status": "private" } }
        ]
      }
    }
  }
}

Response

{
  "mode": "company",
  "field": "hq_country_iso2",
  "canonical_field": "hq_country_iso2",
  "aggregation_field": "hq_country_iso2",
  "nested_path": null,
  "value_type": "keyword",
  "supports_top_values": true,
  "supports_exact_filter_snippet": true,
  "total_scoped_documents": 12345,
  "request_duration_ms": 47,
  "values": [
    {
      "value": "US",
      "count": 4200,
      "percent_of_scope": 0.340219,
      "filter_snippet": {
        "term": { "hq_country_iso2": "US" }
      }
    }
  ]
}

Response Fields

FieldTypeDescription
modestringAlways "company".
fieldstringField requested in the request.
canonical_fieldstringCanonical field resolved by the server.
aggregation_fieldstring or nullActual field aggregated in OpenSearch.
nested_pathstring or nullNested path for nested fields.
value_typestringMapping-derived value type.
supports_top_valuesbooleanCapability flag for this field.
supports_exact_filter_snippetbooleanWhether exact snippet generation is available.
total_scoped_documentsintegerNumber of company documents in the active scope.
request_duration_msintegerServer processing time in milliseconds.
valuesarrayTop values ranked by descending count in the active scope.

values entry

FieldTypeDescription
valueany or nullCandidate value.
countintegerCompany-document count for this value inside the active scope.
percent_of_scopenumbercount / total_scoped_documents, rounded to 6 decimals.
filter_snippetobject or nullReady-to-use exact filter clause for this value.

Nested Example

For nested fields such as funding_rounds.name, counts are company-document counts and snippets are wrapped in nested.
{
  "field": "funding_rounds.name",
  "values": [
    {
      "value": "Series A",
      "count": 120,
      "percent_of_scope": 0.15,
      "filter_snippet": {
        "nested": {
          "path": "funding_rounds",
          "query": {
            "term": { "funding_rounds.name.keyword": "Series A" }
          }
        }
      }
    }
  ]
}

Error Codes

HTTPcodeMeaning
400unsupported_modemode is not company.
400invalid_scoped_filtersScoped body is invalid. This includes missing filters.query or unsupported keys.
400unsupported_fieldField is not supported for value discovery.
400top_values_not_supportedField exists but does not support top-values aggregation.
400invalid_requestGeneric request validation failure.
504opensearch_timeoutAggregation timed out. Retry with narrower scope or smaller top_k.
500aggregation_failedUnexpected aggregation failure.
POST https://api.sixtyfour.ai/search/start-filter-search
Runs the paginated company search. Use filter_snippet values from POST /search/filter-field-values to build exact filters.

Request Body

FieldTypeRequiredDescription
modestringNoDefaults to "company". Only company mode is supported.
filtersobjectConditionallyRequired for fresh searches. Must include query. Optional sort, optional size.
max_resultsintegerNoTotal cap across pages. Range 1..5000.
page_sizeintegerNoPage size for company pagination. Range 1..100. Default 10.
cursorstringNoCursor token for the next page. When present, the request should only include cursor.
save_jsonbooleanNoNot supported for company mode. true returns 400.

Request Flow

  1. First request: send filters and optionally page_size and max_results.
  2. Next page request: send only {"cursor":"..."}.
  3. Requests that mix cursor with filters, page_size, max_results, or save_json are invalid.

Effective Result Cap

  • page_size controls rows per page. Range 1..100. Default 10.
  • max_results controls the row cap across all pages. Range 1..5000.
  • If max_results is omitted, the effective cap can come from filters.size.
  • If both max_results and filters.size are omitted, the backend applies its default server cap flow.

Request Example

First page:
{
  "mode": "company",
  "page_size": 10,
  "max_results": 100,
  "filters": {
    "query": {
      "bool": {
        "filter": [
          { "term": { "hq_country_iso2": "US" } },
          { "range": { "employees_count": { "gte": 100, "lte": 5000 } } }
        ]
      }
    },
    "sort": [
      { "employees_count": "desc" }
    ]
  }
}
Next page:
{
  "cursor": "eyJpZCI6I..."
}

Response

{
  "next_cursor": "eyJpZCI6I...",
  "cursor_expires_in_seconds": 1800,
  "request_duration_ms": 142,
  "has_more": true,
  "page_size": 10,
  "page_count": 10,
  "page_number": 1,
  "max_pages": 500,
  "remaining_results": 4990,
  "total_results": 10,
  "exported_count": 0,
  "results": [
    {
      "raw_document_id": "stripe",
      "raw_source": {
        "company_name": "Stripe",
        "hq_country_iso2": "US",
        "employees_count": 8000
      }
    }
  ]
}
FieldTypeDescription
next_cursorstring or nullCursor for the next page. null when there are no more pages.
cursor_expires_in_secondsintegerSeconds until the current cursor expires.
request_duration_msintegerServer-side request duration in milliseconds.
has_morebooleanWhether another page is available.
page_sizeintegerRequested page size.
page_countintegerNumber of rows returned in the current page.
page_numberintegerCurrent page number, starting at 1.
max_pagesintegerMaximum page count available under the effective cap for this search.
remaining_resultsintegerNumber of rows still available under the effective cap after the current page.
total_resultsintegerCumulative rows returned so far across the cursor flow. This is not a global match count.
exported_countintegerAlways 0 in company mode.
resultsarrayCompany rows for the current page.

Result Row

FieldTypeDescription
raw_document_idstringStable identifier for the returned company document.
raw_sourceobjectCompany source payload for the row, excluding hidden internal fields.
{
  "raw_document_id": "stripe",
  "raw_source": {
    "company_name": "Stripe",
    "hq_country_iso2": "US",
    "employees_count": 8000
  }
}
raw_source returns the company document directly. It does not use grouped objects such as identity, profile, or location.

Error Response

StatusDescription
400Invalid or expired cursor, invalid Query DSL, unsupported parameters, unsupported mode, save_json=true in company mode, invalid page_size, or invalid max_results.
404Cursor belongs to another organization.
409Cursor is already being processed. Retry with the same cursor after the in-flight request finishes.
429Rate limit exceeded.
500Unexpected server error.
503Company OpenSearch is not configured.
Example 400 response:
{
  "detail": "Cursor is invalid or has expired"
}

Filters

The filters object accepts OpenSearch Query DSL for company records.

Top-Level Shape

{
  "filters": {
    "query": { ... },
    "sort": [ ... ],
    "size": 100
  }
}
KeyTypeDescription
queryobjectRequired for fresh searches. OpenSearch query object.
sortarrayOptional. Sort clauses for the first request.
sizeintegerOptional. Additional size hint that can drive the effective cap when max_results is omitted.

Supported Query Clauses

ClauseDescription
boolCombine conditions with must, filter, should, and must_not.
termExact-match query for a single value.
termsExact-match query for multiple values.
rangeNumeric or date range with gt, gte, lt, lte.
existsMatch documents where a field is present.
matchFull-text match query.
match_phrasePhrase query.
multi_matchSearch the same value across multiple fields.
nestedQuery nested arrays and nested objects.
match_allMatch all company records.
Use GET /search/filter-capabilities to determine valid query, sort, range, nested, and value fields.

Query Examples

Exact match:
{
  "term": {
    "website_domain": "stripe.com"
  }
}
Range filter:
{
  "range": {
    "employees_count": {
      "gte": 100,
      "lte": 5000
    }
  }
}
Multi-field full-text search:
{
  "multi_match": {
    "query": "cloud security",
    "fields": [
      "description",
      "categories_and_keywords.element"
    ],
    "type": "best_fields",
    "operator": "and"
  }
}
Nested query:
{
  "nested": {
    "path": "funding_rounds",
    "query": {
      "match_phrase": {
        "funding_rounds.name": "Series B"
      }
    }
  }
}

Limits

LimitValue
POST /search/filter-field-values20 requests per minute per organization
POST /search/start-filter-search10 requests per minute per organization
top_k1..100
page_size1..100
max_results1..5000