{
  "info": {
    "name": "Kelase Edukonten API (sandbox)",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Koleksi dihasilkan dari kontrak OpenAPI (1.0.0-draft.2). Isi variabel koleksi, lalu jalankan \"Ambil access token\" lebih dulu."
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://edukonten.example/partner-api",
      "description": "Host situs deployment sandbox + /partner-api"
    },
    {
      "key": "clientId",
      "value": ""
    },
    {
      "key": "clientSecret",
      "value": "",
      "type": "secret"
    },
    {
      "key": "access_token",
      "value": "",
      "type": "secret"
    },
    {
      "key": "schoolId",
      "value": "SCH-LMS-001"
    },
    {
      "key": "contentId",
      "value": ""
    },
    {
      "key": "sessionId",
      "value": ""
    },
    {
      "key": "deviceId",
      "value": ""
    },
    {
      "key": "parentOrigin",
      "value": "https://lms.partner-anda.example"
    },
    {
      "key": "activationCode",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Ambil access token (client credentials)",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.access_token) pm.collectionVariables.set('access_token', j.access_token);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "description": "Autentikasi HTTP Basic dengan client_id dan client_secret. Token berlaku 15 menit, tanpa refresh token. Backend partner meminta token baru bila habis; secret tidak boleh ada di browser, APK, atau EXE.",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/x-www-form-urlencoded"
          }
        ],
        "auth": {
          "type": "basic",
          "basic": [
            {
              "key": "username",
              "value": "{{clientId}}"
            },
            {
              "key": "password",
              "value": "{{clientSecret}}"
            }
          ]
        },
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            {
              "key": "grant_type",
              "value": "client_credentials"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/oauth/token",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "oauth",
            "token"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Identitas client dan scope token",
      "request": {
        "method": "GET",
        "description": "Identitas client dan scope token",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/me",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "me"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Daftar konten untuk satu sekolah",
      "request": {
        "method": "GET",
        "description": "Hanya konten terbit. Default licensed_only=true. Status akses bersifat indikatif dan tidak menggantikan otorisasi launch.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/contents?external_school_id={{schoolId}}&limit=20",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "contents"
          ],
          "query": [
            {
              "key": "external_school_id",
              "value": "{{schoolId}}"
            },
            {
              "key": "limit",
              "value": "20"
            }
          ]
        }
      }
    },
    {
      "name": "Cari konten",
      "request": {
        "method": "GET",
        "description": "Pencarian tanpa membedakan huruf pada judul, tag, topik, mata pelajaran, dan deskripsi; semua kata harus cocok. Urutan bawaan: relevansi.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/contents/search?external_school_id={{schoolId}}&limit=20&q=terapung",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "contents",
            "search"
          ],
          "query": [
            {
              "key": "external_school_id",
              "value": "{{schoolId}}"
            },
            {
              "key": "limit",
              "value": "20"
            },
            {
              "key": "q",
              "value": "terapung"
            }
          ]
        }
      }
    },
    {
      "name": "Detail konten",
      "request": {
        "method": "GET",
        "description": "Tidak memuat URL aset privat atau URL launch permanen. Gunakan endpoint launch untuk membuka konten.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/contents/{{contentId}}?external_school_id={{schoolId}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "contents",
            "{{contentId}}"
          ],
          "query": [
            {
              "key": "external_school_id",
              "value": "{{schoolId}}"
            }
          ]
        }
      }
    },
    {
      "name": "Periksa hak akses (informasi sementara)",
      "request": {
        "method": "POST",
        "description": "Tidak menerbitkan hak playback; launch memeriksa ulang. Konten tidak ditemukan atau tidak boleh dilihat sekolah: 404. Jalur lisensi perangkat butuh device_id dan device_proof (sekali pakai). Penolakan lisensi berstatus 200 dengan entitled=false dan reason.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"external_school_id\": \"{{schoolId}}\",\n  \"content_id\": \"{{contentId}}\",\n  \"role\": \"teacher\",\n  \"interaction_mode\": \"whole_class\",\n  \"channel\": \"web_iframe\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/v1/entitlements/check",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "entitlements",
            "check"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Daftarkan perangkat",
      "request": {
        "method": "POST",
        "description": "Memakai kode aktivasi sekali pakai milik sekolah. Pendaftaran ulang instalasi yang sama dengan kunci yang sama idempoten (200) dan tidak mengambil slot. Kunci privat tidak pernah dikirim.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"external_school_id\": \"{{schoolId}}\",\n  \"installation_id\": \"{{$guid}}\",\n  \"activation_code\": \"{{activationCode}}\",\n  \"public_key\": \"public_key\",\n  \"platform\": \"platform\",\n  \"device_type\": \"device_type\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/v1/devices/register",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "devices",
            "register"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Minta challenge bukti perangkat",
      "request": {
        "method": "POST",
        "description": "Challenge berlaku 120 detik, terikat ke konteks (sekolah, konten, role, mode) dan sekali pakai. Pesan yang ditandatangani: edukonten-device-proof-v1, challenge_id, nonce, audience, device_id, expires_at (Unix ms), context_hash, dipisah baris baru.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"external_school_id\": \"{{schoolId}}\",\n  \"content_id\": \"{{contentId}}\",\n  \"role\": \"teacher\",\n  \"interaction_mode\": \"whole_class\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/v1/devices/{{deviceId}}/challenge",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "devices",
            "{{deviceId}}",
            "challenge"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Buka konten (menerbitkan tiket launch)",
      "request": {
        "method": "POST",
        "description": "Header Idempotency-Key wajib. Menerbitkan sesi dan tiket sekali pakai (berlaku 120 detik) di fragment launch_url. Pengulangan dengan key dan payload yang sama mengembalikan tiket yang sama selama belum ditebus; sesudah itu 409 TICKET_ALREADY_USED, dan partner meminta launch baru dengan key baru. Penolakan lisensi: 403 dengan error.reason. Kuota sesi paket: 409 SESSION_LIMIT_REACHED.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          },
          {
            "key": "Idempotency-Key",
            "value": "{{$guid}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"external_school_id\": \"{{schoolId}}\",\n  \"external_user_id\": \"guru-contoh-1\",\n  \"role\": \"teacher\",\n  \"context\": {\n    \"interaction_mode\": \"whole_class\"\n  },\n  \"display\": {\n    \"mode\": \"web_iframe\",\n    \"parent_origin\": \"{{parentOrigin}}\"\n  }\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/v1/contents/{{contentId}}/launch",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "contents",
            "{{contentId}}",
            "launch"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Catat event penggunaan",
      "request": {
        "method": "POST",
        "description": "Partner, sekolah, perangkat, dan konten diturunkan dari sesi (bukan dari badan). Sesi harus sudah dimulai (tiket ditebus). Event adalah telemetri dan tidak memberi hak akses. Mark bersifat monoton: opened dan read hanya sekali per sesi. Header Idempotency-Key bila ada harus sama dengan event_id.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"event_id\": \"{{$guid}}\",\n  \"event_type\": \"content.opened\",\n  \"session_id\": \"{{sessionId}}\",\n  \"content_id\": \"{{contentId}}\",\n  \"occurred_at\": \"{{$isoTimestamp}}\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{baseUrl}}/v1/content-events",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "content-events"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Status mark sesi",
      "request": {
        "method": "GET",
        "description": "opened_at dan read_at (nullable). Sesi tenant lain: 404.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/sessions/{{sessionId}}/marks",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "sessions",
            "{{sessionId}}",
            "marks"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Tutup sesi",
      "request": {
        "method": "POST",
        "description": "Idempoten. Sesi milik tenant lain: 404.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/sessions/{{sessionId}}/close",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "sessions",
            "{{sessionId}}",
            "close"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Status perangkat",
      "request": {
        "method": "GET",
        "description": "Status perangkat",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/devices/{{deviceId}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "devices",
            "{{deviceId}}"
          ],
          "query": []
        }
      }
    },
    {
      "name": "Cabut registrasi perangkat",
      "request": {
        "method": "POST",
        "description": "Permintaan launch dan penebusan baru dari perangkat ini ditolak.",
        "header": [
          {
            "key": "Authorization",
            "value": "Bearer {{access_token}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/v1/devices/{{deviceId}}/revoke",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "v1",
            "devices",
            "{{deviceId}}",
            "revoke"
          ],
          "query": []
        }
      }
    }
  ]
}