---
title: "Mark the document as index-failed."
method: POST
path: "/v1/documents/{id}/index-failure"
tags: ["Documents"]
---

# Mark the document as index-failed.

`POST /v1/documents/{id}/index-failure`

Service-owned status transition. The `index_text_too_large` code on a `extraction_status='pending'` row atomically advances extraction to `'complete'` AND writes `semantic_index_status='failed'` so the durable row reflects the upload-pipeline sequence. Idempotent on retry; 409 on invalid source state.

## Path parameters

- `id` string, uuid, required

## Request body

- object — Constrained transition body for the index-failure route. Permitted transitions: (a) `extraction_status="complete"` + `semantic_index_status="pending"` -> writes `semantic_index_status="failed"`; (b) `extraction_status="pending"` + `semantic_index_status="pending"` AND `error_code="index_text_too_large"` -> atomically writes `extraction_status="complete"` + `semantic_index_status="failed"`; (c) idempotent retry on already-failed rows. Any other state returns 409.
  - `error_code` 'index_text_too_large' | 'extraction_empty' | 'unknown', required — Bounded semantic-index-layer failure code. `index_text_too_large` is the upload-pipeline shortcut for the case where extracted text exceeded the index byte cap before reaching `POST /:id/index`.
  - `error_message` string, required
  - `user_id` string, required — Required. user_id.

## Response `200`

Marker write acknowledgement; durable row echoed.

- object — Constrained-transition acknowledgement. The persisted row is echoed so callers can read back the durable status they just wrote. `idempotent: true` when the row was already in the failed state and the call only refreshed `last_error`.
  - `document` object, required — Document registry record. snake_case wire format.
    - `content_hash` string, nullable, required
    - `created_at` string, required
    - `delete_semantics` 'delete' | 'unpin' | 'tombstone' | 'null', nullable, required — What AtomicMemory's DELETE call does at the provider boundary for this row's storage_provider. `'delete'` = adapter issues the provider's removal operation; `'unpin'` = removes AtomicMemory's pin but the provider's other peers may continue to serve; `'tombstone'` = AtomicMemory stops managing the bytes but the decentralized network may still serve. `null` for pointer-only rows or providers not registered for cleanup.
    - `display_name` string, nullable, required
    - `external_id` string, required
    - `external_uri` string, nullable, required
    - `extraction_status` 'not_required' | 'pending' | 'running' | 'complete' | 'unsupported' | 'failed', required
    - `id` string, required
    - `indexed_at` string, nullable, required
    - `indexed_content_hash` string, nullable, required
    - `last_error` object, nullable, required
      - `code` string, required
      - `layer` 'raw_storage' | 'extraction' | 'semantic_index', required
      - `message` string, required
      - `occurred_at` string, required
    - `metadata` object, required
    - `mime_type` string, nullable, required
    - `provider_version` string, nullable, required
    - `raw_source_id` string, required
    - `raw_storage_metadata` object, required — Public-facing raw_storage_metadata. STRICTLY allowlisted: codec emits only name+version (AES-GCM internals never reach the wire); filecoin emits public fields (ipfs_cid, piece_cid, copy_count, provider_ids, copy_statuses) — `ipfs_cid` is an optional CIDv1 IPFS / CAR-root identity hint populated by drivers that derive one alongside the PieceCID; the canonical storage URI stays `filecoin://piece/<piece_cid>` regardless. The internal structured copies[{provider_id,status}] shape is flattened at the formatter; upload_result and other internal sidecars are NEVER emitted. The schema is deny-by-default (`.strict()`) at every level — a formatter regression that lets unknown keys through fails response-shape validation.
      - `codec` object
        - `name` 'none' | 'aes_gcm', required
        - `version` number, required
      - `filecoin` object
        - `copy_count` integer
        - `copy_statuses` string[]
        - `ipfs_cid` string
        - `piece_cid` string
        - `provider_ids` string[]
    - `raw_storage_status` 'pointer_recorded' | 'blob_stored' | 'inline_text_stored' | 'raw_storage_failed' | 'blob_deleted' | 'blob_pending' | 'blob_available' | 'blob_archival_failed' | 'blob_tombstoned', required
    - `registration_status` 'registered' | 'registration_failed', required
    - `semantic_index_status` 'not_required' | 'pending' | 'running' | 'complete' | 'failed' | 'stale', required
    - `size_bytes` number, nullable, required
    - `source_modified_at` string, nullable, required
    - `storage_artifact_id` string, uuid, nullable, required
    - `storage_mode` 'pointer_only' | 'managed_blob' | 'inline_small_text', required
    - `storage_provider` string, nullable, required
    - `storage_uri` string, nullable, required
    - `updated_at` string, required
    - `user_id` string, required
  - `idempotent` boolean, required

## Other responses

- `400` — Input validation error
- `404` — Document not found
- `409` — Invalid index state transition; current per-layer status echoed.
- `500` — Internal server error
- `502` — Upstream AI provider returned an unrecoverable failure (auth, non-retryable 4xx).
- `503` — Upstream AI provider is rate-limited, quota-exhausted, or returned 5xx; consult `retryable`.

---

[API](https://skmtc.net/atomicstrata/apis/atomicmemory-http-api.md) · [All operations](https://skmtc.net/atomicstrata/apis/atomicmemory-http-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/atomicstrata/atomicmemory-http-api/versions/d501daa39bb2/schema)
