{
  "info": {
    "_postman_id": "937a475b-e9a4-53da-b1f1-180347f81ef6",
    "name": "POS GROVE POS API — AI assistant",
    "description": "Questions about sales, stock, customers, finance, HR and projects, answered from this installation's data without any internet service. API keys need the `ai` scope (or plain read) plus the scope of the data asked about.\n\n**Setup**\n1. Set the collection variable `baseUrl` to your POS GROVE address followed by `/api/v1`.\n2. Either paste an API key (Online store → API & Webhooks) into `accessToken`, or run **Get an access token** (in the *Sign in* or *Authentication* folder): it signs in with a username and password and saves the token for you (valid 12 hours).\n3. Send any request. A test checks the `{ success }` envelope on every answer.\n\nAll responses use `{ success, message, data, meta }`; errors use `{ success: false, message, error: { code, details, requestId } }`. Lists accept `page`, `limit`, `sort` and `fields`.\n\nReference: https://posgrove.com/docs/pos-api",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{accessToken}}",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "// POS GROVE APIs answer { success, message, data } (or { success: false, error, message }).",
          "pm.test(\"Response is JSON\", function () { pm.response.to.be.json; });",
          "pm.test(\"Envelope has a success flag\", function () {",
          "  var b = pm.response.json();",
          "  pm.expect(b).to.have.property(\"success\");",
          "  if (pm.response.code < 400) pm.expect(b.success).to.eql(true);",
          "});"
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://your-store.example.com/api/v1",
      "type": "string",
      "description": "Your POS GROVE address followed by /api/v1, e.g. https://shop.example.com/api/v1"
    },
    {
      "key": "accessToken",
      "value": "",
      "type": "string",
      "description": "An API key, or the token saved by the Get an access token request."
    }
  ],
  "item": [
    {
      "name": "Sign in",
      "description": "Run once: saves {{accessToken}} for the other requests (or paste an API key instead).",
      "item": [
        {
          "name": "Get an access token",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/token",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "token"
              ]
            },
            "description": "Signs in with a username and password (and the 6-digit code when two-factor sign-in is on) and returns a bearer token valid for 12 hours. The token is shown only once. Five wrong passwords in a row disable the account, as on the sign-in page.\n\nNo authentication needed.\n\n`POST /auth/token` · operationId `auth.token`",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"username\": \"jane\",\n  \"password\": \"••••••••\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "auth": {
              "type": "noauth"
            }
          },
          "response": [
            {
              "name": "201 Success",
              "originalRequest": {
                "method": "POST",
                "header": [
                  {
                    "key": "Accept",
                    "value": "application/json"
                  },
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ],
                "url": {
                  "raw": "{{baseUrl}}/auth/token",
                  "host": [
                    "{{baseUrl}}"
                  ],
                  "path": [
                    "auth",
                    "token"
                  ]
                },
                "body": {
                  "mode": "raw",
                  "raw": "{\n  \"username\": \"jane\",\n  \"password\": \"••••••••\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                }
              },
              "status": "Success",
              "code": 201,
              "_postman_previewlanguage": "json",
              "header": [
                {
                  "key": "Content-Type",
                  "value": "application/json; charset=utf-8"
                }
              ],
              "body": "{\n  \"success\": true,\n  \"message\": \"OK\",\n  \"data\": {\n    \"token\": \"mtk_<token shown once>\",\n    \"tokenType\": \"Bearer\",\n    \"expiresAt\": \"2026-10-02T21:30:00.000Z\",\n    \"expiresIn\": 43200,\n    \"user\": {\n      \"id\": \"66f1c2a9e4b0a1b2c3d4e502\",\n      \"username\": \"jane\",\n      \"name\": \"Jane Doe\"\n    }\n  }\n}"
            }
          ],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "var body = {};",
                  "try { body = pm.response.json(); } catch (e) {}",
                  "if (body && body.data && body.data.token) {",
                  "  pm.collectionVariables.set(\"accessToken\", body.data.token);",
                  "  if (pm.environment && pm.environment.has(\"accessToken\")) pm.environment.set(\"accessToken\", body.data.token);",
                  "  console.log(\"POS GROVE: access token saved to {{accessToken}} (valid until \" + body.data.expiresAt + \")\");",
                  "}",
                  "pm.test(\"Access token received\", function () { pm.expect(body.data && body.data.token).to.be.a(\"string\"); });"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Ask a question",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/ai/ask",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "ai",
            "ask"
          ]
        },
        "description": "`status` is `answered`, `no_match` (with `suggestions`) or `denied` (the user or key may not see that data). Answers can include `facts` (headline figures), a `table` and a `chart`; money values are plain numbers in the store currency (`currency`).\n\nAny signed-in user.\n\nScope: `ai:read`.\n\n`POST /ai/ask` · operationId `ai.ask`",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"question\": \"How much did we sell this month?\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": [
        {
          "name": "200 Success",
          "originalRequest": {
            "method": "POST",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              },
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/ai/ask",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "ai",
                "ask"
              ]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"question\": \"How much did we sell this month?\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          },
          "status": "Success",
          "code": 200,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json; charset=utf-8"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"message\": \"OK\",\n  \"data\": {\n    \"status\": \"answered\",\n    \"question\": \"How much did we sell this month?\",\n    \"intent\": \"sales.summary\",\n    \"area\": \"sales\",\n    \"areaLabel\": \"Sales\",\n    \"period\": {\n      \"label\": \"this month\",\n      \"from\": \"2026-10-01T00:00:00.000Z\",\n      \"to\": \"2026-10-02T23:59:59.999Z\"\n    },\n    \"store\": null,\n    \"currency\": \"NGN\",\n    \"corrections\": [],\n    \"link\": {\n      \"href\": \"/pos/report\",\n      \"label\": \"Sales report\"\n    },\n    \"answer\": \"You sold NGN845,000 this month at Main Street from 64 orders (average NGN13,203.13). That is +12.5% compared with the previous period.\",\n    \"facts\": [\n      {\n        \"label\": \"Revenue\",\n        \"value\": 845000,\n        \"type\": \"money\"\n      },\n      {\n        \"label\": \"Orders\",\n        \"value\": 64,\n        \"type\": \"number\"\n      },\n      {\n        \"label\": \"Average order\",\n        \"value\": 13203.13,\n        \"type\": \"money\"\n      },\n      {\n        \"label\": \"Items sold\",\n        \"value\": 211,\n        \"type\": \"number\"\n      }\n    ],\n    \"chart\": {\n      \"type\": \"line\",\n      \"labels\": [\n        \"2026-10-01\",\n        \"2026-10-02\"\n      ],\n      \"series\": [\n        {\n          \"label\": \"Revenue\",\n          \"data\": [\n            402000,\n            443000\n          ]\n        }\n      ],\n      \"format\": \"money\"\n    }\n  }\n}"
        }
      ]
    },
    {
      "name": "Questions you can ask",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/ai/suggestions",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "ai",
            "suggestions"
          ]
        },
        "description": "Example questions grouped by area, limited to the data this user (and key) may see.\n\nAny signed-in user.\n\nScope: `ai:read`.\n\n`GET /ai/suggestions` · operationId `ai.suggestions`"
      },
      "response": [
        {
          "name": "200 Success",
          "originalRequest": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/ai/suggestions",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "ai",
                "suggestions"
              ]
            }
          },
          "status": "Success",
          "code": 200,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json; charset=utf-8"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"message\": \"OK\",\n  \"data\": [\n    {\n      \"area\": \"sales\",\n      \"label\": \"Sales\",\n      \"questions\": [\n        \"How much did we sell this month?\"\n      ]\n    },\n    {\n      \"area\": \"inventory\",\n      \"label\": \"Inventory\",\n      \"questions\": [\n        \"Which products are out of stock?\"\n      ]\n    }\n  ]\n}"
        }
      ]
    }
  ]
}