{
  "info": {
    "_postman_id": "25d28904-bbaf-54e3-a77d-546860eb0f44",
    "name": "POS GROVE POS API — Authentication",
    "description": "Get an access token with a username and password, or use an API key created in Online store > API & Webhooks. Send either as `Authorization: Bearer <token>` (API keys may also use `X-API-Key`).\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": "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": "Current user and credential",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/auth/me",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "auth",
            "me"
          ]
        },
        "description": "The user the request acts as, their permissions, and the credential used (type, name, scopes, expiry).\n\nAny signed-in user.\n\nScope: `auth:read`.\n\n`GET /auth/me` · operationId `auth.me`"
      },
      "response": [
        {
          "name": "200 Success",
          "originalRequest": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/me",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "me"
              ]
            }
          },
          "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    \"user\": {\n      \"id\": \"66f1c2a9e4b0a1b2c3d4e502\",\n      \"username\": \"jane\",\n      \"name\": \"Jane Doe\",\n      \"email\": \"jane@example.com\",\n      \"storeId\": \"66f1c2a9e4b0a1b2c3d4e501\",\n      \"storeName\": \"Main Street\",\n      \"isSuperAdmin\": false,\n      \"permissions\": {\n        \"pos\": {\n          \"pos\": \"1\",\n          \"products\": \"1\",\n          \"sales\": \"1\"\n        },\n        \"crm\": {\n          \"customers\": \"1\"\n        }\n      },\n      \"twoFactorEnabled\": true\n    },\n    \"credential\": {\n      \"type\": \"token\",\n      \"id\": \"66f1c2a9e4b0a1b2c3d4e517\",\n      \"name\": \"Warehouse scanner\",\n      \"scopes\": [\n        \"*\"\n      ],\n      \"expiresAt\": \"2026-10-02T21:30:00.000Z\"\n    }\n  }\n}"
        }
      ]
    },
    {
      "name": "List your access tokens",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/auth/tokens",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "auth",
            "tokens"
          ],
          "query": [
            {
              "key": "page",
              "value": "1",
              "description": "Page number (starts at 1).",
              "disabled": true
            },
            {
              "key": "limit",
              "value": "25",
              "description": "Items per page (max 100).",
              "disabled": true
            },
            {
              "key": "sort",
              "value": "",
              "description": "Comma-separated fields; prefix with - for descending. Example: -createdAt,name",
              "disabled": true
            },
            {
              "key": "fields",
              "value": "",
              "description": "Comma-separated fields to return. Example: id,name,status",
              "disabled": true
            }
          ]
        },
        "description": "Tokens you created with /auth/token (not their values).\n\nAny signed-in user.\n\nScope: `auth:read`.\n\n`GET /auth/tokens` · operationId `auth.tokens.list`"
      },
      "response": [
        {
          "name": "200 Success",
          "originalRequest": {
            "method": "GET",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/tokens",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "tokens"
              ],
              "query": [
                {
                  "key": "page",
                  "value": "1",
                  "description": "Page number (starts at 1).",
                  "disabled": true
                },
                {
                  "key": "limit",
                  "value": "25",
                  "description": "Items per page (max 100).",
                  "disabled": true
                },
                {
                  "key": "sort",
                  "value": "",
                  "description": "Comma-separated fields; prefix with - for descending. Example: -createdAt,name",
                  "disabled": true
                },
                {
                  "key": "fields",
                  "value": "",
                  "description": "Comma-separated fields to return. Example: id,name,status",
                  "disabled": true
                }
              ]
            }
          },
          "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      \"id\": \"66f1c2a9e4b0a1b2c3d4e517\",\n      \"name\": \"Warehouse scanner\",\n      \"scopes\": [\n        \"*\"\n      ],\n      \"createdAt\": \"2026-10-01T09:30:00.000Z\",\n      \"expiresAt\": \"2026-10-02T21:30:00.000Z\",\n      \"lastUsedAt\": \"2026-10-02T14:05:00.000Z\",\n      \"lastIp\": \"102.89.1.20\",\n      \"revoked\": false,\n      \"current\": true\n    }\n  ]\n}"
        }
      ]
    },
    {
      "name": "Revoke one of your tokens",
      "request": {
        "method": "DELETE",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/auth/tokens/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "auth",
            "tokens",
            ":id"
          ],
          "variable": [
            {
              "key": "id",
              "value": "",
              "description": "Pattern: ^([a-f0-9]{24}|current)$"
            }
          ]
        },
        "description": "Revoked tokens stop working at once. Use the id `current` to revoke the token making the request (sign out).\n\nAny signed-in user.\n\nScope: `auth:read`.\n\n`DELETE /auth/tokens/{id}` · operationId `auth.tokens.revoke`"
      },
      "response": [
        {
          "name": "200 Success",
          "originalRequest": {
            "method": "DELETE",
            "header": [
              {
                "key": "Accept",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/auth/tokens/:id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "auth",
                "tokens",
                ":id"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "",
                  "description": "Pattern: ^([a-f0-9]{24}|current)$"
                }
              ]
            }
          },
          "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    \"id\": \"66f1c2a9e4b0a1b2c3d4e517\",\n    \"revoked\": true\n  }\n}"
        }
      ]
    }
  ]
}