Create Sub UID API Key
To create new API key for those newly created sub UID. Use master user's api key only.
tip
The API key must have one of the below permissions in order to call this endpoint..
- master API key: "Account Transfer", "Subaccount Transfer", "Withdrawal"
HTTP Request
POST /v5/user/create-sub-api
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
subuid | true | integer | Sub user Id |
note | false | string | Set a remark |
readOnly | true | integer | 0 :Read and Write. 1 :Read only |
ips | false | string | Set the IP bind. example: "192.168.0.1,192.168.0.2" note:
|
permissions | true | Object | Tick the types of permission.
|
> ContractTrade | false | array | Contract Trade. ["Order","Position"] |
> Spot | false | array | Spot Trade. ["SpotTrade"] |
> Wallet | false | array | Wallet. ["AccountTransfer","SubMemberTransferList"] |
> Options | false | array | USDC Contract. ["OptionsTrade"] |
> Derivatives | false | array | This param is depreciated because system will automatically add this permission according to your account is UTA or Classic |
> Exchange | false | array | Exchange. ["ExchangeHistory"] |
> CopyTrading | false | array | Copytrade. ["CopyTrading"] |
Response Parameters
Parameter | Type | Comments |
---|---|---|
id | string | Unique id. Internal used |
note | string | The remark |
apiKey | string | Api key |
readOnly | integer | 0 :Read and Write. 1 :Read only |
secret | string | The secret paired with api key.
|
permissions | Object | The types of permission |
> ContractTrade | array | Permisson of contract trade |
> Spot | array | Permisson of spot |
> Wallet | array | Permisson of wallet |
> Options | array | Permission of USDC Contract. It supports trade option and usdc perpetual. |
> Derivatives | array | Permission of Unified account |
> CopyTrading | array | Permission of copytrade |
> BlockTrade | array | Permission of blocktrade. Not applicable to sub account, always [] |
> Exchange | array | Permission of exchange |
> NFT | array | Permission of NFT. Not applicable to sub account, always [] |
Request Example
- HTTP
- Python
- Node.js
POST /v5/user/create-sub-api HTTP/1.1
Host: api.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1676430005459
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"subuid": 53888000,
"note": "testxxx",
"readOnly": 0,
"permissions": {
"Wallet": [
"AccountTransfer"
]
}
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.create_sub_api_key(
subuid=53888000,
note="testxxx",
readOnly=0,
permissions={
"Wallet": [
"AccountTransfer"
]
},
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.createSubUIDAPIKey({
subuid: 53888000,
note: 'testxxx',
readOnly: 0,
permissions: {
Wallet: ['AccountTransfer'],
},
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "",
"result": {
"id": "16651283",
"note": "testxxx",
"apiKey": "xxxxx",
"readOnly": 0,
"secret": "xxxxxxxx",
"permissions": {
"ContractTrade": [],
"Spot": [],
"Wallet": [
"AccountTransfer"
],
"Options": [],
"CopyTrading": [],
"BlockTrade": [],
"Exchange": [],
"NFT": []
}
},
"retExtInfo": {},
"time": 1676430007643
}