Create Portfolio Net Allocations
curl --request POST \
--url https://api.prime.coinbase.com/v1/allocations/net \
--header 'Content-Type: application/json' \
--data '
{
"source_portfolio_id": "<string>",
"product_id": "<string>",
"order_ids": [
"<string>"
],
"allocation_legs": [
{
"allocation_leg_id": "<string>",
"destination_portfolio_id": "<string>",
"amount": "<string>"
}
],
"remainder_destination_portfolio": "<string>",
"netting_id": "<string>"
}
'import requests
url = "https://api.prime.coinbase.com/v1/allocations/net"
payload = {
"source_portfolio_id": "<string>",
"product_id": "<string>",
"order_ids": ["<string>"],
"allocation_legs": [
{
"allocation_leg_id": "<string>",
"destination_portfolio_id": "<string>",
"amount": "<string>"
}
],
"remainder_destination_portfolio": "<string>",
"netting_id": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
source_portfolio_id: '<string>',
product_id: '<string>',
order_ids: ['<string>'],
allocation_legs: [
{
allocation_leg_id: '<string>',
destination_portfolio_id: '<string>',
amount: '<string>'
}
],
remainder_destination_portfolio: '<string>',
netting_id: '<string>'
})
};
fetch('https://api.prime.coinbase.com/v1/allocations/net', 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.prime.coinbase.com/v1/allocations/net",
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([
'source_portfolio_id' => '<string>',
'product_id' => '<string>',
'order_ids' => [
'<string>'
],
'allocation_legs' => [
[
'allocation_leg_id' => '<string>',
'destination_portfolio_id' => '<string>',
'amount' => '<string>'
]
],
'remainder_destination_portfolio' => '<string>',
'netting_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.prime.coinbase.com/v1/allocations/net"
payload := strings.NewReader("{\n \"source_portfolio_id\": \"<string>\",\n \"product_id\": \"<string>\",\n \"order_ids\": [\n \"<string>\"\n ],\n \"allocation_legs\": [\n {\n \"allocation_leg_id\": \"<string>\",\n \"destination_portfolio_id\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"remainder_destination_portfolio\": \"<string>\",\n \"netting_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.prime.coinbase.com/v1/allocations/net")
.header("Content-Type", "application/json")
.body("{\n \"source_portfolio_id\": \"<string>\",\n \"product_id\": \"<string>\",\n \"order_ids\": [\n \"<string>\"\n ],\n \"allocation_legs\": [\n {\n \"allocation_leg_id\": \"<string>\",\n \"destination_portfolio_id\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"remainder_destination_portfolio\": \"<string>\",\n \"netting_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prime.coinbase.com/v1/allocations/net")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"source_portfolio_id\": \"<string>\",\n \"product_id\": \"<string>\",\n \"order_ids\": [\n \"<string>\"\n ],\n \"allocation_legs\": [\n {\n \"allocation_leg_id\": \"<string>\",\n \"destination_portfolio_id\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"remainder_destination_portfolio\": \"<string>\",\n \"netting_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"body": {
"success": true,
"netting_id": "<string>",
"buy_allocation_id": "<string>",
"sell_allocation_id": "<string>",
"failure_reason": "<string>"
}
}Allocations
Create Portfolio Net Allocations
Create net allocation for a given portfolio.
POST
/
v1
/
allocations
/
net
Create Portfolio Net Allocations
curl --request POST \
--url https://api.prime.coinbase.com/v1/allocations/net \
--header 'Content-Type: application/json' \
--data '
{
"source_portfolio_id": "<string>",
"product_id": "<string>",
"order_ids": [
"<string>"
],
"allocation_legs": [
{
"allocation_leg_id": "<string>",
"destination_portfolio_id": "<string>",
"amount": "<string>"
}
],
"remainder_destination_portfolio": "<string>",
"netting_id": "<string>"
}
'import requests
url = "https://api.prime.coinbase.com/v1/allocations/net"
payload = {
"source_portfolio_id": "<string>",
"product_id": "<string>",
"order_ids": ["<string>"],
"allocation_legs": [
{
"allocation_leg_id": "<string>",
"destination_portfolio_id": "<string>",
"amount": "<string>"
}
],
"remainder_destination_portfolio": "<string>",
"netting_id": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
source_portfolio_id: '<string>',
product_id: '<string>',
order_ids: ['<string>'],
allocation_legs: [
{
allocation_leg_id: '<string>',
destination_portfolio_id: '<string>',
amount: '<string>'
}
],
remainder_destination_portfolio: '<string>',
netting_id: '<string>'
})
};
fetch('https://api.prime.coinbase.com/v1/allocations/net', 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.prime.coinbase.com/v1/allocations/net",
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([
'source_portfolio_id' => '<string>',
'product_id' => '<string>',
'order_ids' => [
'<string>'
],
'allocation_legs' => [
[
'allocation_leg_id' => '<string>',
'destination_portfolio_id' => '<string>',
'amount' => '<string>'
]
],
'remainder_destination_portfolio' => '<string>',
'netting_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"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.prime.coinbase.com/v1/allocations/net"
payload := strings.NewReader("{\n \"source_portfolio_id\": \"<string>\",\n \"product_id\": \"<string>\",\n \"order_ids\": [\n \"<string>\"\n ],\n \"allocation_legs\": [\n {\n \"allocation_leg_id\": \"<string>\",\n \"destination_portfolio_id\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"remainder_destination_portfolio\": \"<string>\",\n \"netting_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.prime.coinbase.com/v1/allocations/net")
.header("Content-Type", "application/json")
.body("{\n \"source_portfolio_id\": \"<string>\",\n \"product_id\": \"<string>\",\n \"order_ids\": [\n \"<string>\"\n ],\n \"allocation_legs\": [\n {\n \"allocation_leg_id\": \"<string>\",\n \"destination_portfolio_id\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"remainder_destination_portfolio\": \"<string>\",\n \"netting_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.prime.coinbase.com/v1/allocations/net")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"source_portfolio_id\": \"<string>\",\n \"product_id\": \"<string>\",\n \"order_ids\": [\n \"<string>\"\n ],\n \"allocation_legs\": [\n {\n \"allocation_leg_id\": \"<string>\",\n \"destination_portfolio_id\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"remainder_destination_portfolio\": \"<string>\",\n \"netting_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"body": {
"success": true,
"netting_id": "<string>",
"buy_allocation_id": "<string>",
"sell_allocation_id": "<string>",
"failure_reason": "<string>"
}
}Use the Prime SDK or CLI to test this endpoint by following the quickstart guide and running with the following examples
For more information, please visit the Prime Java SDK.For more information, please visit the Prime .NET SDK.For more information, please visit the Prime Go SDK.For more information, please visit the Prime Python SDK.For more information, please visit the Prime CLI.For more information, please visit the Prime TS SDK.
- Java
- .NET
- Go
- Python
- CLI
- TS/JS
AllocationsService allocationsService = PrimeServiceFactory.createAllocationsService(client);
String allocationId = UUID.randomUUID().toString();
String allocationLegId = UUID.randomUUID().toString();
AllocationLeg allocationLeg = new AllocationLeg.Builder()
.allocationLegId(allocationLegId)
.amount("100")
.destinationPortfolioId("DESTINATION_PORTFOLIO_ID_HERE")
.build();
CreateNetAllocationRequest request = new CreateNetAllocationRequest.Builder()
.sourcePortfolioId("SOURCE_PORTFOLIO_ID_HERE")
.allocationId(allocationId)
.allocationLegs(new AllocationLeg[]{allocationLeg})
.productId("ETH-USD")
.nettingId("NETTING_ID_HERE")
.build();
CreateNetAllocationResponse response = allocationsService.createNetAllocation(request);
var allocationsService = new AllocationsService(client);
var allocationId = Guid.NewGuid();
var allocationLegId = Guid.NewGuid();
var allocationLeg = new AllocationLeg()
{
AllocationLegId = allocationLegId.ToString(),
Amount = "100",
DestinationPortfolioId = "ADD_DESTINATION_PORTFOLIO_ID_HERE",
};
var request = new CreateNetAllocationRequest()
{
AllocationId = allocationId.ToString(),
ProductId = "ETH-USD",
SourcePortfolioId = "ADD_SOURCE_PORTFOLIO_ID_HERE",
AllocationLegs = [ allocationLeg ],
SizeType = Prime.Model.SizeType.PERCENT,
NettingId = "NETTING_ID_HERE",
};
var response = allocationsService.CreateNetAllocation(request);
allocationsService := allocations.NewAllocationsService(client)
allocationId := uuid.New().String()
allocationLegId := uuid.New().String()
allocationLeg := &model.AllocationLeg{
LegId: allocationLegId,
DestinationPortfolioId: "DESTINATION_PORTFOLIO_ID_GOES_HERE",
Amount: "100.0",
}
request := &allocations.CreatePortfolioNetAllocationsRequest{
AllocationId: allocationId,
SourcePortfolioId: "SOURCE_PORTFOLIO_ID_GOES_HERE",
ProductId: "ETH-USD",
AllocationLegs: []*model.AllocationLeg{allocationLeg},
OrderIds: []string{"ORDER_IDS_TO_BE_ALLOCATED_HERE"},
SizeType: "PERCENT",
NettingId: "NETTING_ID_HERE",
}
response, err := allocationsService.CreatePortfolioNetAllocations(context.Background(), request)
prime_client = PrimeClient(credentials)
allocation_id = uuid.uuid4()
allocation_leg_id = uuid.uuid4()
product_id = 'ETH-USD'
size_type = 'PERCENT'
allocation_leg = AllocationLeg(
leg_id=allocation_leg_id,
destination_portfolio_id='DESTINATION_PORTFOLIO_ID_GOES_HERE',
amount='100.0',
)
request = CreatePortfolioNetAllocationsRequest(
allocation_id=allocation_id,
source_portfolio_id='SOURCE_PORTFOLIO_ID_GOES_HERE',
product_id=product_id,
order_ids=['ORDER_ID_GOES_HERE'],
allocation_legs=[allocation_leg],
size_type=size_type,
netting_id='NETTING_ID_HERE',
)
response = prime_client.create_portfolio_net_allocations(request)
primectl create-net-allocation --help
const allocationService = new AllocationService(client);
allocationService.createNetAllocation({
allocationId: uuidv4(),
sourcePortfolioId: "SOURCE_PORTFOLIO_ID_GOES_HERE"
productId: "ETH-USD",
orderIds: ["ORDER_ID_GOES_HERE"],
allocationLegs: [{
legId: uuidv4(),
destinationPortfolioId: "DESTINATION_PORTFOLIO_ID_GOES_HERE",
amount: "100.0",
}]
sizeType: AllocationSizeType.Percent,
nettidId: uuidv4()
}).then(async (response) => {
console.log('Order allocated: ', response);
})
Body
application/json
The source portfolio id for the allocation
The product for the allocation
The list of order ids in the allocation
The list of allocation_legs for the allocation
Show child attributes
Show child attributes
Available options:
BASE, QUOTE, PERCENT The portfolio where to allocate the remainder of the size
The ID to identify an in-flight net allocation.
Response
200 - application/json
A successful response.
Show child attributes
Show child attributes
Was this page helpful?
⌘I