{
  "info": {
    "name": "TurfAI DMS API",
    "description": "Complete API collection for TurfAI Document Management System",
    "version": "0.9.0",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "http://localhost:1337/api",
      "type": "string"
    },
    {
      "key": "jwt_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "document_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "collection_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "prompt_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "activity_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "execution_id",
      "value": "",
      "type": "string"
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{jwt_token}}",
        "type": "string"
      }
    ]
  },
  "item": [
    {
      "name": "Authentication",
      "item": [
        {
          "name": "Login",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "if (pm.response.code === 200) {",
                  "    var jsonData = pm.response.json();",
                  "    pm.collectionVariables.set(\"jwt_token\", jsonData.jwt);",
                  "    console.log(\"JWT Token saved:\", jsonData.jwt);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"identifier\": \"user@example.com\",\n  \"password\": \"password123\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/auth/local",
              "host": ["{{base_url}}"],
              "path": ["auth", "local"]
            },
            "description": "Login and get JWT token. Token is automatically saved to collection variables."
          }
        }
      ]
    },
    {
      "name": "Documents",
      "item": [
        {
          "name": "Upload Document",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "if (pm.response.code === 200 || pm.response.code === 201) {",
                  "    var jsonData = pm.response.json();",
                  "    pm.collectionVariables.set(\"document_id\", jsonData.id);",
                  "    console.log(\"Document ID saved:\", jsonData.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "file",
                  "type": "file",
                  "src": ""
                },
                {
                  "key": "title",
                  "value": "Test Document",
                  "type": "text"
                },
                {
                  "key": "description",
                  "value": "Test description",
                  "type": "text"
                },
                {
                  "key": "tags",
                  "value": "[\"test\",\"demo\"]",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/documents/upload",
              "host": ["{{base_url}}"],
              "path": ["documents", "upload"]
            },
            "description": "Upload a document file. Document ID is automatically saved."
          }
        },
        {
          "name": "List Documents",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/documents?populate=*&pagination[page]=1&pagination[pageSize]=25&sort=createdAt:desc",
              "host": ["{{base_url}}"],
              "path": ["documents"],
              "query": [
                {
                  "key": "populate",
                  "value": "*"
                },
                {
                  "key": "pagination[page]",
                  "value": "1"
                },
                {
                  "key": "pagination[pageSize]",
                  "value": "25"
                },
                {
                  "key": "sort",
                  "value": "createdAt:desc"
                },
                {
                  "key": "filters[title][$contains]",
                  "value": "invoice",
                  "disabled": true
                }
              ]
            }
          }
        },
        {
          "name": "Get Single Document",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/documents/{{document_id}}?populate=*",
              "host": ["{{base_url}}"],
              "path": ["documents", "{{document_id}}"],
              "query": [
                {
                  "key": "populate",
                  "value": "*"
                }
              ]
            }
          }
        },
        {
          "name": "Update Document Metadata",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"title\": \"Updated Document Title\",\n  \"description\": \"Updated description\",\n  \"tags\": [\"updated\", \"test\"]\n}"
            },
            "url": {
              "raw": "{{base_url}}/documents/{{document_id}}/metadata",
              "host": ["{{base_url}}"],
              "path": ["documents", "{{document_id}}", "metadata"]
            }
          }
        },
        {
          "name": "Delete Document",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/documents/{{document_id}}",
              "host": ["{{base_url}}"],
              "path": ["documents", "{{document_id}}"]
            }
          }
        }
      ]
    },
    {
      "name": "Collections",
      "item": [
        {
          "name": "List Collections",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/collections?populate=*",
              "host": ["{{base_url}}"],
              "path": ["collections"],
              "query": [
                {
                  "key": "populate",
                  "value": "*"
                }
              ]
            }
          }
        },
        {
          "name": "Create Collection",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "if (pm.response.code === 200 || pm.response.code === 201) {",
                  "    var jsonData = pm.response.json();",
                  "    pm.collectionVariables.set(\"collection_id\", jsonData.data.id);",
                  "    console.log(\"Collection ID saved:\", jsonData.data.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Test Collection\",\n  \"description\": \"Collection for testing\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/collections/create-collection",
              "host": ["{{base_url}}"],
              "path": ["collections", "create-collection"]
            }
          }
        },
        {
          "name": "Get Collection Documents",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/collections/{{collection_id}}/documents",
              "host": ["{{base_url}}"],
              "path": ["collections", "{{collection_id}}", "documents"]
            }
          }
        },
        {
          "name": "Add Document to Collection",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"documentId\": {{document_id}}\n}"
            },
            "url": {
              "raw": "{{base_url}}/collections/{{collection_id}}/add-document",
              "host": ["{{base_url}}"],
              "path": ["collections", "{{collection_id}}", "add-document"]
            }
          }
        },
        {
          "name": "Remove Document from Collection",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"documentId\": {{document_id}}\n}"
            },
            "url": {
              "raw": "{{base_url}}/collections/{{collection_id}}/remove-document",
              "host": ["{{base_url}}"],
              "path": ["collections", "{{collection_id}}", "remove-document"]
            }
          }
        },
        {
          "name": "Delete Collection",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/collections/{{collection_id}}/delete",
              "host": ["{{base_url}}"],
              "path": ["collections", "{{collection_id}}", "delete"]
            }
          }
        }
      ]
    },
    {
      "name": "Prompts",
      "item": [
        {
          "name": "List Prompts",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/prompts?populate=*",
              "host": ["{{base_url}}"],
              "path": ["prompts"],
              "query": [
                {
                  "key": "populate",
                  "value": "*"
                },
                {
                  "key": "filters[level][$eq]",
                  "value": "system",
                  "disabled": true
                }
              ]
            }
          }
        },
        {
          "name": "Get Single Prompt",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/prompts/{{prompt_id}}?populate=*",
              "host": ["{{base_url}}"],
              "path": ["prompts", "{{prompt_id}}"],
              "query": [
                {
                  "key": "populate",
                  "value": "*"
                }
              ]
            }
          }
        },
        {
          "name": "Create Prompt",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "if (pm.response.code === 200 || pm.response.code === 201) {",
                  "    var jsonData = pm.response.json();",
                  "    pm.collectionVariables.set(\"prompt_id\", jsonData.data.id);",
                  "    console.log(\"Prompt ID saved:\", jsonData.data.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"data\": {\n    \"title\": \"Test Extraction Prompt\",\n    \"type\": \"extraction\",\n    \"level\": \"user\",\n    \"section\": \"test\",\n    \"roles\": [\n      {\n        \"role\": \"system\",\n        \"prompt\": \"You are an AI assistant.\"\n      },\n      {\n        \"role\": \"user\",\n        \"prompt\": \"Extract information from the document.\"\n      }\n    ],\n    \"tasks\": [\n      \"Extract key information\",\n      \"Format as JSON\"\n    ],\n    \"instructions\": [\n      \"Be accurate\",\n      \"Use proper formatting\"\n    ]\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/prompts",
              "host": ["{{base_url}}"],
              "path": ["prompts"]
            }
          }
        },
        {
          "name": "Update Prompt",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"data\": {\n    \"title\": \"Updated Prompt Title\",\n    \"description\": \"Updated description\"\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/prompts/{{prompt_id}}",
              "host": ["{{base_url}}"],
              "path": ["prompts", "{{prompt_id}}"]
            }
          }
        },
        {
          "name": "Delete Prompt",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/prompts/{{prompt_id}}",
              "host": ["{{base_url}}"],
              "path": ["prompts", "{{prompt_id}}"]
            }
          }
        }
      ]
    },
    {
      "name": "Activities (Workflows)",
      "item": [
        {
          "name": "List Activities",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/activities?populate=*",
              "host": ["{{base_url}}"],
              "path": ["activities"],
              "query": [
                {
                  "key": "populate",
                  "value": "*"
                }
              ]
            }
          }
        },
        {
          "name": "Create Activity",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "if (pm.response.code === 200 || pm.response.code === 201) {",
                  "    var jsonData = pm.response.json();",
                  "    pm.collectionVariables.set(\"activity_id\", jsonData.data.id);",
                  "    console.log(\"Activity ID saved:\", jsonData.data.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"data\": {\n    \"name\": \"Test Workflow\",\n    \"description\": \"Simple extraction workflow\",\n    \"status\": \"draft\",\n    \"workflow_definition\": {\n      \"nodes\": [\n        {\n          \"id\": \"start\",\n          \"type\": \"start\",\n          \"data\": {\"label\": \"Start\"}\n        },\n        {\n          \"id\": \"extract\",\n          \"type\": \"extraction\",\n          \"data\": {\n            \"label\": \"Extract Data\",\n            \"task_type\": \"extraction_task\",\n            \"config\": {\n              \"prompt_id\": \"{{prompt_id}}\",\n              \"model_type\": \"vertex\"\n            }\n          }\n        },\n        {\n          \"id\": \"end\",\n          \"type\": \"end\",\n          \"data\": {\"label\": \"End\"}\n        }\n      ],\n      \"edges\": [\n        {\"id\": \"e1\", \"source\": \"start\", \"target\": \"extract\"},\n        {\"id\": \"e2\", \"source\": \"extract\", \"target\": \"end\"}\n      ]\n    }\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/activities",
              "host": ["{{base_url}}"],
              "path": ["activities"]
            }
          }
        },
        {
          "name": "Get Single Activity",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/activities/{{activity_id}}?populate=*",
              "host": ["{{base_url}}"],
              "path": ["activities", "{{activity_id}}"],
              "query": [
                {
                  "key": "populate",
                  "value": "*"
                }
              ]
            }
          }
        },
        {
          "name": "Update Activity",
          "request": {
            "method": "PUT",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"data\": {\n    \"name\": \"Updated Workflow Name\",\n    \"status\": \"active\"\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/activities/{{activity_id}}",
              "host": ["{{base_url}}"],
              "path": ["activities", "{{activity_id}}"]
            }
          }
        },
        {
          "name": "Delete Activity",
          "request": {
            "method": "DELETE",
            "header": [],
            "url": {
              "raw": "{{base_url}}/activities/{{activity_id}}",
              "host": ["{{base_url}}"],
              "path": ["activities", "{{activity_id}}"]
            }
          }
        }
      ]
    },
    {
      "name": "Workflow Executions",
      "item": [
        {
          "name": "Create Execution",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "if (pm.response.code === 200 || pm.response.code === 201) {",
                  "    var jsonData = pm.response.json();",
                  "    pm.collectionVariables.set(\"execution_id\", jsonData.data.id);",
                  "    console.log(\"Execution ID saved:\", jsonData.data.id);",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"data\": {\n    \"activity\": {{activity_id}},\n    \"inputs\": {\n      \"document_url\": \"https://storage.googleapis.com/path/to/doc.pdf\",\n      \"mime_type\": \"application/pdf\"\n    }\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/workflow-executions",
              "host": ["{{base_url}}"],
              "path": ["workflow-executions"]
            }
          }
        },
        {
          "name": "Execute Workflow",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"document_url\": \"https://storage.googleapis.com/path/to/doc.pdf\",\n  \"mime_type\": \"application/pdf\"\n}"
            },
            "url": {
              "raw": "{{base_url}}/workflow-executions/{{execution_id}}/execute",
              "host": ["{{base_url}}"],
              "path": ["workflow-executions", "{{execution_id}}", "execute"]
            }
          }
        },
        {
          "name": "Get Execution Status",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/workflow-executions/{{execution_id}}/status",
              "host": ["{{base_url}}"],
              "path": ["workflow-executions", "{{execution_id}}", "status"]
            },
            "description": "Poll this endpoint to check workflow execution status"
          }
        },
        {
          "name": "Resume Paused Workflow",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"correlation_token\": \"doc_input_xyz123\",\n  \"user_data\": {\n    \"document_url\": \"https://storage.googleapis.com/path/to/selected.pdf\",\n    \"document_name\": \"Selected Document.pdf\",\n    \"mime_type\": \"application/pdf\"\n  }\n}"
            },
            "url": {
              "raw": "{{base_url}}/workflow-executions/{{execution_id}}/resume",
              "host": ["{{base_url}}"],
              "path": ["workflow-executions", "{{execution_id}}", "resume"]
            }
          }
        }
      ]
    },
    {
      "name": "Dashboard",
      "item": [
        {
          "name": "Get Stats",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/dashboard/stats?period=7d",
              "host": ["{{base_url}}"],
              "path": ["dashboard", "stats"],
              "query": [
                {
                  "key": "period",
                  "value": "7d",
                  "description": "24h, 7d, or 30d"
                },
                {
                  "key": "tenant",
                  "value": "tenant1",
                  "disabled": true
                }
              ]
            }
          }
        },
        {
          "name": "Get Activity Data",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/dashboard/activity?period=7d",
              "host": ["{{base_url}}"],
              "path": ["dashboard", "activity"],
              "query": [
                {
                  "key": "period",
                  "value": "7d"
                }
              ]
            }
          }
        },
        {
          "name": "Get Recent Activity Feed",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/dashboard/recent-activity?limit=10",
              "host": ["{{base_url}}"],
              "path": ["dashboard", "recent-activity"],
              "query": [
                {
                  "key": "limit",
                  "value": "10"
                }
              ]
            }
          }
        },
        {
          "name": "System Health",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/dashboard/health",
              "host": ["{{base_url}}"],
              "path": ["dashboard", "health"]
            },
            "description": "No authentication required"
          },
          "auth": {
            "type": "noauth"
          }
        }
      ]
    }
  ]
}
