> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloud.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Allocation by ID

> Retrieve an allocation by allocation ID.

Use the Prime SDK or CLI to test this endpoint by following the [quickstart](/prime/introduction/quickstart) guide and running with the following examples

<Tabs>
  <Tab title="Java">
    ```java theme={null}
    AllocationsService allocationsService = PrimeServiceFactory.createAllocationsService(client);

    GetAllocationRequest request = new GetAllocationRequest.Builder("PORTFOLIO_ID_HERE", "ALLOCATION_ID_HERE").build();

    GetAllocationResponse response = allocationsService.getAllocation(request);
    ```

    For more information, please visit the [Prime Java SDK](https://github.com/coinbase-samples/prime-sdk-java).
  </Tab>

  <Tab title=".NET">
    ```csharp wrap theme={null}
    var allocationsService = new AllocationsService(client);

    var request = new GetAllocationRequest("PORTFOLIO_ID_HERE", "ALLOCATION_ID_HERE");
    var response = allocationsService.GetAllocation(request);
    ```

    For more information, please visit the [Prime .NET SDK](https://github.com/coinbase-samples/prime-sdk-dotnet).
  </Tab>

  <Tab title="Go">
    ```go wrap theme={null}
    allocationsService := allocations.NewAllocationsService(client)

    request := &allocations.GetPortfolioAllocationRequest{
        PortfolioId:  "PORTFOLIO_ID_HERE",
        AllocationId: "ALLOCATION_ID_HERE",
    }

    response, err := allocationsService.GetPortfolioAllocation(context.Background(), request)
    ```

    For more information, please visit the [Prime Go SDK](https://github.com/coinbase-samples/prime-sdk-go).
  </Tab>

  <Tab title="Python">
    ```python wrap theme={null}
    prime_client = PrimeClient(credentials)

    request = GetAllocationByIdRequest(
            portfolio_id="PORTFOLIO_ID_HERE",
            allocation_id="ALLOCATION_ID_HERE",
    )

    response = prime_client.get_allocation_by_id(request)
    ```

    For more information, please visit the [Prime Python SDK](https://github.com/coinbase-samples/prime-sdk-py).
  </Tab>

  <Tab title="CLI">
    ```bash wrap theme={null}
    primectl get-allocation --help
    ```

    For more information, please visit the [Prime CLI](https://github.com/coinbase-samples/prime-cli).
  </Tab>

  <Tab title="TS/JS">
    ```typescript wrap theme={null}
    const allocationService = new AllocationService(client);

    allocationService.getAllocation({
        allocationId: "ALLOCATION_ID_HERE",
        portfolioId: "PORTFOLIO_ID_HERE"
    }).then(async (response) => {
        console.log('Allocation: ', response);
    })
    ```

    For more information, please visit the [Prime TS SDK](https://github.com/coinbase-samples/prime-sdk-ts).
  </Tab>
</Tabs>


## OpenAPI

````yaml GET /v1/portfolios/{portfolio_id}/allocations/{allocation_id}
openapi: 3.0.1
info:
  title: REST API
  description: >-
    The Coinbase Prime REST API provides programmatic access to trading,
    custody, staking, market data, and account management functionality.
  version: '0.1'
servers:
  - url: https://api.prime.coinbase.com/
security: []
tags:
  - name: PrimeRESTAPI
paths:
  /v1/portfolios/{portfolio_id}/allocations/{allocation_id}:
    get:
      tags:
        - Allocations
      summary: Get Allocation by ID
      description: Retrieve an allocation by allocation ID.
      operationId: PrimeRESTAPI_GetAllocation
      parameters:
        - name: portfolio_id
          in: path
          description: The portfolio ID of the allocation
          required: true
          schema:
            type: string
        - name: allocation_id
          in: path
          description: The ID of the allocation
          required: true
          schema:
            type: string
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/coinbase.public_rest_api.GetAllocationResponse
components:
  schemas:
    coinbase.public_rest_api.GetAllocationResponse:
      type: object
      properties:
        allocation:
          $ref: '#/components/schemas/coinbase.public_rest_api.Allocation'
    coinbase.public_rest_api.Allocation:
      type: object
      properties:
        root_id:
          type: string
          description: The ID that ties together an allocation and all of its legs.
        reversal_id:
          type: string
          description: >-
            The ID of the allocation if this allocation is a reversal. In this
            case, the root_id would be the original allocation ID.
        allocation_completed_at:
          type: string
          description: Time the final leg of the root allocation was completed.
          format: date-time
        user_id:
          type: string
          description: The ID of the user that created the allocation.
        product_id:
          type: string
          description: The ID of the product of the orders allocated.
        side:
          $ref: '#/components/schemas/coinbase.public_rest_api.OrderSide'
        avg_price:
          type: string
          description: Price the allocation was done at.
        base_quantity:
          type: string
          description: Amount allocated in base asset units.
        quote_value:
          type: string
          description: Amount allocated in quote asset units.
        fees_allocated:
          type: string
          description: Fees from original trade execution allocated in quote asset units.
        status:
          $ref: '#/components/schemas/coinbase.public_rest_api.AllocationStatus'
        source:
          type: string
          description: Portfolio ID of the source portfolio.
        order_ids:
          title: slice
          type: array
          description: >-
            All order IDs that were aggregated to calculate the avg_price,
            quantity to allocate in each leg. Each order_id should tie back to
            the single allocation root_id.
          items:
            type: string
        destinations:
          type: array
          description: >-
            Array of objects, each containing the leg ID, destination portfolio
            ID and amount in chosen units allocated to each portfolio: [{leg_id,
            portfolio_id, allocation_base, allocation_quote}, {leg_id,
            portfolio_id, allocation_base, allocation_quote}...]
          items:
            $ref: '#/components/schemas/coinbase.public_rest_api.DestinationAlloc'
        netting_id:
          type: string
          description: >-
            The netting ID of the allocation, not empty if the allocation was
            submitted as part of a net allocation
    coinbase.public_rest_api.OrderSide:
      title: Order side
      type: string
      description: |-
        - UNKNOWN_ORDER_SIDE: nil value
         - BUY: Buy order
         - SELL: Sell order
      enum:
        - BUY
        - SELL
    coinbase.public_rest_api.AllocationStatus:
      type: string
      default: ALLOCATION_STATUS_UNSPECIFIED
      enum:
        - ALLOCATION_STATUS_UNSPECIFIED
        - ALLOCATION_STATUS_ALLOCATION_PENDING
        - ALLOCATION_STATUS_ALLOCATION_ACCEPTED
        - ALLOCATION_STATUS_ALLOCATION_ALLOCATED
        - ALLOCATION_STATUS_ALLOCATION_REJECTED
    coinbase.public_rest_api.DestinationAlloc:
      type: object
      properties:
        leg_id:
          type: string
          description: The ID unique to each leg of an allocation.
        portfolio_id:
          type: string
          description: Portfolio ID of the source portfolio.
        allocation_base:
          type: string
          description: Amount allocated in base asset units.
        allocation_quote:
          type: string
          description: Amount allocated in quote asset units.
        fees_allocated_leg:
          type: string
          description: >-
            Pro rata fees for each leg. Adding up the fees for each leg will sum
            up to equal the total allocation level fees.

````