Index Text
Index plain text content into a collection.
Accepts raw text content in the request body, saves it as a .txt file, and indexes it for semantic search. No file upload or cloud storage needed.
Headers:
- Authorization: Bearer {api_key} - Captain API key for authentication
- X-Organization-ID: Organization UUID
- Idempotency-Key: UUID for request deduplication (optional)
Args: collection_name: Name of the collection (path parameter) body: Text content and optional metadata
Returns: { job_id, status: "pending" }
Path parameters
Headers
Request
This endpoint expects an object.
The text content to index.
Custom metadata to attach to all indexed chunks. Keys must be strings. Values: str, int, float, bool, or List[str].
Optional filename for the text document. Defaults to ‘snippet-{N}.txt’ where N auto-increments.
falseWhen true, detected PII (emails, phone numbers, SSNs, credit cards, names, and locations) is masked in the parsed content before it is embedded and stored — replaced with entity tags like <PERSON> and <EMAIL_ADDRESS>. For images (including images embedded in PDFs), PII text visible in the image is also pixel-redacted. Opt-in; defaults to false, which leaves content unchanged.
kevMasking engine for this job. kev (default): the Kev classifier model on Captain’s infrastructure; supports pii_fields and pii_instructions; no fallback, so a file kev cannot mask fails to index and the rest of the job continues. jev: TypeSafe’s hosted Jev model, slightly more accurate, best-effort availability; supports custom fields and instructions and may list fallbacks in pii_fallback. presidio: the legacy pattern engine, built-in categories only (rejects pii_fields or pii_instructions with 422), never a fallback. Requires mask_pii: true. The earlier names captain-jev and captain-presidio keep working as before; new requests should use kev, jev or presidio.
kevjevpresidiocaptain-jevcaptain-presidioOrdered fallback engines for jev, as {"engines": [...], "retry_budget_seconds": n}. Omitted or an empty engines list means no fallback. Only valid with pii_engine: "jev"; with kev or presidio a non-empty list answers 422. On the multipart file upload endpoint, send it as a JSON string form field. With the earlier engine name captain-jev it is true (default, fall back to captain-presidio) or false.
Additional PII categories to mask for this job, on top of the built-in set. Requires mask_pii to be true. Up to 20 fields. Each masked value is replaced with the field’s tag in angle brackets and appears in the masking report under the field’s name.
<=1000 charactersPlain-language guidance that steers what counts as personal data for this job, for the built-in categories and any pii_fields. For example: ‘Names of hospital staff may stay; patient names, record numbers and bed assignments must be masked.’ Requires mask_pii to be true. Up to 1,000 characters.
Response
Successful Response
pendingThe custom_metadata Captain accepted for this job, echoed back as validated. Null when none was supplied.
import requests
BASE_URL = "https://api.filesearch.dev"
API_KEY = "your_api_key"
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.post(
f"{BASE_URL}/v2/collections/my_documents/index/text",
headers=headers,
json={"content": "Captain supports multilingual video and audio transcription with automatic language detection.", "filename": "release-notes.txt"},
timeout=60.0
)
print(response.json()){
"job_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6-1783111725",
"status": "pending"
}