Create users
POST createSubaccount
For streamlined user transaction filtering, utilize the createSubaccount
method.
For new users:
- Call
createSubaccount
on user registration. - Save the generated
subaccountId
for user association.
For existing users:
- Upon user login, check if you have saved
subaccountId
for them. - If not, call
createSubaccount
.
To be able to filter transactions by subaccountId
:
- Include
subaccountId
in createTransaction or createFixTransaction body parameters for user-specific transactions. - Use
subaccountId
in getTransactions calls to fetch user-specific transaction history.
HTTP request
https://api.changelly.com/v2/#createSubaccount
Request
- Request
- Payload
- cURL
Header parameters
Name | Type | Required | Description |
---|---|---|---|
X-Api-Key | string | true | Your API key (SHA256 from Public Key) |
X-Api-Signature | string | true | The query's serialized body signed by your private key according to the RSA-SHA256 method. |
Body parameters
Name | Type | Required | Description |
---|---|---|---|
jsonrpc | string | true | JSON-RPC version. |
id | string | true | Client's custom ID. |
method | string | true | API method name. |
params | object | true | Request parameters. |
params
object:
Name | Type | Required | Description |
---|---|---|---|
string | false | User's email address. Must be unique among all of your users. |
application/json
{
"jsonrpc": "2.0",
"id": "test",
"method": "createSubaccount",
"params": {
"email": "[email protected]"
}
}
curl --location --request POST 'https://api.changelly.com/v2' \
--header 'X-Api-Key: {{apiKey}}' \
--header 'X-Api-Signature: {{sign}}' \
--data-raw '{
"id": "test",
"jsonrpc": "2.0",
"method": "createSubaccount",
"params": {
"email": "[email protected]"
}
}'
Response
- Example
- Success
- Errors
Sample response
application/json
{
"jsonrpc": "2.0",
"id": "test",
"result": {
"subaccountId": "FhbRm-Ox"
}
}
Response params
Name | Type | Description |
---|---|---|
jsonrpc | string | JSON-RPC version. |
id | string | Client's custom ID. |
result | object | Result. |
result
schema:
Name | Type | Description |
---|---|---|
subaccountId | string | Subaccount ID. |
Error schema
Name | Type | Description |
---|---|---|
jsonrpc | string | JSON-RPC version. |
id | string | Client's custom ID. |
error | object | Possible errors. |
»code | integer | Error code. |
»message | string | Error message. |
Error codes
Code | Message | Description |
---|---|---|
-32600 | Error: You reached requests limit {limit} rps | You have been sending more than 10 requests per second. |
-32602 | Parameter {param} is invalid | You've specified an invalid parameter. Also, the chance is that the email address is already associated with an existing subaccount. |
-32603 | Internal Error or Error | Most likely, the problem is on our side. Further investigation is required. |