---
title: "Index GCS File"
method: POST
path: "/v2/collections/{collection_name}/index/gcs/file"
tags: ["indexing"]
---

# Index GCS File

`POST /v2/collections/{collection_name}/index/gcs/file`

## Request

- Base URL: `https://api.captain.dev`
- URL: `https://api.captain.dev/v2/collections/{collection_name}/index/gcs/file`
- Auth: none declared

Index a single file from GCS bucket into a collection.

Headers:
- Authorization: Bearer {api_key} - Captain API key for authentication
- X-Organization-ID: Organization UUID

Args:
    collection_name: Name of the collection (path parameter)
    body: GCS file configuration with file_uri

Returns:
    { job_id, status: "pending" }

## Path parameters

- `collection_name` string, required

## Headers

- `authorization` string, nullable

## Request body

- IndexGCSFileRequest
  - `bucket_name` string, required
  - `custom_metadata` object, nullable: Custom metadata to attach to all chunks from this file. Keys must be strings. Values: str, int, float, bool, or List[str].
  - `file_uri` string, required
  - `overwrite_existing` boolean: When true, files that already exist in the collection are re-indexed and replaced with zero downtime: the new version is built alongside the live one and atomically swapped in when complete, so the previous version keeps serving search results throughout the rebuild. The document keeps the same document_id across overwrites, and its status reads 'updating' in the document listing while the rebuild runs. Requires skip_existing=false. Setting both to true returns a 400 error.
  - `parsing_script` string, nullable: Relative path to a JS parsing script for JSON files (e.g. 'research/paper-parser'). When provided, .json files are processed through a sandboxed V8 isolate. Without this, .json files are indexed as raw text.
  - `processing_type` 'advanced' | 'basic', required: Document processing type. 'advanced' uses agentic OCR with AI-enhanced extraction for complex layouts, tables, figures, charts, and documents containing images. 'basic' provides reliable OCR optimized for general document indexing and high-volume processing.
  - `service_account_json` string, required
  - `skip_existing` boolean: When true, files already indexed in the collection are skipped and will not be re-indexed with incoming changes. When false, all incoming files are indexed regardless of whether they already exist.
  - `source_identity` string, nullable: Stable identity for this document, independent of where the object is read from. Indexing any location with the same source_identity updates the same document instead of creating another, and skip_existing matches on it. Defaults to the object's own URI. Opaque to Captain; one line, no newlines.
  - `mask_pii` boolean: When 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.
  - `pii_engine` 'kev' | 'jev' | 'presidio' | 'captain-jev' | 'captain-presidio': Masking 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`.
  - `pii_fallback` union: Ordered 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`.
    - PiiFallbackPolicy: Fallback policy for `pii_engine: "jev"`. If every engine fails, the file fails to index and the rest of the job continues.
      - `engines` PiiFallbackPolicyEnginesItems[]: Engines to try, in order, when `jev` fails with a rate limit, timeout, capacity limit, provider error or invalid answer. `jev-openrouter` and `jev-ai-gateway` are the same Jev model served through OpenRouter and Vercel AI Gateway. Custom fields and instructions apply on every engine. `presidio` is not allowed, and an engine may appear only once.
      - `retry_budget_seconds` integer: Extra retry and wait time per engine, for each piece of a file, before moving to the next engine. Time spent on successful answers does not count. 0 means one attempt per engine. Normal request timeouts still apply.
    - boolean
  - `pii_fields` PIIField[], nullable: 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.
    - `name` string, required: Tag for this category. Uppercase letters, digits and underscores, 2 to 40 characters, unique within the request and not one of the built-in tags. Masked values are replaced with the tag in angle brackets (a field named EMPLOYEE_ID produces <EMPLOYEE_ID>) and the masking report lists them under this name.
    - `description` string, required: What the category covers, in plain language, as you would explain it to a colleague. This is what decides whether a value is masked, so say what the values look like and where they appear.
    - `examples` string[], nullable: Up to 10 sample values, used only to make the description concrete. They are not a pattern: values that do not look like the examples are still masked when the description covers them.
  - `pii_instructions` string, nullable: Plain-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.
  - `transcription_language` string, nullable: AWS Transcribe language code for the spoken audio (e.g. 'es-US', 'pt-BR'). Omit to auto-detect per file. Video and audio files only. Supported codes: https://docs.aws.amazon.com/transcribe/latest/dg/supported-languages.html

## Response `200`

Successful Response

- IndexJobResponse
  - `job_id` string, required
  - `status` string
  - `custom_metadata` object, nullable: The custom_metadata Captain accepted for this job, echoed back as validated. Null when none was supplied.

## Other responses

- `400`: overwrite_existing and skip_existing cannot both be true

## Changes

- **2026-09-26** `ac61e472bb7d`: 1 breaking, 2 warning, 3 info
  - the `pii_fallback` request property type changed from `object` to no type
  - removed the request property `pii_fallback/engines`
  - removed the request property `pii_fallback/retry_budget_seconds`
  - added the new `captain-jev` enum value to the request property `pii_engine`
  - …2 more
- **2026-09-24** `61a9364ad042`: 4 breaking, 11 info
  - removed the enum value `captain-jev` of the request property `pii_engine`
  - removed the enum value `captain-presidio` of the request property `pii_engine`
  - the `pii_fallback` request property type changed from `boolean` to `object`
  - the response's body type changed from no type to `object` for status `400`
  - …11 more
- **2026-09-20** `57fab6058b1a`: 1 info
  - added the new optional request property `source_identity`
- **2026-09-18** `bc541b943881`: 4 info
  - added the new optional request property `pii_engine`
  - added the new optional request property `pii_fallback`
  - added the new optional request property `pii_fields`
  - added the new optional request property `pii_instructions`
- **2026-09-12** `d07ce3783494`: 1 info
  - api operation id `index-gcs-file-v-2` removed and replaced with `indexing_index_gcs_file_v2`

[Operation history](https://skmtc.dev/runcaptain/apis/runcaptain/changes/v2/collections/:collection_name/index/gcs/file/post.md)

---

[API](https://skmtc.dev/runcaptain/apis/runcaptain.md) - [All operations](https://skmtc.dev/runcaptain/apis/runcaptain/llms.txt) - [OpenAPI document](https://skmtc.dev/runcaptain/apis/runcaptain/revisions/ac61e472bb7d?raw)
