Skip to content

feat: API key and active status at terminal onboarding - #18

Open
golobitch wants to merge 3 commits into
mainfrom
tadej/terminal-api-keys
Open

golobitch wants to merge 3 commits into
mainfrom
tadej/terminal-api-keys

Conversation

@golobitch

@golobitch golobitch commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A Terminal gets its API Key from Onboarding, and becomes ACTIVE at the same time. ONBOARDED is gone.

 POS API (merchant-pos-api.yaml)
-GET  /v1/terminals/onboard
-POST /v1/terminals/onboard                  # serial number in data.terminalSerialNumber
+GET  /v1/terminals/{serialNumber}/onboard   # + 400, 404, 409
+POST /v1/terminals/{serialNumber}/onboard
   OnboardingResult
-    status: ONBOARDED
+    status: ACTIVE
+    terminalId                              # required; the terminal needs it for /authorize
+    apiKey                                  # required; returned only here
 POST /v1/transactions/authorize
+  403  valid API key, terminal not ACTIVE
+  404  terminalId unknown, or not the terminal of the API key

 FSP API (fsp-onboarding-api.yaml)
-GET  <fsp.onboarding_api>
+GET  <fsp.onboarding_api>?merchantId=…      # the FSP may ignore it

 Admin API (merchant-api.yaml)
+POST /v1/terminals/{terminalId}/reset       # ACTIVE | SUSPENDED -> PROVISIONED, revokes the API key
   Terminal.status
-    ACTIVE | SUSPENDED | REVOKED
+    PROVISIONED | ACTIVE | SUSPENDED | REVOKED
stateDiagram-v2
    [*] --> PROVISIONED: operator creates the terminal
    PROVISIONED --> ACTIVE: onboarding (issues the API key)
    ACTIVE --> SUSPENDED: PATCH
    SUSPENDED --> ACTIVE: PATCH
    ACTIVE --> PROVISIONED: reset (revokes the key)
    SUSPENDED --> PROVISIONED: reset (revokes the key)
    PROVISIONED --> REVOKED: PATCH
    ACTIVE --> REVOKED: PATCH (revokes the key)
    SUSPENDED --> REVOKED: PATCH (revokes the key)
Loading
  • The serial number is in the path so that the Merchant API knows the merchant when it asks the FSP for the fields, and so that it can check a submission against that merchant's current form.
  • definitionToken is no longer described as signed: it carries nothing the server can't recompute at submit time, so it is an opaque form identifier, not a credential. A token that no longer matches the form is a 409.
  • The FSP decides what proof to ask the merchant for and limits attempts. The Merchant API does not verify the merchant itself. An FSP that checks field formats alone lets anyone with a serial number obtain a key that can take payments.
  • A suspended terminal keeps its key and can still call /finalize. /finalize returns 404 when terminalId is not the terminal of the key.

Evidence

  • Before: redocly lint --extends=spec passes on the three files.
    After: it passes on the three files.
  • After: merchant-api's go generate ./internal/api/openapi/... (oapi-codegen) accepts all three. merchant-api does not compile against the result yet: its onboarding handler uses the removed data.terminalSerialNumber, and the new resetTerminal and finalizeTransaction operations have no handlers.

Merge Danger

Door: two-way until a terminal or FSP implements it

Blast Radius: consumers

Breaking for anything that calls /v1/terminals/onboard. The implementation is in review in interledger/merchant-api#231 and needs this change. The cards-devenv portal and validate.sh use the old path. The testnet wallet needs no change, because it may ignore merchantId.

🤖 Generated with Claude Code

Onboarding moves to /v1/terminals/{serialNumber}/onboard, makes the
terminal ACTIVE and returns its API key and terminalId. The ONBOARDED
status is removed. The FSP receives merchantId when it is asked for the
fields.

authorize gains 403 for a terminal that is not ACTIVE and 404 for a
terminalId that is not the terminal of the API key. The admin API gains
POST /v1/terminals/{terminalId}/reset.
@golobitch
golobitch marked this pull request as ready for review November 23, 2026 14:35
The token only carries data the server recomputes at submit time, so
signing it protects nothing. Drop the signature, serial number, expiry
and credential wording; a token that no longer matches the form is 409.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants