Sign and check BizPrint Print API requests with the signing tool
This page shows you how to use the BizPrint signing tool, a small command-line program published on npm as @bizswoop/print-sign-request-cli. It is for developers who call the BizPrint Print API over plain HTTP and want to sign a request by hand, or check a signature that the API rejects.
The tool does the same signing as described in Sign BizPrint Print API requests. It is a help for testing and debugging. Your own server still signs the requests your app sends. If your server runs Node.js, it can sign them with the SDK. See Use the BizPrint Node.js SDK to create and check print jobs.
Before you start
Section titled “Before you start”- Install Node.js 20.19 or later on your own computer. The tool runs with
npx, which comes with Node.js. - Have the Public Key and Secret Key of an application that uses the REST API. See Get API keys for the BizPrint Print API.
- Run the tool only on a computer you trust. You type the Secret Key into the terminal and it shows on screen. Do not run it while you share your screen, and never paste the Secret Key into a ticket, chat or email.
Start the tool
Section titled “Start the tool”-
Open a terminal.
-
Run this command:
Terminal window npx @bizswoop/print-sign-request-cli -
Confirm the install if
npxasks. The tool asks What do you want to do? -
Use the arrow keys to choose one of the options.
-
Press Enter.
| Option | What it does |
|---|---|
| Make a get request | Signs the query string for a GET request. |
| Make a post request | Signs a JSON body for a POST request. |
| Validate a get request | Checks the hash in a signed query string. |
| Validate a post request | Checks the hash in a signed JSON body. |
Sign a GET request
Section titled “Sign a GET request”-
Choose Make a get request.
-
Type your Public Key at Public key.
-
Type your Secret Key at Secret key.
-
Paste the request address, or only its query string, at Enter Request URL or query string. For example:
https://print.bizswoop.app/api/connect-application/v1/printers?perPage=10&page=1 -
Answer Update time? with Yes (the default). The tool sets
timeto the current time. -
Copy the query string the tool prints. It has your parameters plus
publicKey,timeandhash. -
Send the request to the same path with that query string, for example
https://print.bizswoop.app/api/connect-application/v1/printers?followed by the copied text.
Send the signed request within a few minutes. The API checks time and rejects requests that are too old. If you change any parameter after signing, sign it again.
Sign a POST request
Section titled “Sign a POST request”-
Choose Make a post request.
-
Type your Public Key at Public key.
-
Type your Secret Key at Secret key.
-
Answer Update time? with Yes (the default).
-
Press Enter at Enter JSON payload. Your terminal’s default text editor opens. To use a different editor, set the
EDITORenvironment variable before you start the tool. -
Type the JSON body, for example:
{"printerId": YOUR_PRINTER_ID,"url": "https://example.com/receipts/1001.pdf?token=LONG_RANDOM_TOKEN","description": "Order 1001"}Replace
YOUR_PRINTER_IDwith the ID of your printer, as a number without quotes. -
Save the file.
-
Close the editor.
-
Copy the JSON the tool prints. It is your body plus
publicKey,timeandhash. -
Send it as the body of the
POSTrequest, exactly as printed, with the headerContent-Type: application/json.
Check a signature
Section titled “Check a signature”Use the validate options when the API answers ERR_UNAUTHORIZED and you want to know whether the signature is the problem.
- Choose Validate a get request or Validate a post request.
- Type your Secret Key at Secret key.
- Paste the signed query string or address for a get request, or paste the signed JSON body into the editor for a post request.
- Save the file, if you used the editor.
- Close the editor.
- Read the result.
| Result | What it means |
|---|---|
| Valid | The hash matches the rest of the request and your Secret Key. If the API still rejects it, check that the Public Key belongs to the same application and that time is recent. |
| Invalid (hash mismatch), expected … got … | The hash does not match. Common causes: the wrong Secret Key, or a parameter or field that changed after signing, including the order of the fields. |
| Invalid, missing arguments: … | The request is missing time, publicKey or hash. |
You can also use Validate a post request to check a webhook body that BizPrint sent you, because webhooks are signed the same way. See Receive print job updates from BizPrint with webhooks.
Related pages
Section titled “Related pages”- Sign BizPrint Print API requests
- BizPrint Print API error codes and how to fix them
- Create a print job with the BizPrint Print API
- Receive print job updates from BizPrint with webhooks
Need help? Contact BizPrint support at https://getbizprint.com/support/.