Server Integration
Besides typing the UID, nfc-keyboard-emulator can hand every scan to a server you run, and a web app can ask the app for a scan on demand. This is optional and off by default: until you switch a mode on in the Server view, no scan data leaves your computer.
This page is for people who set up a station. If you are building the server side, see the server protocol reference.
The three modes
Section titled “The three modes”Each mode is switched on independently. You can combine them with each other and with typing into the focused field.
| Mode | What it does | Use it when |
|---|---|---|
| HTTP push | Sends one HTTP request to your server for every scan. | Your server only needs to be told about scans and does not need to reach the station. The simplest option. |
| WebSocket: send every scan | Keeps a connection to your server open and sends every scan through it. | Your server should react at once, for example by refreshing the page a user has open. |
| WebSocket: answer scan requests | Over the same connection, the server can ask for the next scan. The next card answers exactly that request. | A user clicks Scan in a web page, for example to register a new tag, and the UID should land in that page. |
The two WebSocket modes share one address and one token. The connection is open while at least one of them is on and a URL is set.
Set up a station
Section titled “Set up a station”- Open the Server view in the sidebar, under Settings.
- Optionally enter a Device name (see below).
- For HTTP push, enter the URL (it must start with
http://orhttps://) and the Token (labelled Password when you choose Basic auth, see below), then switch on Send every scan by HTTP. - For the WebSocket, enter the URL (it must start with
ws://orwss://) and the Token (labelled Password when you choose Basic auth), then switch on Send every scan, Answer scan requests, or both. - If your server needs the token in another place, or expects its own JSON, open Advanced on that target (see Advanced settings).
- Click Test next to each target you set up (see Test your settings).
- Click Save. The button is only active while you have unsaved changes. Settings take effect straight away, without restarting the app.
The token field is masked. Use Show token and Hide token to check what you entered (Show password and Hide password with Basic auth). A token may only contain letters, digits and punctuation from the basic Latin alphabet: no spaces, line breaks or umlauts. Spaces and line breaks around it are removed when you save.
Device name and tokens
Section titled “Device name and tokens”Device name is sent with every scan, and with the hello and test messages, so your server can tell stations apart (for example Reception and Warehouse). If you leave it empty, the computer’s host name is used.
The token is how your server knows which station is talking. By default it is sent as Authorization: Bearer <token> with every HTTP request and when the WebSocket connects. If your server expects it another way, see Advanced settings. Your server issues the tokens, normally one per user or per station, for example from a settings page in your web app. The app does not create, change or check tokens; it only sends the one you entered.
Tokens are saved in the app’s local settings file, so treat that file like a password. See Security & Privacy.
Advanced settings
Section titled “Advanced settings”Each target, HTTP push and WebSocket, has an Advanced section that is closed by default. It opens by itself when something in it differs from the defaults, and its heading then summarises the change, for example Custom header · Custom template. With the defaults, scans go out exactly as described above. The options are set per target, so HTTP push and the WebSocket can differ.
How the token is sent
Section titled “How the token is sent”Choose the option under Authentication. There are five:
| Option | What the app sends | Fields |
|---|---|---|
| Bearer token (default) | Authorization: Bearer <token> | None. |
| Custom header | The token as the value of a header you name, for example X-API-Key: <token>. | Header name, X-API-Key at first. |
| Basic auth | Authorization: Basic …, built from the user name and the token as the password. | Username. The token field is then called Password. |
| URL parameter | The token as a parameter at the end of the address, for example https://example.com/scans?token=<token>. | Parameter name, token at first. |
| None | No credential. | None. |
Things to know:
- For the WebSocket, the header or the parameter belongs to the request that opens the connection, not to a message.
- With an empty token the app sends no credential. The exception is Basic auth, where a user name you entered is still sent.
- A URL parameter is added to the address you entered. Parameters that are already in it stay as they are.
- The fields of the options you are not using are kept, so you can switch back and forth without typing them again.
- Only the field of the selected option is checked. A Header name may contain letters, digits and the characters
! # $ % & ' * + - . ^ _ | ~and the backtick. It may not beHost,Content-Length,Content-Type,Connection,UpgradeorTransfer-Encoding, and may not start withSec-WebSocket-, because the app sets these itself. A Username may only contain visible ASCII characters and no colon. A Parameter name may only contain letters, digits and. _ ~ -, and must not be empty.
Your own JSON format
Section titled “Your own JSON format”By default the app sends its standard scan message. If you already have a server or a webhook that expects another shape, set Payload to Custom template and write the JSON yourself. Switching to Custom template fills in an example that uses all placeholders. Under it, the buttons after Insert put a placeholder at the cursor, and Preview shows the result for an example scan as you type. The preview uses example values: Example values; if the device name is empty, the computer name is sent as the device. If the template is not usable, the preview shows the reason instead, and Save is refused with the same message. That error starts with the target, such as HTTP: Template is not valid JSON or WebSocket: Unknown placeholder: name.
A placeholder is a name in double curly braces, such as {{uid}}. Spaces inside the braces are allowed, so {{ uid }} works too. The app replaces it in every text value of your template:
| Placeholder | Replaced by |
|---|---|
{{uid}} | The card UID: uppercase hex without separators. Use this one for matching. |
{{uidFormatted}} | The UID as your output format renders it (case, separator, byte order, prefix). |
{{uidLength}} | The length of the UID in bytes. |
{{scanId}} | A new unique ID for every scan. |
{{device}} | The device name. |
{{reader}} | The name of the reader that saw the card. |
{{timestamp}} | When the scan happened, in UTC, for example 2026-10-28T13:45:21.123Z. |
For a generic webhook that expects a badge number, a terminal name and a time, the template could be:
{ "badge": "{{uid}}", "terminal": "{{device}}", "time": "{{timestamp}}"}With the device name Reception, your server then receives:
{ "badge": "04A2B3C4D5E6F7", "terminal": "Reception", "time": "2026-10-28T13:45:21.123Z"}Rules for templates:
- The template must be valid JSON and at most 8192 bytes. Other body formats, such as plain text or form fields, are not possible.
- Placeholders are replaced in values, also inside nested objects and lists. They are never replaced in keys.
- Text around a placeholder stays, so
"badge-{{uid}}"becomes"badge-04A2B3C4D5E6F7". - A value that consists of
"{{uidLength}}"and nothing else becomes a number (7), not text. Everywhere else, including"{{uidLength}} bytes", the result is text. - The order of your keys is kept.
- A name that is not in the table is an error: Unknown placeholder: name. The other errors are Template is not valid JSON and Template is larger than 8 KB. Text with braces that does not look like a placeholder, such as
{{}}or{{ 1 }}, is left as it is. - The app sends exactly your JSON. It does not add
typeorprotocolVersion; put them in the template if your server needs them. The HTTP method and the content type stay the same: aPOSTwithContent-Type: application/json.
If a template cannot be applied when a scan is sent, which can only happen after the settings file was edited by hand, the delivery fails with Template could not be applied. For HTTP push no request is made; on the WebSocket no stream frame is sent for that scan, while an answer to a scan request still goes out in the standard format.
Test your settings
Section titled “Test your settings”Each card has a Test button. It uses the values currently in the form, so you can check a connection before you save or switch the mode on. A test is something you start yourself; it is the only server traffic the app sends while a mode is off.
- HTTP push sends a small message of type
testto the URL. Your server should answer with a 2xx status. With a custom template, the test sends the template filled with an example scan instead, so your server sees the shape it will get. - WebSocket connects, sends the
hellomessage and disconnects again. It reports whether the connection and the token were accepted. With a custom template it also sends one example scan, filled in the same way, before it disconnects.
The example scan has the scanId test, the reader Example Reader and a made-up UID, together with your real device name. The test uses the Authentication option you have selected, so it also shows whether the token reaches your server in the right place.
The result appears next to the button: OK, or the reason it failed (see Troubleshooting). Changing any field clears the previous result.
Read the status bar
Section titled “Read the status bar”While the WebSocket is in use, the status bar at the bottom shows a Server entry. The Connection line in the Server view shows the same state.
| Shown | Meaning |
|---|---|
| connecting | The app is opening the connection. |
| connected | The connection is open and the server has been greeted. |
| reconnecting (reason) | The connection dropped or could not be opened. The app tries again by itself, waiting a little longer after each failed attempt, up to a minute. A connection only counts as working again once it has stayed open for 30 seconds, so a server that keeps closing it at once is not retried every second. The reason is one of the messages in the troubleshooting table. |
| token rejected | The server refused the token. The app stops retrying until you change the URL or token, or click Reconnect. |
| waiting for scan | Shown next to the state while a server request is pending: the server has asked for a scan and the next card will answer it. |
If notifications are on, you also get a system notification when a server request arrives (Server is waiting for a scan).
Delivery in the scan log
Section titled “Delivery in the scan log”The Log view has a Server column. Every enabled target gets a small badge per scan: HTTP or WS, followed by … while sending, ✓ when delivered and ✗ when it failed. Hover over a failed badge to see the reason. See Scan Log.
A failed delivery is reported and then dropped. The app does not queue scans or retry them, so a scan that could not be delivered is not sent later.
For the WebSocket, Delivered means the scan was written to an open connection. Version 1 of the protocol has no acknowledgement from the server.
Delivery problems also show up as system notifications, for example Delivery failed, Server connection lost and Server rejected the token. They follow your Notifications setting: shown for Errors only and All scans, hidden for Off. Only one notification is shown when the connection drops, and one when the token is rejected, not one per attempt. If the server keeps accepting the connection and closing it again, you get one Server connection lost notification, and the next one only after the connection has stayed open for 30 seconds.
Import and export settings
Section titled “Import and export settings”The Import and export card at the bottom of the Server view moves your server settings between computers, or lets your server provide a ready-made configuration.
- Export … saves the server settings to a JSON file. The app first warns you: The exported file contains your tokens. Treat it like a password and don’t share it. Click Export anyway to continue.
- Import … reads such a file. Before anything changes, a preview titled Apply server settings? shows the source, the device name, and for each mode whether it will be on or off and which server address it points to, such as
https://example.com. If an address changes, the preview shows the old one crossed out next to the new one, and changed rows are in bold. Tokens are never shown, only whether they stay unchanged, will be set or will be cleared. If the file changes Authentication or Payload of a target, the preview lists the new option, for example Custom header or Custom template, in bold. The template itself is not shown. Click Apply to accept or Cancel to discard.
A highlighted warning at the top of the preview points out three risky changes:
- The stored HTTP token (or WebSocket token) will be sent to address. The import changes the server address but keeps the token you already have, so your token would go to a server it was not issued for. Only apply if you trust that server. The warning does not appear when the target’s Authentication is None, because then no token is sent.
- The stored HTTP token (or WebSocket token) will be sent as a URL parameter from now on and may end up in server or proxy logs. The import switches that target to URL parameter while keeping the token you already have, so it moves into the address, where logs can record it.
- The HTTP connection (or WebSocket connection) will no longer be encrypted. The address changes from
https://tohttp://, or fromwss://tows://, so the token and the scans travel in clear text.
Only server settings are part of the file. Output format, startup options and language are not.
The file the app exports always contains the Authentication and Payload settings of both targets, so it is a full copy of the setup. When a file contains one of them, it replaces that whole setting, not only the fields it names; fields it leaves out go back to their defaults. A file without it leaves the setting as it is. Older versions of the app ignore these settings, so on them the import changes the address and token but still sends the standard format with a bearer token.
If an import fails, the dialog Import failed tells you why:
| Message | Meaning |
|---|---|
| The file is not valid JSON. | The file is damaged or not a JSON file. |
| This is not a server configuration for this app. | The format value is missing or different. |
| This configuration uses version n, which this app does not support. Update the app. | The file was made for a newer version of the format. |
| The HTTP URL must start with http:// or https://. | The HTTP address has another scheme or is malformed. |
| The WebSocket URL must start with ws:// or wss://. | The WebSocket address has another scheme or is malformed. |
| The HTTP token (or WebSocket token) may only contain visible ASCII characters, without spaces or line breaks. | The token contains characters that cannot be sent in an HTTP header. The same message appears when you save such a token in the Server view. |
| HTTP (or WebSocket): Invalid or reserved header name (e.g. Host) | The Custom header name is empty, contains characters a header name may not have, or is one of the headers the app sets itself. |
| The HTTP (or WebSocket) username may only contain visible ASCII characters, without spaces or colons. | The Basic auth username contains a colon, a space or another character that is not visible ASCII. |
| HTTP (or WebSocket): Invalid parameter name | The URL parameter name is empty or contains a character other than letters, digits and . _ ~ -. |
| HTTP (or WebSocket): Template is not valid JSON, Unknown placeholder: name, or Template is larger than 8 KB | The template in the file has the problem named. |
The same messages appear when you click Save in the Server view with such a value. The messages about the header name, parameter name and template then start with the target, as shown above.
The file format is described in the reference, together with a JSON Schema for tools that generate these files.
Configuration links
Section titled “Configuration links”A web app can also configure the app with a link that starts with nfc-keyboard-emulator://configure. Clicking it opens the app, or brings it to the front if it is already running, and shows the same Apply server settings? preview as a file import. Nothing is changed until you click Apply.
If the preview shows a server address you do not recognise, or warns that your stored token would be sent to a new address, click Cancel. A link is just a way to deliver a configuration; it can contain a token, so only open links from sites you trust. If the link is damaged and cannot be decoded, the app shows This link is not a valid server configuration. If it can be decoded but the configuration inside is wrong, you get the same messages as for a file import (see above).
Troubleshooting
Section titled “Troubleshooting”The same messages appear next to the Test buttons, in the log badges, in the connection state and in notifications.
| Message | What it means | What to check |
|---|---|---|
| Invalid server address | The URL cannot be used. | The URL starts with http:// or https:// (HTTP) or ws:// or wss:// (WebSocket) and contains a host name. |
| Server unreachable: reason (origin) | The app could not talk to the server. origin is the address without path or query, such as https://example.com:8443. The reason is listed per transport below. | See the reason table. |
| Server did not answer in time | No answer within 5 seconds (HTTP) or 10 seconds (opening the WebSocket). | The server is overloaded or blocked by a firewall; answer quickly and do slow work afterwards. |
| Token rejected (HTTP 401) or (HTTP 403) | The server refused the token. | The token matches the one your server issued, was not revoked, and was pasted without extra characters. For the WebSocket, the app then stops reconnecting; fix the token or click Reconnect. |
| Server answered with HTTP n | The server answered with a status other than 2xx, 401 or 403. | The URL path is right. A redirect (3xx) is not followed and is reported like this, so enter the final address. 404 usually means a wrong path; 5xx means an error on the server. |
| Not connected to the server | A scan was due on the WebSocket, but the connection was not open. | The state in the status bar. The scan is not queued. |
| Invalid or reserved header name (e.g. Host), The username may only contain visible ASCII characters, without spaces or colons. or Invalid parameter name | Only the Test button shows these. The Authentication field of the selected option is not usable, so the test sent nothing. | Correct the Header name, Username or Parameter name in Advanced as described under How the token is sent. |
| Template could not be applied | The custom template could not be filled for this scan. HTTP push made no request; the WebSocket sent no stream frame (an answer to a scan request still goes out in the standard format). | Open Advanced for that target and check the template. |
Reasons for “Server unreachable”
Section titled “Reasons for “Server unreachable””The text after the colon is a short reason followed by the origin in parentheses, for example Server unreachable: connection refused (https://example.com:8443). Which reasons appear depends on the transport.
| Reason | Transport | What to check |
|---|---|---|
connection refused | HTTP, WebSocket | Nothing is listening at that host and port. Check that the server is running and the port is right. |
dns error | HTTP, WebSocket | The host name could not be resolved. Check the spelling, your network connection and any VPN. |
connection failed | HTTP, WebSocket | The connection could not be opened for another reason: firewalls, proxies, routing. Over https:// it also covers certificate problems (expired, wrong host name, untrusted issuer). |
tls error | WebSocket | The secure connection to a wss:// address could not be set up, for example because of a certificate problem. |
request failed | HTTP | The connection was made but the request failed afterwards, for example because the server closed it. Check the server logs. |
connection closed | WebSocket | The server closed the connection. The app reconnects by itself. |
no response | WebSocket | The connection looked open, but the server stopped answering: nothing came back for more than 40 seconds, not even an answer to the keepalive ping, or a scan could not be sent within 10 seconds. Typical after the computer slept or switched networks. The app reconnects by itself; if it keeps happening, check proxies or firewalls that drop idle connections. |
protocol error | WebSocket | The server did not answer as a WebSocket server should. Check that the URL points to a WebSocket endpoint. |
invalid token characters | WebSocket | The token contains characters that cannot be sent in an HTTP header. Paste the token again without line breaks or special characters. |
Other situations
Section titled “Other situations”A scan reaches the server but is not typed. That is intended when the scan answered a server request. The log status is Answered server request.
A server request arrives but nothing happens when you scan. Check that Answer scan requests is on. If it is off, the app tells the server that the request was not accepted. A request also ends after its time limit (30 seconds unless the server asks for another) and when the server cancels it or sends a newer one.
Nothing is sent at all. HTTP push needs its toggle on and a URL. The WebSocket needs at least one of its two toggles on and a URL. Read errors, where no UID could be read, are never sent.
The server rejects the token although it is right. Check Authentication under Advanced: your server may expect another header, Basic auth or a URL parameter. Test uses the selected option, so you can try each one.
The token shows up in my server’s access log. This happens with URL parameter, because the address is logged. Switch to a header, or set up the server or proxy to leave the parameter out of its logs.
The WebSocket keeps saying reconnecting. The state shows the reason of the last attempt. The app retries after 1 second at first, then waits longer after each failure, up to about a minute. A connection that the server closes again within 30 seconds counts as a failure too. Reconnect starts a new attempt at once.