The Miva Postman collection, Miva: JSON API: Authenticated, has a ready-made request for most JSON API functions, grouped in folders by area. It signs every request for you, so you can try a function and see its response before writing any signing code.
You need an API token with ProductList_Load_Query assigned, and its signing key if the token requires signed requests. See Create an API token.
Import the collection and environment#
- Open the Miva Postman workspace.
- Fork or import the Miva: JSON API: Authenticated collection and the Miva Environment environment into your own Postman workspace.
- Select Miva Environment in the environment menu at the top right of Postman.
Fill in the environment#
Open the environment and set these 4 variables. They’re at the top of the list.
| Variable | Value |
|---|---|
Domain_Name |
Your store’s domain, for example www.example.com. JSON_URL is built from it as https://{{Domain_Name}}/mm5/json.mvc. |
Store_Code |
The code of the store you want to work with |
API_Token |
The access token from Users > API Tokens |
API_SigningKey |
The token’s signing key, exactly as shown in the admin. Leave it empty if the token doesn’t require signed requests. |
If your store uses a folder other than /mm5, change JSON_URL to match.
The rest of the environment holds sample IDs and codes the requests use, such as Product_Code, Order_ID and Customer_Login. Change them to records that exist in your store before running requests that read or change a specific record.
Warning
Keep real tokens and signing keys in your own workspace. Don’t add them to a shared or public workspace, and don’t export an environment with real values in it. API_Token and API_SigningKey are secret variables, so Postman masks them on screen.
Send your first request#
- Open the Getting Started folder at the top of the collection.
- Open ProductList_Load_Query (first request) and click Send.
- A successful response starts with
"success": 1and has one product underdata. See Read the response.
The request has two saved examples, a success and a Function not assigned to token error, so you can see both shapes before you send anything.
If you get access_denied, check the message against Troubleshooting. The most common causes are a function not assigned to the token, an IP address not on the token’s list, and a signing key that doesn’t match the token.
How the collection signs requests#
A pre-request script on the collection runs before every request:
- It reads
API_TokenandAPI_SigningKeyfrom the environment. - It resolves the variables in the request body, including
{{$timestamp}}, which fills inMiva_Request_Timestamp. - It writes the resolved body back to the request, so Postman sends exactly what was signed.
- It calculates an HMAC-SHA256 signature over that body with the Base64-decoded signing key.
- It sets
X-Miva-API-AuthorizationtoMIVA-HMAC-SHA256 <token>:<signature>. WithAPI_SigningKeyempty, it sendsMIVA <token>instead.
These are the same steps your own code has to follow. Make a signed request with HMAC shows them in PHP, Node.js and Python.
Find a request#
The collection’s folders follow the same areas as the function reference. Common starting points:
| Folder | Requests to try |
|---|---|
| Products | ProductList_Load_Query, Product_Insert, Product_Update |
| Orders | OrderList_Load_Query, Order_Create |
| Customers | CustomerList_Load_Query, Customer_Insert |
| Categories | CategoryList_Load_Query, CategoryProductList_Load_Query |
| Order Queues | QueueOrderList_Load_Query and OrderList_Acknowledge, for the order integration workflow |
Requests that insert, update or delete change real store data. Try them on a development store first.
Other Miva collections#
The Miva workspace has 2 more collections. Both use the same Miva Environment, and neither needs an API token.
| Collection | What it’s for | Variables to set |
|---|---|---|
| Miva: Runtime Functions | Public storefront functions (Session_Type: runtime) for the catalog, basket, checkout, customers and wish lists. See Runtime.js. |
Domain_Name, Store_Code, and the shopper’s Session_ID for basket, checkout and wish list requests |
| Miva: X-Miva-Partial-Render | Storefront page requests that return only some items of the page, as HTML or JSON. See Partial Page Render. | Domain_Name, and Product_Code for the product requests |