Skip to content

INVALID_STATE — Resource can't accept this operation

The resource is in a state the requested operation doesn’t allow — for example, coding a question before generating a codebook, or refining a codebook on a question with no coded responses.

409 Conflict. Standard envelope.

{
"success": false,
"error": {
"code": "INVALID_STATE",
"message": "Question must have a codebook before coding. Generate one first with POST /v1/codebook/generate.",
"request_id": "req_01HXJZK4ABCDEF",
"doc_url": "https://docs.surveycoder.io/errors/invalid-state"
}
}

Common state mismatches:

  • Trying to code a question before it has a codebook → generate one first.
  • Trying to refine before any responses are coded → run coding first.
  • Trying to clone a codebook from a question that has no codebook → use a different source.
  • Trying to finalize a refinement that’s already resolved.
  1. Read the message — it always names the required prior step.
  2. The lifecycle is: upload responses → generate codebook → code → refine → export. Skipping a step usually causes this error.
  3. Use GET /v1/projects/{id}/questions/{qid} to inspect the current state — fields like has_codebook, coded_count, and status tell you where you are in the pipeline.