Skip to main content
POST
/
api
/
v1
/
portfolios
/
{portfolio}
/
loans
/
{asset}
/
preview
Preview loan update
curl --request POST \
  --url https://api.international.coinbase.com/api/v1/portfolios/{portfolio}/loans/{asset}/preview \
  --header 'CB-ACCESS-KEY: <api-key>' \
  --header 'CB-ACCESS-PASSPHRASE: <api-key>' \
  --header 'CB-ACCESS-SIGN: <api-key>' \
  --header 'CB-ACCESS-TIMESTAMP: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "action": "ACQUIRE",
  "amount": 1000
}
'
import requests

url = "https://api.international.coinbase.com/api/v1/portfolios/{portfolio}/loans/{asset}/preview"

payload = {
"action": "ACQUIRE",
"amount": 1000
}
headers = {
"CB-ACCESS-KEY": "<api-key>",
"CB-ACCESS-PASSPHRASE": "<api-key>",
"CB-ACCESS-SIGN": "<api-key>",
"CB-ACCESS-TIMESTAMP": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'CB-ACCESS-KEY': '<api-key>',
'CB-ACCESS-PASSPHRASE': '<api-key>',
'CB-ACCESS-SIGN': '<api-key>',
'CB-ACCESS-TIMESTAMP': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({action: 'ACQUIRE', amount: 1000})
};

fetch('https://api.international.coinbase.com/api/v1/portfolios/{portfolio}/loans/{asset}/preview', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.international.coinbase.com/api/v1/portfolios/{portfolio}/loans/{asset}/preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'action' => 'ACQUIRE',
'amount' => 1000
]),
CURLOPT_HTTPHEADER => [
"CB-ACCESS-KEY: <api-key>",
"CB-ACCESS-PASSPHRASE: <api-key>",
"CB-ACCESS-SIGN: <api-key>",
"CB-ACCESS-TIMESTAMP: <api-key>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.international.coinbase.com/api/v1/portfolios/{portfolio}/loans/{asset}/preview"

payload := strings.NewReader("{\n \"action\": \"ACQUIRE\",\n \"amount\": 1000\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("CB-ACCESS-KEY", "<api-key>")
req.Header.Add("CB-ACCESS-PASSPHRASE", "<api-key>")
req.Header.Add("CB-ACCESS-SIGN", "<api-key>")
req.Header.Add("CB-ACCESS-TIMESTAMP", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.international.coinbase.com/api/v1/portfolios/{portfolio}/loans/{asset}/preview")
.header("CB-ACCESS-KEY", "<api-key>")
.header("CB-ACCESS-PASSPHRASE", "<api-key>")
.header("CB-ACCESS-SIGN", "<api-key>")
.header("CB-ACCESS-TIMESTAMP", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action\": \"ACQUIRE\",\n \"amount\": 1000\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.international.coinbase.com/api/v1/portfolios/{portfolio}/loans/{asset}/preview")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["CB-ACCESS-KEY"] = '<api-key>'
request["CB-ACCESS-PASSPHRASE"] = '<api-key>'
request["CB-ACCESS-SIGN"] = '<api-key>'
request["CB-ACCESS-TIMESTAMP"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": \"ACQUIRE\",\n \"amount\": 1000\n}"

response = http.request(request)
puts response.read_body
{
  "initial_margin_contribution": 0.07,
  "initial_margin_delta": 0.07,
  "portfolio_initial_margin": 0.15,
  "portfolio_initial_margin_notional": 1571.5345,
  "loan_collateral_requirement": 10.01,
  "loan_collateral_requirement_delta": 10.01,
  "total_loan": 100.75,
  "loan_delta": 10.75,
  "max_available": 500.9,
  "reject_details": "<string>",
  "is_valid": true
}
const positionOffsetsService = new PositionOffsetsService(client);

positionOffsetsService.previewLoanUpdate({
    portfolio: 'PORTFOLIO_ID_HERE',
    asset: 'ETH',
    action: LoanUpdateAction.ACQUIRE,
    amount: '1',
}).then(async (response) => {
    console.log('Preview Loan: ', response);
})
For more information, please visit the INTX TS SDK.

Authorizations

CB-ACCESS-KEY
string
header
required

The Client ID that owns the API Key for the request

CB-ACCESS-PASSPHRASE
string
header
required

The pass phrase affiliated with the API Key

CB-ACCESS-SIGN
string
header
required

A HMAC SHA-256 signature using the API Key secret on the string TIMESTAMP, METHOD, REQUEST_PATH, BODY

CB-ACCESS-TIMESTAMP
string
header
required

The timestamp of when the request is being made

Path Parameters

portfolio
string
required

Identifies the portfolio by UUID (e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID (e.g., 5189861793641175)

asset
string
required

Identifies the asset by name (e.g., BTC), UUID (e.g., 291efb0f-2396-4d41-ad03-db3b2311cb2c), or asset ID (e.g., 1482439423963469)

Body

application/json
action
enum<string>
required

The loan update action to take

Available options:
ACQUIRE,
REPAY
Example:

"ACQUIRE"

amount
string
required

The amount of the loan to acquire or repay in quantity

Example:

1000

Response

Loan update preview result

initial_margin_contribution
string<string>

The notional amount this loan contributes to the portfolio initial margin notional value

Example:

0.07

initial_margin_delta
string<string>

The delta of notional amount this loan contributes to the portfolio initial margin notional value

Example:

0.07

portfolio_initial_margin
string

The weighted average of all initial margin utilization

Example:

0.15

portfolio_initial_margin_notional
string

The notional initial margin of the portfolio

Example:

1571.5345

loan_collateral_requirement
string

The notional collateral requirement to hold the loan

Example:

10.01

loan_collateral_requirement_delta
string

The delta of notional collateral requirement to hold the loan

Example:

10.01

total_loan
string

The total quantity of the asset borrowed by the portfolio

Example:

100.75

loan_delta
string

The delta of the total quantity of the asset borrowed by the portfolio

Example:

10.75

max_available
string

The maximum remaining amount of this asset that can be borrowed at this time

Example:

500.9

reject_details
string

The reason for the rejection of the loan preview request

is_valid
boolean

Indicates whether the requested loan preview could be executed