API Documentation: Add Asset (Coin/Token) to Portfolio
Overview
This endpoint allow user to add asset to particular wallet. The asset information can be taken from Get Assets.
- HTTP Method: POST
- Endpoint:
/api/v1/portfolios
Request Body Parameters
walletId
(required): this will be used to determine where the asset will be added to.network
(required): The network of asset. Type : string.tokenId
(required): The id of asset. Type : string.isNative
(required): The native status of asset. Type : boolean.
Example Request Body
{
"walletId" : "7a813f6b-5639-49b2-a39c-8159fefaa6ae",
"network" : "ethereum",
"tokenId" : "usd-coin",
"isNative": false
}
Request
Request Headers
X-CLIENT-ID
: (required): Client ID which was generated when register in Xellar TSS API Service Dashboard.X-SIGNATURE
: (required): Calculated signature, please refer to Authorization section.X-TIMESTAMP
: (required): Request timestamp in RFC3339 format.
Example Request Syntax
curl -X POST -H "Content-Type: application/json" -H "x-client-id: $YOUR_CLIENT_ID" -H "x-client-secret: $YOUR_CLIENT_SECRET" -d '{
"walletId" : "7a813f6b-5639-49b2-a39c-8159fefaa6ae",
"network" : "ethereum",
"tokenId" : "usd-coin",
"isNative": false
}' <BASE_URL>/api/v1/portfolios
Response
The response will include a JSON object with the following properties:
status
(number): The HTTP status code of the response (e.g., 200 for success).message
(string): A message providing additional information about the operation.data
(object): An object containing asset information.data.key
(string): Unique identifier for asset on portfolio.data.id
(string): Coin/token id.data.symbol
(string): Coin/token symbol.data.name
(string): Coin/token name.data.network
(string): Coin/token network.data.wrapped
(boolean): Coin/token wrapped status.data.isNative
(boolean): Coin/token native status on particular network.data.logo
(boolean): Coin/token logo.data.contractAddress
(boolean): Coin/token contract address, only have value on non-native asset.data.deicmalPlace
(boolean): Coin/token decimal.
Example Response
// Success : HTTP OK 200
{
"status": 200,
"message": "Add asset to portfolio successfully",
"data": {
"key": "3748810b-3ee3-4cf7-80e7-42434806a661",
"id": "usd-coin",
"symbol": "usdc",
"name": "USDC",
"network": "ethereum",
"wrapped": false,
"isNative": false,
"logo": "https://raw.githubusercontent.com/Xellar-Protocol/xellar-assets/master/assets/usd-coin/logo.png",
"contractAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"decimalPlace": 6
}
}
// Asset exist on wallet : HTTP BAD REQUEST 400
{
"error": "asset already exists on portfolio"
}