{
  "info": {
    "_postman_id": "73980500-d532-4ed7-b691-6064b4a68f82",
    "name": "connectX Admin API v3",
    "description": "1. Set connectx_url, admin_email, admin_password in Variables. 2. Run Login (saves admin_token). 3. Use any request. Admins: super admin only.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "id": "83d7e9e5-c242-4f65-9946-862463ae6b03",
      "name": "Login",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/login",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{admin_email}}\",\n  \"password\": \"{{admin_password}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "Saves admin_token (valid 8 hours) for every other request."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "id": "7704104a-b57b-441f-a2ea-ca8bb47657b6",
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.token) { pm.collectionVariables.set('admin_token', j.token); console.log('Logged in as', j.admin.email, j.admin.role); }"
            ]
          }
        }
      ]
    },
    {
      "id": "41ec4a5e-49f2-4900-bbdf-d45a75183752",
      "name": "My account",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/me"
      },
      "response": []
    },
    {
      "id": "c759b5c4-1ba8-4dcc-a103-46c2aca47c4a",
      "name": "Change my password",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/me/password",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"current_password\": \"\",\n  \"new_password\": \"\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "Returns a new token (saved); other sessions are logged out."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "id": "f70c8fcb-405d-4f85-b5f9-f10dad4a8e1a",
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.token) pm.collectionVariables.set('admin_token', j.token);"
            ]
          }
        }
      ]
    },
    {
      "id": "123b2848-ffca-4a41-a06f-249d1771136c",
      "name": "Clients: List clients",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients"
      },
      "response": []
    },
    {
      "id": "b0c58f9e-6c19-4d46-8302-607c98cb5cb1",
      "name": "Clients: Add client",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"Reseller A\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "Returns the new client's api_key (GET shows it again later). Saves client_id."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "id": "686644fe-4be7-4b81-b924-1b2056278036",
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.client && j.client.id) pm.collectionVariables.set('client_id', String(j.client.id));",
              "if (j.api_key) console.log('api_key:', j.api_key);"
            ]
          }
        }
      ]
    },
    {
      "id": "f4908fc5-689c-4bdd-90f6-ab76ea5f1333",
      "name": "Clients: Get client",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}"
      },
      "response": []
    },
    {
      "id": "9b24607f-a684-4264-bd4b-570bd43c465e",
      "name": "Clients: Update client",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"Reseller A Pvt Ltd\",\n  \"status\": 1\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": []
    },
    {
      "id": "0f563080-faf2-407b-90d2-0a064a4e9c20",
      "name": "Clients: Rotate API key",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/rotate-key",
        "body": {
          "mode": "raw",
          "raw": "{}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "Old key stops working. Returns the new api_key."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "id": "ef15fed5-9f74-490c-ae40-73593b4e7a8f",
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.client && j.client.id) pm.collectionVariables.set('client_id', String(j.client.id));",
              "if (j.api_key) console.log('api_key:', j.api_key);"
            ]
          }
        }
      ]
    },
    {
      "id": "40524f90-698e-434f-a4e9-2434b70c5550",
      "name": "Clients: Add or update TBO",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/suppliers/TBO",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"is_active\": true,\n  \"credentials\": {\n    \"username\": \"<TBO username>\",\n    \"password\": \"<TBO password>\"\n  },\n  \"settings\": {\n    \"search_url\": \"https://example/HotelAPI/Search\",\n    \"prebook_url\": \"https://example/HotelAPI/PreBook\",\n    \"book_url\": \"https://example/rest/Book\",\n    \"cancel_url\": \"https://example/HotelAPI/Cancel\",\n    \"voucher_url\": \"https://example/HotelAPI/rest/GenerateVoucher\",\n    \"end_user_ip\": \"103.80.161.62\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": []
    },
    {
      "id": "20c9bea3-e49c-4f5e-9c1e-c957eb73dfed",
      "name": "Clients: Add or update GRN",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/suppliers/GRN",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"is_active\": true,\n  \"credentials\": {\n    \"api_key\": \"<GRN api key>\"\n  },\n  \"settings\": {\n    \"base_url\": \"https://api-sandbox.grnconnect.com\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": []
    },
    {
      "id": "67713949-3cd8-4850-83a9-26ae7874d3ae",
      "name": "Clients: Add or update BW",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/suppliers/BW",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"is_active\": true\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": []
    },
    {
      "id": "02b02269-b994-459e-964a-93c54a095e27",
      "name": "Clients: TBO from .env.tbo",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/suppliers/TBO",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"import_from_env\": true\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": []
    },
    {
      "id": "8d054f83-9939-4552-a09a-f86422891523",
      "name": "Clients: GRN from .env.grn",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/suppliers/GRN",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"import_from_env\": true\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": []
    },
    {
      "id": "2e7f15cb-193e-4426-853d-4f1873c560aa",
      "name": "Clients: Switch TBO off",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/suppliers/TBO",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"is_active\": false\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "response": []
    },
    {
      "id": "cc683a79-b605-41c2-8526-95640539786d",
      "name": "Clients: Delete TBO supplier",
      "request": {
        "method": "DELETE",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}/suppliers/TBO"
      },
      "response": []
    },
    {
      "id": "4fadab7f-17e4-43dd-acf3-ab361ec26c3c",
      "name": "Clients: Delete client",
      "request": {
        "method": "DELETE",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/clients/{{client_id}}",
        "description": "Also deletes its supplier rows. Prefer status 0."
      },
      "response": []
    },
    {
      "id": "8bfe3354-58b2-40e5-bb7a-af2ede54ef85",
      "name": "Admins: List",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/admins",
        "description": "Super admin only."
      },
      "response": []
    },
    {
      "id": "adcdc21d-037d-49b9-ba64-86c47cf46597",
      "name": "Admins: Add",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/admins",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"Ops User\",\n  \"email\": \"ops@example.com\",\n  \"password\": \"change-me-123\",\n  \"role\": \"admin\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "Super admin only. role: super_admin or admin."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "id": "2464fe97-5e1a-4d48-83f3-88454edb5b6b",
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.admin) pm.collectionVariables.set('admin_id', String(j.admin.id));"
            ]
          }
        }
      ]
    },
    {
      "id": "e42c6549-2c0f-4c20-9fb3-56325c9349b4",
      "name": "Admins: Get",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/admins/{{admin_id}}"
      },
      "response": []
    },
    {
      "id": "ef460f82-c4e2-4331-ba6d-96fe039ab3a8",
      "name": "Admins: Update",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/admins/{{admin_id}}",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"name\": \"Ops User\",\n  \"role\": \"admin\",\n  \"status\": 1\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "Any of name, email, role, status (0 disables and logs them out)."
      },
      "response": []
    },
    {
      "id": "b502c561-e7c3-4545-a463-66d356c1ee7f",
      "name": "Admins: Reset password",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/admins/{{admin_id}}/password",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"new_password\": \"new-pass-123\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "description": "Also unlocks the account and logs them out."
      },
      "response": []
    },
    {
      "id": "867cfcd9-18c3-4a99-bb7a-2855d11a35c4",
      "name": "Admins: Delete",
      "request": {
        "method": "DELETE",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{admin_token}}",
            "type": "text"
          }
        ],
        "url": "{{connectx_url}}/admin/admins/{{admin_id}}"
      },
      "response": []
    }
  ],
  "variable": [
    {
      "key": "connectx_url",
      "value": "http://<connectx-host>:3304",
      "type": "string"
    },
    {
      "key": "client_id",
      "value": "1",
      "type": "string"
    },
    {
      "key": "admin_email",
      "value": "",
      "type": "string"
    },
    {
      "key": "admin_password",
      "value": "",
      "type": "string"
    },
    {
      "key": "admin_token",
      "value": "",
      "type": "string"
    },
    {
      "key": "admin_id",
      "value": "",
      "type": "string"
    }
  ]
}