{
  "info": {
    "name": "APIBASE",
    "description": "Complete API collection for APIBASE — Personal API and HIVE Gateway. Set your variables before use.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "base_url",   "value": "https://apibase.work", "type": "string" },
    { "key": "token",      "value": "YOUR_FULL_TOKEN",      "type": "string" },
    { "key": "hive_token", "value": "YOUR_HIVE_TOKEN",      "type": "string" },
    { "key": "basekey",    "value": "pierre",               "type": "string" },
    { "key": "tablename",  "value": "orders",               "type": "string" },
    { "key": "T",          "value": "2",                    "type": "string" },
    { "key": "L",          "value": "1",                    "type": "string" },
    { "key": "C",          "value": "2",                    "type": "string" }
  ],
  "item": [

    {
      "name": "Schema",
      "item": [
        {
          "name": "All tables (owner)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/schema",
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Returns all tables you own — T id, row count, min_id."
          }
        },
        {
          "name": "Table columns (owner)",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/schema/{{tablename}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Returns C ids and column names for one table."
          }
        },
        {
          "name": "All tables — HIVE",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/hive/schema/{{basekey}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{hive_token}}" }],
            "description": "Tables this worker can read — filtered by ACL."
          }
        },
        {
          "name": "Table columns — HIVE",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/hive/schema/{{basekey}}/{{tablename}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{hive_token}}" }],
            "description": "Columns for one table. Returns 403 if not in worker ACL."
          }
        }
      ]
    },

    {
      "name": "Personal API",
      "description": "Full access to your own BASE. Token selects the BASE automatically.",
      "item": [
        {
          "name": "Read all records",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/get/T{{T}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Returns all records from table T."
          }
        },
        {
          "name": "Read one record",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/get/T{{T}}/L{{L}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Returns one record by line id."
          }
        },
        {
          "name": "Read one cell",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/api/get/T{{T}}/L{{L}}/C{{C}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Returns the value of a single cell."
          }
        },
        {
          "name": "Read one cell (raw)",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/api/get/T{{T}}/L{{L}}/C{{C}}?format=raw",
              "query": [{ "key": "format", "value": "raw" }]
            },
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Returns the raw cell value without JSON wrapper."
          }
        },
        {
          "name": "Filter records",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/api/get/T{{T}}/L/C{{C}}/O1?V=shipped",
              "query": [{ "key": "V", "value": "shipped" }]
            },
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Returns records where C equals V. O1 = equals operator."
          }
        },
        {
          "name": "Create record",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/api/post/T{{T}}",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{token}}" },
              { "key": "Content-Type",   "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"record\": {\n    \"title\": \"Example\"\n  }\n}"
            },
            "description": "Creates a new record in table T."
          }
        },
        {
          "name": "Update record",
          "request": {
            "method": "PUT",
            "url": "{{base_url}}/api/put/T{{T}}/L{{L}}",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{token}}" },
              { "key": "Content-Type",   "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"record\": {\n    \"status\": \"shipped\"\n  }\n}"
            },
            "description": "Updates one record by line id."
          }
        },
        {
          "name": "Delete record",
          "request": {
            "method": "DELETE",
            "url": "{{base_url}}/api/delete/T{{T}}/L{{L}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{token}}" }],
            "description": "Deletes one record by line id."
          }
        }
      ]
    },

    {
      "name": "HIVE Gateway",
      "description": "Collaboration access to a shared BASE. Requires a hive-scope token and matching ACL.",
      "item": [
        {
          "name": "Read all records",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/hive/get/{{basekey}}/T{{T}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{hive_token}}" }],
            "description": "Returns all readable records from table T in the shared BASE."
          }
        },
        {
          "name": "Read one record",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/hive/get/{{basekey}}/T{{T}}/L{{L}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{hive_token}}" }],
            "description": "Returns one record by line id."
          }
        },
        {
          "name": "Read one cell",
          "request": {
            "method": "GET",
            "url": "{{base_url}}/hive/get/{{basekey}}/T{{T}}/L{{L}}/C{{C}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{hive_token}}" }],
            "description": "Returns the value of a single cell."
          }
        },
        {
          "name": "Filter records",
          "request": {
            "method": "GET",
            "url": {
              "raw": "{{base_url}}/hive/get/{{basekey}}/T{{T}}/L/C{{C}}/O1?V=shipped",
              "query": [{ "key": "V", "value": "shipped" }]
            },
            "header": [{ "key": "Authorization", "value": "Bearer {{hive_token}}" }],
            "description": "Returns records where C equals V."
          }
        },
        {
          "name": "Create record",
          "request": {
            "method": "POST",
            "url": "{{base_url}}/hive/post/{{basekey}}/T{{T}}",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{hive_token}}" },
              { "key": "Content-Type",   "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"record\": {\n    \"title\": \"Example\"\n  }\n}"
            },
            "description": "Creates a record in the shared BASE. Requires add ACL."
          }
        },
        {
          "name": "Update record",
          "request": {
            "method": "PUT",
            "url": "{{base_url}}/hive/put/{{basekey}}/T{{T}}/L{{L}}",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{hive_token}}" },
              { "key": "Content-Type",   "value": "application/json" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"record\": {\n    \"status\": \"shipped\"\n  }\n}"
            },
            "description": "Updates a record in the shared BASE. Requires edit ACL."
          }
        },
        {
          "name": "Delete record",
          "request": {
            "method": "DELETE",
            "url": "{{base_url}}/hive/delete/{{basekey}}/T{{T}}/L{{L}}",
            "header": [{ "key": "Authorization", "value": "Bearer {{hive_token}}" }],
            "description": "Deletes a record in the shared BASE. Requires delete ACL."
          }
        }
      ]
    }

  ]
}
