Allocations
Create Portfolio Allocations
REST API
- Introduction
- Requests
- Rate Limits
- Authentication
- Pagination
- CLI Setup
- Activities
- Address Book
- Allocations
- Assets
- Balances
- Commission
- Financing
- Futures
- Invoices
- Onchain Address Book
- Onchain Address Groups
- Orders
- Payment Methods
- Portfolios
- Positions
- Products
- Staking
- Transactions
- Users
- Wallets
FIX API
Allocations
Create Portfolio Allocations
Create allocation for a given portfolio.
POST
/
v1
/
allocations
Copy
Ask AI
curl --request POST \
--url https://api.prime.coinbase.com/v1/allocations \
--header 'Content-Type: application/json' \
--data '{
"allocation_id": "<string>",
"source_portfolio_id": "<string>",
"product_id": "<string>",
"order_ids": [
"<string>"
],
"allocation_legs": [
{
"allocation_leg_id": "<string>",
"destination_portfolio_id": "<string>",
"amount": "<string>"
}
],
"size_type": "ALLOCATION_SIZE_TYPE_UNKNOWN",
"remainder_destination_portfolio": "<string>",
"netting_id": "<string>"
}'
Copy
Ask AI
{
"body": {
"success": true,
"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
Copy
Ask AI
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();
CreateAllocationRequest request = new CreateAllocationRequest.Builder()
.sourcePortfolioId("SOURCE_PORTFOLIO_ID_HERE")
.allocationId(allocationId)
.allocationLegs(new AllocationLeg[]{allocationLeg})
.productId("ETH-USD")
.build();
CreateAllocationResponse response = allocationsService.createAllocation(request);
For more information, please visit the Prime Java SDK.
Copy
Ask AI
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();
CreateAllocationRequest request = new CreateAllocationRequest.Builder()
.sourcePortfolioId("SOURCE_PORTFOLIO_ID_HERE")
.allocationId(allocationId)
.allocationLegs(new AllocationLeg[]{allocationLeg})
.productId("ETH-USD")
.build();
CreateAllocationResponse response = allocationsService.createAllocation(request);
For more information, please visit the Prime Java SDK.
Copy
Ask AI
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 CreateAllocationRequest()
{
AllocationId = allocationId.ToString(),
ProductId = "ETH-USD",
SourcePortfolioId = "ADD_SOURCE_PORTFOLIO_ID_HERE",
AllocationLegs = [ allocationLeg ],
SizeType = Prime.Model.SizeType.PERCENT,
};
var response = allocationsService.CreateAllocation(request);
For more information, please visit the Prime .NET SDK.
Copy
Ask AI
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.CreatePortfolioAllocationsRequest{
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",
}
response, err := allocationsService.CreatePortfolioAllocations(context.Background(), request)
For more information, please visit the Prime Go SDK.
Copy
Ask AI
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 = CreatePortfolioAllocationsRequest(
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,
)
response = prime_client.create_portfolio_allocations(request)
For more information, please visit the Prime Python SDK.
Copy
Ask AI
primectl create-allocation --help
For more information, please visit the Prime CLI.
Copy
Ask AI
const allocationService = new AllocationService(client);
allocationService.createAllocation({
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
}).then(async (response) => {
console.log('Order allocated: ', response);
})
For more information, please visit the Prime TS SDK.
Body
application/json
Response
200
application/json
A successful response.
The response is of type object
.
Was this page helpful?
Copy
Ask AI
curl --request POST \
--url https://api.prime.coinbase.com/v1/allocations \
--header 'Content-Type: application/json' \
--data '{
"allocation_id": "<string>",
"source_portfolio_id": "<string>",
"product_id": "<string>",
"order_ids": [
"<string>"
],
"allocation_legs": [
{
"allocation_leg_id": "<string>",
"destination_portfolio_id": "<string>",
"amount": "<string>"
}
],
"size_type": "ALLOCATION_SIZE_TYPE_UNKNOWN",
"remainder_destination_portfolio": "<string>",
"netting_id": "<string>"
}'
Copy
Ask AI
{
"body": {
"success": true,
"allocation_id": "<string>",
"failure_reason": "<string>"
}
}
Assistant
Responses are generated using AI and may contain mistakes.