INVALID_STATE — Resource can't accept this operation
Summary
Section titled “Summary”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.
HTTP status
Section titled “HTTP status”409 Conflict. Standard envelope.
Example response
Section titled “Example response”{ "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" }}Why this happens
Section titled “Why this happens”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.
How to fix it
Section titled “How to fix it”- Read the
message— it always names the required prior step. - The lifecycle is: upload responses → generate codebook → code → refine → export. Skipping a step usually causes this error.
- Use
GET /v1/projects/{id}/questions/{qid}to inspect the current state — fields likehas_codebook,coded_count, andstatustell you where you are in the pipeline.
Related
Section titled “Related”EMPTY_CODEBOOK— specific case for missing codebooksNO_DATA— specific case for missing responses- Coding pipeline