Skip to main content

Call Method

Signature Method

Last updated: 2025-12-24 15:06:05

Prerequisites

  • Before using the signature method, you need to obtain your access_key and secret_key. If you haven't obtained them yet, please refer to the Key Management guide to create and save your keys.
  • To access services using the access key method, you need to set the X-AUTH-TYPE header with the value AK in your request headers.

Signature Parameters

Parameter Type Description
access_key string Application access identifier
secret_key string Encryption key
nonce string Unix timestamp, the server will validate the time difference within 30 seconds from the current time
signature string Signature

When requesting services, nonceaccess_key, and signature should be set in the URI querystring, and the X-AUTH-TYPE header should be set to AK in the request headers, for example:

/gpu/api/v1/service/cloudregion?pageIdx=1&access_key=xx&nonce=123456&signature=xx

Request headers:

X-AUTH-TYPE: AK

Signature Algorithm

  1. The signature field is not included in the signature calculation.
  2. Sort the JSON request parameters by key in ASCII ascending order to generate the signature message. Empty values are not included in the signature calculation. For example: pageIdx=1
  3. Append nonce and access_key to the message, for example: pageIdx=1123456FkxZwvrgm5tZ2iIW2cv98smcriekvt7uH4PaFieZ
  4. Use secret_key to perform HMAC-SHA256 encryption on the message generated in step 3, then convert to hex to generate the signature. For example: 7f2ef8b5f35efc22ebadc59bf4db8bf84995b8e56b6df8d8b030b6e744329bf0
  5. Finally, add the signature parameter to the request parameters to complete the signature, and submit to the server for validation.

Example

Below is a complete example demonstrating the signature process for creating an instance order:

Application Details:

  • appName: api-test
  • access_key: 2DhWOSzx3ZZfDKR5HCwbEdes93PIDWxcwTZq60K8
  • secret_key: onHO1TC7xaakx9k2JdnGU0T2dWVWVxVMcexOVjLG

Request Body:

{
    "associate_id": "1720276164460810240",
    "user_id": "1996482558459777024",
    "sku": "1b06ec36070ba20bf1413544017a6e374218b6c7",
    "image_id": "34611f92-75b6-462c-84a2-44ca9ef5243a",
    "hostname": "bd-k8s-1KpDSbXMxZ-nat-gateway",
    "generate_name": "bd-k8s-1KpDSbXMxZ-nat-gateway",
    "description": "K8s NAT Gateway for cluster bd-k8s-1KpDSbXMxZ",
    "__count__": 1,
    "instance_type_family": "VIRTUAL_MACHINE",
    "keypair": "0a52ba76-7f56-49a5-82f3-fd9d92f6adb2",
    "prefer_region": "default",
    "prefer_zone": "ba4d6422-b6f8-4e97-8ce6-e4fc94aaca13",
    "zone_id": "ba4d6422-b6f8-4e97-8ce6-e4fc94aaca13",
    "vpc_network_id": "6ab1b65d-642c-4db5-870c-e6cee6b84c8f",
    "vpc_id": "f1c32034-4bcd-4c48-8eef-c9448e0beed4",
    "network_id": "6ab1b65d-642c-4db5-870c-e6cee6b84c8f",
    "bandwidth": 200,
    "bandwidth_category": 2,
    "bandwidth_charging_category": 2,
    "bandwidth_promotion_id": "176",
    "used_category": 3,
    "secgroups": [
        "12c10f42-44d3-4b77-8001-3b26ec15091a"
    ],
    "system_disk_storage": {
        "size": 100,
        "promotion_id": "196860769046888857658816283812",
        "disk_type": "sys"
    },
    "promotion_id": "180370914450761728011477873701",
    "source": "online",
    "sold_type": 1,
    "renew": 3,
    "rg_id": "rg-qMYZoxUiRDmDDwOm",
    "tags": [
        "K8S"
    ]
}

Request Query Parameters:

  • nonce: 1766545160
  • access_key: 2DhWOSzx3ZZfDKR5HCwbEdes93PIDWxcwTZq60K8
  • signature: 2d398cb4ec3375e1e68f24b6dd8d9e95fcce818230c0794437e7edc7c266c549

Signature Payload:

The payload is constructed by sorting all request body parameters by key in ASCII order, then appending nonce, appName, and access_key:

__count__=1&associate_id=1720276164460810240&bandwidth=200&bandwidth_category=2&bandwidth_charging_category=2&bandwidth_promotion_id=176&description=K8s NAT Gateway for cluster bd-k8s-1KpDSbXMxZ&generate_name=bd-k8s-1KpDSbXMxZ-nat-gateway&hostname=bd-k8s-1KpDSbXMxZ-nat-gateway&image_id=34611f92-75b6-462c-84a2-44ca9ef5243a&instance_type_family=VIRTUAL_MACHINE&keypair=0a52ba76-7f56-49a5-82f3-fd9d92f6adb2&network_id=6ab1b65d-642c-4db5-870c-e6cee6b84c8f&prefer_region=default&prefer_zone=ba4d6422-b6f8-4e97-8ce6-e4fc94aaca13&promotion_id=180370914450761728011477873701&renew=3&rg_id=rg-qMYZoxUiRDmDDwOm&secgroups=["12c10f42-44d3-4b77-8001-3b26ec15091a"]&sku=1b06ec36070ba20bf1413544017a6e374218b6c7&sold_type=1&source=online&system_disk_storage=disk_type=sys&promotion_id=196860769046888857658816283812&size=100&tags=["K8S"]&used_category=3&user_id=1996482558459777024&vpc_id=f1c32034-4bcd-4c48-8eef-c9448e0beed4&vpc_network_id=6ab1b65d-642c-4db5-870c-e6cee6b84c8f&zone_id=ba4d6422-b6f8-4e97-8ce6-e4fc94aaca131766545160api-test2DhWOSzx3ZZfDKR5HCwbEdes93PIDWxcwTZq60K8

Signature Result:

Using the secret_key to perform HMAC-SHA256 encryption on the payload and converting to hex generates the signature:

2d398cb4ec3375e1e68f24b6dd8d9e95fcce818230c0794437e7edc7c266c549