Skip to content

Authentication and Examples ​

This page explains how to send credentials with each API call, how scopes control permissions, and provides ready-to-run curl, Python, Node.js, and Java examples.

Request Headers ​

The VMWMS Open API does not require request signing. Just send the Key and Secret in the HTTPS headers of every request.

HeaderRequiredDescription
x-api-keyYesThe public Key (starts with vmk_live_). You can also use the combined form <Key>.<Secret>, in which case x-api-secret can be omitted
x-api-secretOne of the twoThe Secret. Use either this or the combined form; if both are sent, this header takes precedence
Content-TypeRequired for write endpointsapplication/json
X-Request-IdNoYour own request ID (up to 64 characters), echoed back in the response headers. If omitted, the server generates one. Include it when contacting technical support
hytx-api-keyLegacy protocol onlyUsed only on the legacy-compatible path /api/wh/**. See Legacy-Compatible Protocol

The three forms are equivalent:

bash
# Form 1: Key and Secret sent separately (recommended)
curl https://api.vmwms.com/open-api/v1/ping \
  -H "x-api-key: <YOUR_API_KEY>" -H "x-api-secret: <YOUR_API_SECRET>"

# Form 2: combined
curl https://api.vmwms.com/open-api/v1/ping \
  -H "x-api-key: <YOUR_API_KEY>.<YOUR_API_SECRET>"

# Form 3: for the legacy-compatible path only
curl https://api.vmwms.com/api/wh/bizWhWorkOrder/query/my/wh \
  -H "hytx-api-key: <YOUR_API_KEY>.<YOUR_API_SECRET>"

Protect your Secret

Treat the Secret like an account password. Store and use it only on your server. Never put it in front-end pages, app packages, or public code repositories. If you suspect a leak, Rotate or Revoke the Key in OMS immediately.

Authentication Check Order ​

The server checks the following in order. The first check that fails returns the corresponding HTTP status code (not 200):

OrderCheckOn failure
1Is a Key present?401 "Missing x-api-key" (缺少 x-api-key)
2Authentication failures per minute from the same IPAfter 30 failures, 429 "Too many authentication failures, please try again later" (鉴权失败次数过多,请稍后再试)
3Are the Key / Secret correct, not revoked or expired, and does the account still have permission?401 "API Key is invalid, revoked, expired, or its holder no longer has permission" (API Key 无效、已吊销、已过期,或持有人已无权限)
4Does the Key type match the endpoint?403
5Is the path well-formed (no suspicious patterns such as ;, //, ..)?403
6Is a read-only Key calling a write endpoint?403 "A read-only API Key cannot call write endpoints" (只读 API Key 不能调用写接口)
7Calls per minute429 "Too many requests; the API Key's limit of N per minute has been exceeded" (请求过于频繁,已超过该 API Key 每分钟 N 次的上限)
8Scope403 "The current API Key is not authorized for scope: xxx" (当前 API Key 未授权能力域:xxx)

For security reasons, a 401 does not tell you which item is wrong. Check each item against Error Codes and Troubleshooting.

Scopes ​

Every endpoint belongs to a scope. Keys created in OMS have all scopes (*) by default, so you usually do not need to think about this. If you receive an "not authorized for scope" error, the Key's scopes have been restricted; contact the platform to adjust them, or use a different Key.

scopeEndpoints covered
oms:read / oms:write/open-api/v1/oms/** (orders, inbound forecasts, products, Webhooks, OMS inventory); most SKU, inventory, and inbound forecast endpoints of the legacy protocol
outbound:read / outbound:write/open-api/v1/outbound/**; creating, querying, and revoking dropship and self-pickup orders in the legacy protocol
inbound:read/open-api/v1/inbound/expected
inventory:read/open-api/v1/inventory/**
product:read/open-api/v1/sku/**
warehouse:read/open-api/v1/warehouse/**
location:read/open-api/v1/location/**
customer:read/open-api/v1/customer/**
*All
None required/open-api/v1/ping and /open-api/v1/whoami; any valid Key can call them

Rules:

  • Write permission implies read permission in the same domain. For example, a Key with oms:write can call oms:read endpoints.
  • "Read-only" and scope are two independent gates: a read-only Key cannot call write endpoints even if it has oms:write.

Basic Endpoints ​

Connectivity Check ​

GET /open-api/v1/ping. Any valid Key can call it; data returns "pong".

Query the Current Identity ​

GET /open-api/v1/whoami. Call it first when onboarding to verify the authorization scope and available warehouses.

Response fieldDescription
apiKeyThe current Key
ownerTypeCUSTOMER for a customer (cargo owner); COMPANY_OWNER / WH_MANAGER for warehouse-side Keys
accountThe login account of the Key holder
customerIdCustomer ID (customer Keys)
warehouseIdsList of currently visible warehouse IDs
readOnlyWhether the Key is read-only
scopesScopes
json
{
  "code": 200,
  "msg": "操作成功",
  "data": {
    "apiKey": "vmk_live_0123456789abcdef01234567",
    "ownerType": "CUSTOMER",
    "account": "demo_customer",
    "customerId": "1800000000000000001",
    "warehouseIds": ["1800000000000000101"],
    "readOnly": false,
    "scopes": ["*"]
  }
}

Call Examples ​

The examples below demonstrate a connectivity check, order queries, and more. Replace <YOUR_API_KEY> and <YOUR_API_SECRET> with your own values to run them. We recommend passing credentials through environment variables.

curl ​

bash
export VMWMS_KEY="<YOUR_API_KEY>"
export VMWMS_SECRET="<YOUR_API_SECRET>"

# GET: query order status
curl -s "https://api.vmwms.com/open-api/v1/oms/orders/PO-TEST-0001" \
  -H "x-api-key: $VMWMS_KEY" -H "x-api-secret: $VMWMS_SECRET"

# POST: create a product (endpoints with a JSON body need Content-Type)
curl -s -X POST "https://api.vmwms.com/open-api/v1/oms/products" \
  -H "x-api-key: $VMWMS_KEY" -H "x-api-secret: $VMWMS_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"skuCode":"SKU-A001","productName":"Desk Lamp","declarePrice":19.9,"sizeUnit":1,"weight":1.2,"length":30,"width":20,"height":15}'

Python (requests) ​

python
import os
import requests

BASE = "https://api.vmwms.com"
session = requests.Session()
session.headers.update({
    "x-api-key": os.environ["VMWMS_KEY"],
    "x-api-secret": os.environ["VMWMS_SECRET"],
})


def call(method, path, **kwargs):
    resp = session.request(method, BASE + path, timeout=30, **kwargs)
    # Authentication / permission / rate-limit failures return real 401 / 403 / 429
    if resp.status_code in (401, 403, 429):
        raise RuntimeError(f"HTTP {resp.status_code}: {resp.json().get('msg')}")
    resp.raise_for_status()
    body = resp.json()
    # On business failure HTTP is still 200, so check code
    if body.get("code") != 200:
        raise RuntimeError(f"Business failure code={body.get('code')}: {body.get('msg')}")
    return body


print(call("GET", "/open-api/v1/ping")["data"])
order = call("GET", "/open-api/v1/oms/orders/PO-TEST-0001")["data"]
print(order["status"], order["trackingNo"])

page = call("GET", "/open-api/v1/oms/inventory",
            params={"skuCode": "SKU-A001", "pageNum": 1, "pageSize": 100})
print(page["total"], page["rows"])

Node.js (18 or later, built-in fetch) ​

javascript
const BASE = 'https://api.vmwms.com';
const headers = {
  'x-api-key': process.env.VMWMS_KEY,
  'x-api-secret': process.env.VMWMS_SECRET,
};

async function call(method, path, body) {
  const resp = await fetch(BASE + path, {
    method,
    headers: body ? { ...headers, 'Content-Type': 'application/json' } : headers,
    body: body ? JSON.stringify(body) : undefined,
  });
  const json = await resp.json();
  if (!resp.ok) throw new Error(`HTTP ${resp.status}: ${json.msg}`);
  if (json.code !== 200) throw new Error(`Business failure code=${json.code}: ${json.msg}`);
  return json;
}

(async () => {
  console.log((await call('GET', '/open-api/v1/ping')).data);
  const order = (await call('GET', '/open-api/v1/oms/orders/PO-TEST-0001')).data;
  console.log(order.status, order.trackingNo);
})().catch(console.error);

Java (11 or later, java.net.http) ​

java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public class VmwmsDemo {
    private static final String BASE = "https://api.vmwms.com";
    private static final HttpClient CLIENT = HttpClient.newBuilder()
            .connectTimeout(Duration.ofSeconds(10)).build();

    static String call(String method, String path, String jsonBody) throws Exception {
        HttpRequest.Builder b = HttpRequest.newBuilder(URI.create(BASE + path))
                .timeout(Duration.ofSeconds(30))
                .header("x-api-key", System.getenv("VMWMS_KEY"))
                .header("x-api-secret", System.getenv("VMWMS_SECRET"));
        if (jsonBody != null) {
            b.header("Content-Type", "application/json")
             .method(method, HttpRequest.BodyPublishers.ofString(jsonBody));
        } else {
            b.method(method, HttpRequest.BodyPublishers.noBody());
        }
        HttpResponse<String> resp = CLIENT.send(b.build(), HttpResponse.BodyHandlers.ofString());
        if (resp.statusCode() != 200) {
            throw new RuntimeException("HTTP " + resp.statusCode() + ": " + resp.body());
        }
        // On business failure HTTP is still 200; parse the body with a JSON library and check code == 200
        return resp.body();
    }

    public static void main(String[] args) throws Exception {
        System.out.println(call("GET", "/open-api/v1/ping", null));
        System.out.println(call("GET", "/open-api/v1/oms/orders/PO-TEST-0001", null));
    }
}

FAQ ​

Do I need to sign requests? ​

No. Requests only need x-api-key and x-api-secret (over HTTPS throughout). The only signature you need to verify is on the Webhook payloads we push to you.

Why do I keep getting 401? ​

A wrong Key or Secret, a revoked or expired Key, or a disabled main account all return the same 401. On the Open API (开放API对接) page in OMS, confirm the Key's status is Active (有效), and check that you did not copy extra spaces or line breaks. See Error Codes and Troubleshooting.

Why do I get 429 "Too many authentication failures"? ​

If the same egress IP reaches 30 authentication failures within a minute, it is temporarily rate-limited. Fix your credentials, wait one minute, and try again.

Which endpoints can a read-only Key call? ​

All GET query endpoints, plus a few query endpoints in the legacy protocol that are implemented with POST (see Legacy-Compatible Protocol).