- Biz-Api-Key: The API key used for the request. For more details, refer to API key.
- Biz-Api-Nonce: The nonce. A nonce is the current time in Unix timestamp format, measured in milliseconds.
- Biz-Api-Signature: The API signature. To learn how to calculate an API signature, see Calculate an API Signature.
API key and API secret
To enable secure and authenticated communication between clients and the WaaS 2.0 service, a mechanism based on the API key and API secret is used. This mechanism relies on cryptographic key pairs to verify the identity of the client and the integrity of the requests.API key
The API key is the public key in the cryptographic key pair. It is used to identify the client making the API request. The API key is associated with permissions and wallet scopes, which define the actions the client can perform and the wallets they can access. Different API keys can be assigned with varying permissions and wallet scopes, providing granular control over client capabilities.For more details about permissions and wallet scopes, see Permissions and wallet scopes.
API secret
The API secret is the private key in the key pair. It is used to sign API requests, guaranteeing their authenticity and integrity. The API secret must always remain confidential and secure to prevent unauthorized access. The API key and API secret work as a pair to secure communication with the WaaS 2.0 service:- The API key is included in API requests to identify the client to the WaaS service. It is required to be registered on Cobo Portal. For more information, refer to Register an API key.
- The API secret is used to generate a signature for each API request. The WaaS service validates the signature to confirm the request’s authenticity and prevent tampering.
Generate an API key and an API secret
This section introduces three ways to generate an API key and an API secret using the Ed25519 algorithm. You can also generate them using other tools that use the Ed25519 algorithm. The public key will be used as an API key, and the private key will be used as an API secret.Use Cobo CLI
Cobo Command Line Interface (CLI) is a powerful developer tool designed to help you build, test, and manage your integration with Cobo Wallet-as-a-Service (WaaS) 2.0 directly from the command line.-
Install Cobo CLI using the following command:
For more details about the system requirements for Cobo CLI, please refer to Install Cobo CLI.
-
Use the
keys generatecommand to generate a key pair using the Ed25519 algorithm as follows:Generated keys are securely stored in your configuration file (default:~/.cobo/config.toml). For more information about this command, refer to Key management.
Use OpenSSL
In a terminal window, run the following OpenSSL commands to generate a key pair using the Ed25519 algorithm:Private Key (Hex) as your API secret and the Public Key (Hex) as your API key.
Use the Python library
-
Install the
PyNaClPython library. In a terminal window, run the following command: -
Generate a key pair.
Import the function from the Python library to generate a key pair using the Ed25519 algorithm as follows:
Register the API key
After generating an API key, you need to register the key and configure related permissions on Cobo Portal. To learn how to register an API key, see Register an API key.Nonce
A nonce is the current time in Unix timestamp format, measured in milliseconds.Calculate the API signature
The following steps introduce how to calculate an API signature.-
First, concatenate a string based on your request as follows:
str_to_sign =
{METHOD}|{PATH}|{TIMESTAMP}|{PARAMS}|{BODY}Field Description Example METHOD The HTTP method. GETPATH The API endpoint. /v2/transactions/transferTIMESTAMP The current time in Unix timestamp format, measured in milliseconds. This value must be the same as the nonce in the request header. 1718587017026PARAMS (If applicable) The query parameters. chain_id=ETH&limit=10BODY (If applicable) The raw request body in string format. {"name":"Default","wallet_subtype":"Asset","wallet_type":"Custodial"} -
Use the
hashliblibrary to perform SHA-256 hashing twice on the string as follows: -
Use the API secret to sign the string as follows:
Feel free to share your feedback to improve our documentation!
