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

# Preview loan update

> Preview acquire or repay loan for a given portfolio and asset.

<Tabs groupId="programming-language">
  <Tab value="Typescript" title="TS/JS">
    ```js theme={null}
    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](https://github.com/coinbase-samples/intx-sdk-ts).
  </Tab>
</Tabs>


## OpenAPI

````yaml POST /api/v1/portfolios/{portfolio}/loans/{asset}/preview
openapi: 3.0.3
info:
  title: REST API
  description: >
    # Welcome to Coinbase INTX API

    ## Introduction

    The INTX APIs allow institutions to trade and manage orders on the
    International Exchange. The following API pages detail various REST API
    endpoints we offer.

    ## Getting Started

    To get started, please visit one of the following pages:

    - [Quickstart](/international-exchange/introduction/quickstart)

    -
    [Overview](/api-reference/international-exchange-api/rest-api/introduction)

    -
    [Authentication](/api-reference/international-exchange-api/rest-api/authentication)

    - [Rate Limits](/international-exchange/introduction/rate-limits-overview)

    ## FIX API

    - [FIX API reference](/international-exchange/fix-api/fix-api-overview)

    ## WebSocket API

    - [WebSocket API
    reference](/international-exchange/websocket-feed/websocket-overview)
  version: '1.0'
servers:
  - url: https://api.international.coinbase.com
security: []
paths:
  /api/v1/portfolios/{portfolio}/loans/{asset}/preview:
    post:
      tags:
        - Portfolios
      summary: Preview loan update
      description: Preview acquire or repay loan for a given portfolio and asset.
      operationId: previewUpdatePortfolioLoan
      parameters:
        - name: portfolio
          in: path
          description: >-
            Identifies the portfolio by UUID (e.g.,
            `892e8c7c-e979-4cad-b61b-55a197932cf1`) or portfolio ID (e.g.,
            `5189861793641175`)
          required: true
          schema:
            type: string
        - name: asset
          in: path
          description: >-
            Identifies the asset by name (e.g., `BTC`), UUID (e.g.,
            `291efb0f-2396-4d41-ad03-db3b2311cb2c`), or asset ID (e.g.,
            `1482439423963469`)
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - action
                - amount
              properties:
                action:
                  $ref: '#/components/schemas/LoanUpdateAction'
                  description: The loan update action to take
                amount:
                  description: The amount of the loan to acquire or repay in quantity
                  type: string
                  example: 1000
      responses:
        '200':
          description: Loan update preview result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PortfolioPreviewLoanUpdateResult_v1'
        '400':
          description: Invalid attribute
      security:
        - auth_client_id: []
          auth_passphrase: []
          auth_signature: []
          auth_timestamp: []
components:
  schemas:
    LoanUpdateAction:
      description: The type of loan update action
      type: string
      enum:
        - ACQUIRE
        - REPAY
      example: ACQUIRE
    PortfolioPreviewLoanUpdateResult_v1:
      type: object
      properties:
        initial_margin_contribution:
          description: >-
            The notional amount this loan contributes to the portfolio initial
            margin notional value
          format: string
          example: 0.07
        initial_margin_delta:
          description: >-
            The delta of notional amount this loan contributes to the portfolio
            initial margin notional value
          format: string
          example: 0.07
        portfolio_initial_margin:
          description: The weighted average of all initial margin utilization
          type: string
          example: 0.15
        portfolio_initial_margin_notional:
          description: The notional initial margin of the portfolio
          type: string
          example: 1571.5345
        loan_collateral_requirement:
          description: The notional collateral requirement to hold the loan
          type: string
          example: 10.01
        loan_collateral_requirement_delta:
          description: The delta of notional collateral requirement to hold the loan
          type: string
          example: 10.01
        total_loan:
          description: The total quantity of the asset borrowed by the portfolio
          type: string
          example: 100.75
        loan_delta:
          description: >-
            The delta of the total quantity of the asset borrowed by the
            portfolio
          type: string
          example: 10.75
        max_available:
          description: >-
            The maximum remaining amount of this asset that can be borrowed at
            this time
          type: string
          example: 500.9
        reject_details:
          description: The reason for the rejection of the loan preview request
          type: string
        is_valid:
          description: Indicates whether the requested loan preview could be executed
          type: boolean
  securitySchemes:
    auth_client_id:
      type: apiKey
      name: CB-ACCESS-KEY
      in: header
      description: The Client ID that owns the API Key for the request
    auth_passphrase:
      type: apiKey
      name: CB-ACCESS-PASSPHRASE
      in: header
      description: The pass phrase affiliated with the API Key
    auth_signature:
      type: apiKey
      name: CB-ACCESS-SIGN
      in: header
      description: >-
        A HMAC SHA-256 signature using the API Key secret on the string
        TIMESTAMP, METHOD, REQUEST_PATH, BODY
    auth_timestamp:
      type: apiKey
      name: CB-ACCESS-TIMESTAMP
      in: header
      description: The timestamp of when the request is being made

````