> ## 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.

# Create Conversion

> Perform a conversion between 2 assets.

<Info>
  **Supported Swaps**

  This endpoint supports the following conversions: USD \<> USDC and USD \<> PYUSD.

  For more assistance on how to create and track conversions, visit the [stablecoins](/prime/concepts/stablecoins) concepts page.
</Info>

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}
    TransactionsService transactionsService = PrimeServiceFactory.createTransactionsService(client);

    CreateConversionRequest request = new CreateConversionRequest.Builder()
        .portfolioId("PORTFOLIO_ID_HERE")
        .walletId("WALLET_ID_HERE")
        .amount("1")
        .destination("DESTINATION_WALLET_UUID")
        .idempotencyKey(UUID.randomUUID().toString())
        .sourceSymbol("USD")
        .destinationSymbol("USDC")
        .build();

    CreateConversionResponse response = transactionsService.createConversion(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 transactionsService = new TransactionsService(client);

    var request = new CreateConversionRequest("PORTFOLIO_ID_HERE", "WALLET_ID_HERE")
    {
        Amount = "1",
        Destination = "DESTINATION_WALLET_UUID",
        IdempotencyKey = Guid.NewGuid().ToString(),
        SourceSymbol = "USD",
        DestinationSymbol = "USDC",
    };

    var response = transactionsService.CreateConversion(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}
    transactionsService := transactions.NewTransactionsService(client)

    request := &transactions.CreateConversionRequest{
        PortfolioId: "PORTFOLIO_ID_HERE",
        WalletId: "WALLET_ID_HERE",
        Amount: "1",
        Destination: "DESTINATION_WALLET_UUID",
        IdempotencyKey: uuid.New().String(),
        SourceSymbol: "USD",
        DestinationSymbol: "USDC",
    }

    response, err := transactionsService.CreateConversion(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 = CreateConversionRequest(
        portfolio_id="PORTFOLIO_ID_HERE",
        wallet_id="WALLET_ID_HERE",
        amount = '1',
        destination = 'DESTINATION_WALLET_UUID',
        idempotency_key = str(uuid.uuid4()),
        source_symbol = 'USD',
        destination_symbol = 'USDC',
    )

    response = prime_client.create_conversion(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 create-conversion --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 transactionsService = new TransactionsService(client);

    transactionsService.createConversion({
        portfolioId: 'PORTFOLIO_ID_HERE',
        walletId: 'WALLET_ID_HERE',
        amount: "1",
        destination: "DESTINATION_WALLET_UUID",
        idempotencyKey: uuidv4(),
        sourceSymbol: "USD",
        destinationSymbol: "USDC",

    }).then(async (response) => {
        console.log('Conversion: ', response);
    })
    ```

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


## OpenAPI

````yaml POST /v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion
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}/wallets/{wallet_id}/conversion:
    post:
      tags:
        - Transactions
      summary: Create Conversion
      description: Perform a conversion between 2 assets.
      operationId: PrimeRESTAPI_CreateConversion
      parameters:
        - name: portfolio_id
          in: path
          description: The ID of the portfolio
          required: true
          schema:
            type: string
        - name: wallet_id
          in: path
          description: The wallet ID that the conversion will originate from
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              required:
                - amount
                - destination
                - destination_symbol
                - idempotency_key
                - source_symbol
              type: object
              properties:
                amount:
                  type: string
                  description: The amount in whole units to convert
                  example: '50.50'
                destination:
                  type: string
                  description: The UUID of the destination wallet
                  example: e84255eb-2e21-439e-a1d0-f5dd1e1292b9
                idempotency_key:
                  type: string
                  description: The idempotency key associated with this conversion
                  example: e84255eb-2e21-439e-a1d0-f5dd1e1292b9
                source_symbol:
                  type: string
                  description: The currency symbol to convert from
                  example: USD
                destination_symbol:
                  type: string
                  description: The currency symbol to convert to
                  example: USDC
        required: true
      responses:
        '200':
          description: A successful response.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/coinbase.public_rest_api.CreateConversionResponse
components:
  schemas:
    coinbase.public_rest_api.CreateConversionResponse:
      type: object
      properties:
        activity_id:
          type: string
          description: The activity ID for the conversion
          example: e84255eb-2e21-439e-a1d0-f5dd1e1292b9
        source_symbol:
          type: string
          description: The currency symbol to convert from
          example: USD
        destination_symbol:
          type: string
          description: The currency symbol to convert to
          example: USDC
        amount:
          type: string
          description: The amount in whole units to convert
          example: '50.50'
        destination:
          type: string
          description: The UUID of the destination wallet
          example: e84255eb-2e21-439e-a1d0-f5dd1e1292b9
        source:
          type: string
          description: The UUID of the source wallet
          example: e84255eb-2e21-439e-a1d0-f5dd1e1292b9
        transaction_id:
          type: string
          description: The UUID of the conversion transaction
          example: e84255eb-2e21-439e-a1d0-f5dd1e1292b9

````