{
  "info": {
    "_postman_id": "4ef5f8df-b6f6-4678-8ac2-a8fce7ec0a12",
    "name": "FishDog API v1 - Canonical Workflow",
    "description": "Runnable collection for the canonical 6-step flow plus direct question and attachment branches.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://api.example.com/v1"
    },
    {
      "key": "api_key",
      "value": ""
    },
    {
      "key": "group_uuid",
      "value": ""
    },
    {
      "key": "study_id",
      "value": ""
    },
    {
      "key": "question_job_id",
      "value": ""
    },
    {
      "key": "completion_job_id",
      "value": ""
    },
    {
      "key": "agent_id",
      "value": ""
    },
    {
      "key": "group_id_or_uuid",
      "value": ""
    },
    {
      "key": "media_asset_id",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Core 6-Step Flow",
      "item": [
        {
          "name": "1 Recruit Group",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const body = pm.response.json();",
                  "const groupUuid = body && body.group && body.group.uuid;",
                  "if (groupUuid) pm.collectionVariables.set('group_uuid', groupUuid);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Midwest Parents\",\n  \"description\": \"People who cook dinner at home and manage grocery shopping\",\n  \"group_size\": 10,\n  \"filters\": {\n    \"match\": \"all\",\n    \"filters\": {\n      \"country\": { \"any\": [\"USA\"] },\n      \"state\": { \"any\": [\"IL\", \"IN\", \"MI\", \"OH\"] }\n    }\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/research-groups/recruit",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "research-groups",
                "recruit"
              ]
            }
          }
        },
        {
          "name": "2 Create Study",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const body = pm.response.json();",
                  "const studyId = body && body.study && body.study.id;",
                  "if (studyId) pm.collectionVariables.set('study_id', String(studyId));"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Grocery Preferences 2026\",\n  \"objective\": \"Understand grocery shopping priorities\",\n  \"research_group_uuid\": \"{{group_uuid}}\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/research-studies",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "research-studies"
              ]
            }
          }
        },
        {
          "name": "3 Ask Study Question",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const body = pm.response.json();",
                  "const firstJobId = body && Array.isArray(body.job_ids) ? body.job_ids[0] : null;",
                  "if (firstJobId) pm.collectionVariables.set('question_job_id', firstJobId);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"question\": \"What matters most when choosing a grocery store?\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/research-studies/{{study_id}}/questions",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "research-studies",
                "{{study_id}}",
                "questions"
              ]
            }
          }
        },
        {
          "name": "4 Poll Question Job",
          "request": {
            "method": "GET",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              }
            ],
            "url": {
              "raw": "{{base_url}}/jobs/{{question_job_id}}",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "jobs",
                "{{question_job_id}}"
              ]
            }
          }
        },
        {
          "name": "5 Complete Study",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const body = pm.response.json();",
                  "const completionJobId = body && Array.isArray(body.job_ids) ? body.job_ids[0] : null;",
                  "if (completionJobId) pm.collectionVariables.set('completion_job_id', completionJobId);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"force\": false\n}"
            },
            "url": {
              "raw": "{{base_url}}/research-studies/{{study_id}}/complete",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "research-studies",
                "{{study_id}}",
                "complete"
              ]
            }
          }
        },
        {
          "name": "6 Enable Sharing",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"enabled\": true\n}"
            },
            "url": {
              "raw": "{{base_url}}/research-studies/{{study_id}}/share",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "research-studies",
                "{{study_id}}",
                "share"
              ]
            }
          }
        }
      ]
    },
    {
      "name": "Optional Branches",
      "item": [
        {
          "name": "Direct Agent Question",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"question\": \"What is your first reaction to this concept?\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/research-agents/{{agent_id}}/questions",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "research-agents",
                "{{agent_id}}",
                "questions"
              ]
            }
          }
        },
        {
          "name": "Direct Group Question",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"question\": \"What is your first reaction to this concept?\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/research-groups/{{group_id_or_uuid}}/questions",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "research-groups",
                "{{group_id_or_uuid}}",
                "questions"
              ]
            }
          }
        },
        {
          "name": "Upload Media Asset",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "const body = pm.response.json();",
                  "const mediaId = body && body.media_asset && body.media_asset.id;",
                  "if (mediaId) pm.collectionVariables.set('media_asset_id', mediaId);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "Bearer {{api_key}}"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"filename\": \"concept.pdf\",\n  \"mime\": \"application/pdf\",\n  \"file_data\": \"<BASE64_PAYLOAD>\",\n  \"encoding\": \"base64\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/media-assets",
              "host": [
                "{{base_url}}"
              ],
              "path": [
                "media-assets"
              ]
            }
          }
        }
      ]
    }
  ]
}
