Skip to main content

Signing a Request Using RSA

For successful completion, follow the steps and examples below.

How to compute the signature with RSA​

Prepare the payload

Convert the data to be signed (signature payload) into _ASCII format_. This payload typically includes all relevant request parameters or fields.

Generate the binary signature

Use the _RSASSA-PKCS1-v1_5_ signing algorithm with the SHA-256 hash function and _your RSA private key_ to create a binary signature.

Encode the signature

Convert the binary output of the signature to a Base64 string (RFC 2045).

How to send a signed API request​

Once the signature has been created, you can include it in your API request:

Add the Signature to the request header

Use the Base64-encoded signature generated in the previous step.

Include your API Key

Add your 3Commas API Key in the header alongside the Signature.

Send the request

Make the request to a SIGNED endpoint. Ensure the payload, headers, and method match the data used to compute the signature to avoid mismatches.

Keep in mind, the signature is case sensitive.

Examples​

Below are examples of signed endpoints and step-by-step guides for interacting with them.

Let's consider the first an example of a signed endpoint:

POST
/public/api/ver1/users/change_mode

The following is a step-by-step guide for sending a valid signed payload using the Linux command line with echo, openssl, and curl.

KeyValue
api_key
vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A
private key
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAspMfrKDl78gMWr4EO9Nr9LoZirPvkN93oGDO1LPnvDIwkmTV
QCXv9EAgzz4E36B9RuXIukMydrwCqtPOaweSAFgj9MZ0PFwIWsHk4x7flUJU3YI3
Ub2uc+jl2Mbtxfoei5cbY6iAwsp+HyeKrdonVHtEd9mFutd468+vO7+rx/M80onc
fduNVf/GRR2McTOO4Ptm4s68clY0dyXMRLidQjydPPYNjuzs47DVxNK+tXGS7QSH
LuC7VO/YBXWqZNzvii1KeCEIePJfz06ywZFTdNxZt2USoudAgUMBvJg0cLKqQJFx
p62Pez6aWC0lV9yDPHpUwp+RfrNiP213vKObnQIDAQABAoIBAQCf//KBWiirjzKC
m35vnB8+RwBbpp0f0Rn+OL8ZFZispsueX3oy38r/rfW3unnjZIja3UfcnBi7CfnZ
1a09eKr4ZADTcHz1GADkUJYkaaUqtyQS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
wc4dnTdfBxKBacAoUWUZcRuipcgkkUQAQZxqUnGkGZQHf8UFjEzHD5k=
-----END RSA PRIVATE KEY-----

Request Parameters​

Parameter:mode
Value:paper

Request Preparation

path
/public/api/ver1/users/change_mode
queryString
mode=paper
payload
/public/api/ver1/users/change_mode?mode=paper

Generating the Signature

echo -n "/public/api/ver1/users/change_mode?mode=paper" | openssl dgst -sha256 -sign private.pem | openssl enc -base64 -A

After running the command, you'll get the signature:

W+a26NiV6KkWP5zWoaDU9nSHmfObAtbbaq+xPIKwiKIz81Mlgrek/Z51qsAWNXEMCpIGW40IYDo7BTq4FSvOVSxdfrFK3lRqBveoXW+/50QOd3p+fDe5Ku7Z0U6MvXSUeFOguMBxP7er1SLGOb5RLYI/2GPMI5txLAoSsTLjGkWOc7S3ZhUpxEfxSCp8wCFp6E99biIX2MhIT1/AAl290ID76Wr1dj9Y3QxIl6KtQlbpEqhvWBaadYaYyZR5YjHAn5NWAE2cvxLkH+SQE1khzAdB6T9ZJ9sgMtY1bOzTTV/Cj9W0SABCYr4In12+uFY0lB+ANvgi8hLr2NCl775Wdw==

Making the API Call

curl
-H "Apikey: vmPUZE6mv9SD5VNHk4HlWFsOr6aKE2zvsw0MuIgwCIPy6utIco14y7Ju91duEh8A"
-H "Signature: W+a26NiV6KkWP5zWoaDU9nSHmfObAtbbaq+xPIKwiKIz81Mlgrek/Z51qsAWNXEMCpIGW40IYDo7BTq4FSvOVSxdfrFK3lRqBveoXW+/50QOd3p+fDe5Ku7Z0U6MvXSUeFOguMBxP7er1SLGOb5RLYI/2GPMI5txLAoSsTLjGkWOc7S3ZhUpxEfxSCp8wCFp6E99biIX2MhIT1/AAl290ID76Wr1dj9Y3QxIl6KtQlbpEqhvWBaadYaYyZR5YjHAn5NWAE2cvxLkH+SQE1khzAdB6T9ZJ9sgMtY1bOzTTV/Cj9W0SABCYr4In12+uFY0lB+ANvgi8hLr2NCl775Wdw=="
-X POST 'https://api.3commas.io/public/api/ver1/users/change_mode?mode=paper'