Modify Master API Key
Modify the settings of master api key. Use the api key pending to be modified to call the endpoint. 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"
info
Only the api key that calls this interface can be modified
HTTP Request
POST /v5/user/update-api
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
readOnly | false | integer | 0 (default):Read and Write. 1 :Read only |
ips | false | string | Set the IP bind. example: "192.168.0.1,192.168.0.2" note:
|
permissions | false | Object | Tick the types of permission. Don't send this param if you don't want to change the permission |
> ContractTrade | false | array | Contract Trade. ["Order","Position"] |
> Spot | false | array | Spot Trade. ["SpotTrade"] |
> Wallet | false | array | Wallet. ["AccountTransfer","SubMemberTransfer"] |
> Options | false | array | USDC Contract. ["OptionsTrade"] |
> Derivatives | false | array | This param is deprecated because system will automatically add this permission according to your account is UTA or Classic |
> CopyTrading | false | array | Copytrade. ["CopyTrading"] |
> BlockTrade | false | array | Blocktrade. ["BlockTrade"] |
> Exchange | false | array | Exchange. ["ExchangeHistory"] |
> NFT | false | array | NFT. ["NFTQueryProductList"] |
> Affiliate | false | array | Affiliate. ["Affiliate"]
|
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 | Always "" |
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. Not applicable to sub account, always [] |
> 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 [] |
ips | array | IP bound |
Request Example
- HTTP
- Python
- Node.js
POST /v5/user/update-api HTTP/1.1
Host: api.bybit.com
X-BAPI-API-KEY: XXXXXX
X-BAPI-TIMESTAMP: 1676431264739
X-BAPI-RECV-WINDOW: 5000
X-BAPI-SIGN: XXXXXX
Content-Type: application/json
{
"readOnly": null,
"ips": "*",
"permissions": {
"ContractTrade": [
"Order",
"Position"
],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer",
"SubMemberTransfer"
],
"Options": [
"OptionsTrade"
],
"CopyTrading": [
"CopyTrading"
],
"BlockTrade": [],
"Exchange": [
"ExchangeHistory"
],
"NFT": [
"NFTQueryProductList"
]
}
}
from pybit.unified_trading import HTTP
session = HTTP(
testnet=True,
api_key="XXXXX",
api_secret="XXXXX",
)
print(session.modify_master_api_key(
ips=["*"],
permissions={
"ContractTrade": [
"Order",
"Position"
],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer",
"SubMemberTransfer"
],
"Options": [
"OptionsTrade"
],
"Derivatives": [
"DerivativesTrade"
],
"CopyTrading": [
"CopyTrading"
],
"BlockTrade": [],
"Exchange": [
"ExchangeHistory"
],
"NFT": [
"NFTQueryProductList"
]
}
))
const { RestClientV5 } = require('bybit-api');
const client = new RestClientV5({
testnet: true,
key: 'apikey',
secret: 'apisecret',
});
client
.updateMasterApiKey({
ips: ['*'],
permissions: {
ContractTrade: ['Order', 'Position'],
Spot: ['SpotTrade'],
Wallet: ['AccountTransfer', 'SubMemberTransfer'],
Options: ['OptionsTrade'],
Derivatives: ['DerivativesTrade'],
CopyTrading: ['CopyTrading'],
BlockTrade: [],
Exchange: ['ExchangeHistory'],
NFT: ['NFTQueryProductList'],
},
})
.then((response) => {
console.log(response);
})
.catch((error) => {
console.error(error);
});
Response Example
{
"retCode": 0,
"retMsg": "",
"result": {
"id": "13770661",
"note": "xxxxx",
"apiKey": "xxxxx",
"readOnly": 0,
"secret": "",
"permissions": {
"ContractTrade": [
"Order",
"Position"
],
"Spot": [
"SpotTrade"
],
"Wallet": [
"AccountTransfer",
"SubMemberTransfer"
],
"Options": [
"OptionsTrade"
],
"Derivatives": [
"DerivativesTrade"
],
"CopyTrading": [
"CopyTrading"
],
"BlockTrade": [],
"Exchange": [
"ExchangeHistory"
],
"NFT": [
"NFTQueryProductList"
]
},
"ips": [
"*"
]
},
"retExtInfo": {},
"time": 1676431265427
}