{"openapi":"3.0.3","info":{"title":"AI Call Center Dashboard Integration Contract","version":"1.0.0","contact":{"name":"Lam","email":"lam@emct.ai"},"description":"Server-to-server API contract that **BDPark Core** must implement so the\nnew **AI Call Center Dashboard** can resolve parking-lot / vehicle data\nand issue gate commands.\n\nAll endpoints in this document are called **Dashboard → BDPark Core**\nover HTTP and are secured with the `x-api-key` header (a pre-shared\nsecret, rotatable through configuration on both sides).\n\n---\n\n## SSO & IdentityServer Integration Requirements\n\nThe HTTP endpoints below cover the BDPark Core integration only.\nThe **AI Call Center Dashboard UI** has a separate dependency on the\nBDPark IdentityServer / SSO platform. The Auth team must complete the\nitems in this section in parallel.\n\n### 1. New OIDC Client registration\n- Register a **new OIDC Client** in BDPark IdentityServer with the\n  display name **\"AI Call Center Dashboard\"**.\n- Grant type: **Authorization Code + PKCE** (public-flow safe;\n  ClientSecret will still be issued for the confidential\n  back-channel exchange).\n- Redirect URIs (per environment): `https://<dashboard-host>/signin-oidc`\n- Post-logout redirect URIs: `https://<dashboard-host>/signout-callback-oidc`\n- Allowed scopes: `openid`, `profile`, `email`, `roles`.\n- Access-token / ID-token lifetime: 8 hours (matches dashboard cookie).\n\n### 2. Audience restriction\n- The Dashboard UI is **restricted to Customer Service Agents** (call-center\n  operators and their supervisors). Only users assigned to the\n  \"Customer Service Agent\" group should be allowed to authenticate\n  against this client.\n- Users outside that group must be rejected by IdentityServer at the\n  consent / login step (do not let them reach the dashboard with a\n  valid cookie).\n\n### 3. CRITICAL — `SysAdmin` role claim\n- The IdentityServer **MUST emit the `SysAdmin` role** as a `role`\n  claim in the issued **JWT / ID token** for every user that holds it.\n- Claim shape — either of the following is acceptable, but the\n  claim **type** must be exactly `role` and the **value** must be\n  exactly `SysAdmin` (case-sensitive):\n\n  ```json\n  { \"role\": \"SysAdmin\" }\n  ```\n\n  or, when a user holds multiple roles:\n\n  ```json\n  { \"role\": [\"CustomerServiceAgent\", \"SysAdmin\"] }\n  ```\n\n- The Dashboard backend authorizes **sensitive actions — most\n  notably remote gate-open commands and ticket-status overrides —\n  with `[Authorize(Roles = \"SysAdmin\")]`**. If this claim is missing\n  or misspelled, those endpoints will return 403 even for legitimate\n  admins, and gate-control will be unusable.\n- Other roles (e.g. `CustomerServiceAgent`, `Supervisor`) may be\n  added later; this document only mandates `SysAdmin`.\n\n### 4. Discovery & metadata\n- Provide the Dashboard team with:\n  - `Authority` URL (the IdentityServer base, e.g. `https://auth.bdapp.kr`)\n  - `ClientId` and `ClientSecret` per environment (dev / staging / prod)\n  - Confirmation that `/.well-known/openid-configuration` is reachable\n    from the Dashboard backend host.\n\n### 5. Logout\n- End-session endpoint must be reachable so the Dashboard can perform\n  RP-initiated logout. After sign-out, IdentityServer should redirect\n  back to the configured `post_logout_redirect_uri`.\n\n---\n\n## Conventions used in this contract\n- All endpoints assume HTTPS in production. The dev URL on the\n  `servers` block is HTTP for the on-prem test instance only.\n- Errors follow the `Error` schema in `components`.\n- Time values, when present, are ISO-8601 UTC.\n"},"servers":[{"url":"http://emct.ddns.net:10007","description":"BDPark Core — on-prem dev instance"},{"url":"https://core.bdpark.example.com","description":"BDPark Core — production (placeholder; Auth team to confirm)"}],"security":[{"ApiKeyAuth":[]}],"tags":[{"name":"ParkingLot","description":"Parking-lot lookup endpoints (used while the call is in progress)."},{"name":"Vehicle","description":"License-plate → location resolution."},{"name":"Gate","description":"Gate command endpoints (open / close / etc.)."}],"paths":{"/api/searchParkinglot":{"get":{"tags":["ParkingLot"],"operationId":"searchParkinglot","summary":"Resolve a candidate parking-lot name to its canonical name.","description":"Called from the Dashboard when the customer mentions a parking-lot\nname during a call. The candidate text comes from speech-to-text\n(Amazon Lex) and may contain phonetic noise; BDPark Core is\nexpected to do fuzzy / dictionary matching and return the\n**canonical** parking-lot name registered in the system.\n\nReturns an empty string body if no match is found.\n","parameters":[{"in":"query","name":"name","required":true,"description":"Candidate parking-lot name as recognised by speech-to-text.","schema":{"type":"string","example":"강남 1주차장"}}],"responses":{"200":{"description":"Canonical parking-lot name (plain text). Empty string if no match.","content":{"text/plain":{"schema":{"type":"string","example":"강남제1주차장"}},"application/json":{"schema":{"type":"string","example":"강남제1주차장"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/vehicle/location":{"get":{"tags":["Vehicle"],"operationId":"findVehicleByLicensePlate","summary":"Locate a vehicle by license plate.","description":"Returns the parking-lot and gate the vehicle is currently\nassociated with. Called immediately after the customer states\ntheir license plate so the Dashboard can pre-fill ticket fields\nand decide which gate to control.\n","parameters":[{"in":"query","name":"licensePlate","required":true,"description":"Korean license plate, normalised to the canonical form expected\nby BDPark Core (the Dashboard performs Lex-side normalisation\nusing a Custom Vocabulary before this call).\n","schema":{"type":"string","example":"12가 3456"}}],"responses":{"200":{"description":"Vehicle resolved successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VehicleLocationResult"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"License plate not found in BDPark Core.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}},"/api/gate/SetCommand":{"post":{"tags":["Gate"],"operationId":"setGateCommand","summary":"Issue a command to a specific gate.","description":"Called by the Dashboard once a Customer Service Agent (or\nSysAdmin) decides to open the gate for a verified vehicle. The\ncommand is fire-and-forget from the Dashboard's perspective —\nBDPark Core is expected to acknowledge synchronously whether the\ncommand was accepted and forwarded to the gate hardware.\n\n**Authorization:** This endpoint will, in practice, only be called\nfor users carrying the `SysAdmin` role on the Dashboard side (see\nthe SSO requirements in `info.description`). BDPark Core is still\nfree to enforce its own checks via the `x-api-key`.\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GateCommandRequest"}}}},"responses":{"200":{"description":"Command accepted and forwarded to the gate.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","description":"True when the gate hardware acknowledged the command.","example":true},"message":{"type":"string","nullable":true,"description":"Optional human-readable detail.","example":"Gate opened"}}}}}},"400":{"description":"Malformed request body or unsupported command.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Gate not found for the supplied id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"$ref":"#/components/responses/InternalError"}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Pre-shared API key for server-to-server traffic between the\nAI Call Center Dashboard and BDPark Core. Distributed out-of-band\nand rotatable through configuration on both sides.\n"}},"responses":{"Unauthorized":{"description":"Missing or invalid `x-api-key` header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"code":"unauthorized","message":"x-api-key is missing or invalid."}}}},"InternalError":{"description":"Unexpected server error inside BDPark Core.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"code":"internal_error","message":"An unexpected error occurred."}}}}},"schemas":{"VehicleLocationResult":{"type":"object","description":"Result of a license-plate → location lookup.","required":["parkingLotId","parkingLotName","gateId","gateName"],"properties":{"parkingLotId":{"type":"integer","format":"int32","description":"Numeric identifier of the parking lot.","example":12},"parkingLotName":{"type":"string","description":"Canonical parking-lot name (same value space as `searchParkinglot`).","example":"강남제1주차장"},"gateId":{"type":"integer","format":"int32","description":"Numeric identifier of the gate the vehicle is associated with.","example":7},"gateName":{"type":"string","description":"Display name of the gate (e.g. `\"입구1\"` / `\"Entrance 1\"`).","example":"입구1"}}},"GateCommandRequest":{"type":"object","description":"Command payload accepted by `POST /api/gate/SetCommand`.","required":["gateId","command"],"properties":{"gateId":{"type":"integer","format":"int32","description":"Numeric identifier of the gate to act on.","example":7},"command":{"type":"string","description":"Command verb. Initial release supports `OPEN`; other verbs are reserved.","enum":["OPEN","CLOSE"],"example":"OPEN"}}},"Error":{"type":"object","description":"Standard error envelope returned by BDPark Core.","required":["code","message"],"properties":{"code":{"type":"string","description":"Machine-readable error code (snake_case).","example":"vehicle_not_found"},"message":{"type":"string","description":"Human-readable error message (English; no PII).","example":"License plate '12가 3456' was not found."},"details":{"type":"object","additionalProperties":true,"nullable":true,"description":"Optional structured context."}}}}}}