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

# Build a new staking operation

> Builds a new staking operation containing a dynamic list of staking transactions based on the specified network, asset, address, and [custom options](/staking/staking-api/introduction/api-usage#staking-options).

It returns a StakingOperation resource, a unified interface for the entire staking process. Regardless of network complexity, the API abstracts away all the underlying details through it.
You can iterate through this resource to access each staking transaction and have them be signed and broadcasted to land the staking transaction onchain.

Read up more about the stake operation and how to interact with it [here](/staking/staking-api/introduction/the-staking-operation).




## OpenAPI

````yaml POST /v1/stake/build
openapi: 3.0.3
info:
  title: Coinbase Developer Platform API
  license:
    name: MIT License
    url: https://opensource.org/license/mit
  version: 0.0.1-alpha
servers:
  - url: https://api.cdp.coinbase.com/platform
security:
  - bearerAuth: []
tags:
  - name: Addresses
    description: Addresses belong to a wallet and are scoped to a network.
  - name: Assets
    description: Assets are the digital assets that can be held in a wallet.
  - name: Networks
    description: Blockchain networks that are supported by the platform.
  - name: Staking
    description: Staking operations and rewards for addresses on supported networks.
paths:
  /v1/stake/build:
    post:
      tags:
        - Staking
      summary: Build a new staking operation
      description: >
        Builds a new staking operation containing a dynamic list of staking
        transactions based on the specified network, asset, address, and [custom
        options](/staking/staking-api/introduction/api-usage#staking-options).


        It returns a StakingOperation resource, a unified interface for the
        entire staking process. Regardless of network complexity, the API
        abstracts away all the underlying details through it.

        You can iterate through this resource to access each staking transaction
        and have them be signed and broadcasted to land the staking transaction
        onchain.


        Read up more about the stake operation and how to interact with it
        [here](/staking/staking-api/introduction/the-staking-operation).
      operationId: buildStakingOperation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                network_id:
                  type: string
                  example: ethereum-mainnet
                  description: The ID of the blockchain network.
                asset_id:
                  type: string
                  example: ETH
                  description: The symbol of the asset being staked.
                address_id:
                  type: string
                  example: '0xfc807D1bE4997e5C7B33E4d8D57e60c5b0f02B1a'
                  description: >-
                    The onchain address from which the staking transaction
                    originates and is responsible for signing the transaction.
                action:
                  type: string
                  example: unstake
                  description: >-
                    The type of staking operation (`stake`, `unstake`,
                    `claim_stake`, etc.)
                options:
                  type: object
                  description: >-
                    Additional options for the staking operation. See
                    [here](/staking/staking-api/introduction/api-usage#staking-options)
                    for detailed options.
                  additionalProperties:
                    type: string
              required:
                - network_id
                - asset_id
                - address_id
                - action
                - options
      responses:
        '200':
          description: successful staking transaction generated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StakingOperation'
        default:
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error response
components:
  schemas:
    StakingOperation:
      description: A list of onchain transactions to help realize a staking action.
      type: object
      properties:
        id:
          type: string
          example: d91d652b-d020-48d4-bf19-5c5eb5e280c7
          description: The unique ID of the staking operation.
        wallet_id:
          type: string
          example: d91d652b-d020-48d4-bf19-5c5eb5e280c7
          description: The ID of the wallet that owns the address.
        network_id:
          type: string
          example: ethereum-hoodi
          description: The ID of the blockchain network.
        address_id:
          type: string
          example: '0xfc807D1bE4997e5C7B33E4d8D57e60c5b0f02B1a'
          description: The onchain address orchestrating the staking operation.
        status:
          type: string
          enum:
            - initialized
            - pending
            - complete
            - failed
            - unspecified
          description: The status of the staking operation.
        transactions:
          items:
            $ref: '#/components/schemas/Transaction'
          type: array
          description: The transaction(s) that will execute the staking operation onchain.
        metadata:
          type: object
          oneOf:
            - $ref: '#/components/schemas/NativeEthUnstakingMetadata'
      required:
        - id
        - network_id
        - address_id
        - status
        - transactions
      xml:
        name: staking_operation
    Error:
      description: An error response from the Coinbase Developer Platform API
      properties:
        code:
          description: >-
            A short string representing the reported error. Can be use to handle
            errors programmatically.
          maxLength: 5000
          type: string
        message:
          description: A human-readable message providing more details about the error.
          maxLength: 5000
          type: string
        correlation_id:
          description: >-
            A unique identifier for the request that generated the error. This
            can be used to help debug issues with the API.
          type: string
      required:
        - code
        - message
      type: object
      xml:
        name: error
    Transaction:
      description: An onchain transaction.
      type: object
      properties:
        network_id:
          type: string
          example: base-sepolia
          description: Blockchain network identifier.
        from_address_id:
          type: string
          example: '0xfc807D1bE4997e5C7B33E4d8D57e60c5b0f02B1a'
          description: The onchain address of the sender
        unsigned_payload:
          type: string
          description: >-
            The unsigned payload of the transaction. This is the payload that
            needs to be signed by the sender.
        signed_payload:
          type: string
          description: >-
            The signed payload of the transaction. This is the payload that has
            been signed by the sender.
        transaction_hash:
          type: string
          example: '0x53e11e94ebb2438d6ddcfa07dabc9b551d2f440f8363fea941083bc397a86a42'
          description: The hash of the transaction
        transaction_link:
          type: string
          description: >-
            The link to view the transaction on a block explorer. This is
            optional and may not be present for all transactions.
          example: >-
            https://sepolia.basescan.org/tx/0x53e11e94ebb2438d6ddcfa07dabc9b551d2f440f8363fea941083bc397a86a42
        status:
          type: string
          enum:
            - pending
            - signed
            - broadcast
            - complete
            - failed
            - unspecified
          description: The status of the transaction.
        content:
          type: object
          oneOf:
            - $ref: '#/components/schemas/EthereumTransaction'
      required:
        - network_id
        - from_address_id
        - unsigned_payload
        - status
      xml:
        name: transaction
    NativeEthUnstakingMetadata:
      type: array
      description: Additional metadata needed to power native eth unstaking.
      items:
        $ref: '#/components/schemas/SignedVoluntaryExitMessageMetadata'
    EthereumTransaction:
      type: object
      properties:
        from:
          type: string
          example: '0xfc807D1bE4997e5C7B33E4d8D57e60c5b0f02B1a'
          description: The onchain address of the sender.
        gas:
          type: integer
          format: uint64
          example: 1000
          description: The amount of gas spent in the transaction.
        gas_price:
          type: integer
          format: uint64
          example: 1000
          description: >-
            The price per gas spent in the transaction in atomic units of the
            native asset.
        hash:
          type: string
          example: '0x53e11e94ebb2438d6ddcfa07dabc9b551d2f440f8363fea941083bc397a86a42'
          description: >-
            The hash of the transaction as a hexadecimal string, prefixed with
            `0x`.
        input:
          type: string
          description: The input data of the transaction.
        nonce:
          type: integer
          format: uint64
          example: 136
          description: The nonce of the transaction in the source address.
        to:
          type: string
          example: '0xfc807D1bE4997e5C7B33E4d8D57e60c5b0f02B1a'
          description: The onchain address of the receiver.
        index:
          type: integer
          format: uint64
          example: 5
          description: The index of the transaction in the block.
        value:
          type: string
          example: '100'
          description: The value of the transaction in atomic units of the native asset.
        type:
          type: integer
          format: uint64
          example: 2
          description: >-
            The EIP-2718 transaction type. See
            https://eips.ethereum.org/EIPS/eip-2718 for more details.
        max_fee_per_gas:
          type: integer
          format: uint64
          example: 190
          description: >-
            The max fee per gas as defined in EIP-1559.
            https://eips.ethereum.org/EIPS/eip-1559 for more details.
        max_priority_fee_per_gas:
          type: integer
          format: uint64
          example: 100
          description: >-
            The max priority fee per gas as defined in EIP-1559.
            https://eips.ethereum.org/EIPS/eip-1559 for more details.
        priority_fee_per_gas:
          type: integer
          format: uint64
          example: 1000
          description: >-
            The confirmed priority fee per gas as defined in EIP-1559.
            https://eips.ethereum.org/EIPS/eip-1559 for more details.
        transaction_access_list:
          $ref: '#/components/schemas/EthereumTransactionAccessList'
          description: >-
            The transaction access list as defined in EIP-2930.
            https://eips.ethereum.org/EIPS/eip-2930 for more details.
        flattened_traces:
          type: array
          items:
            $ref: '#/components/schemas/EthereumTransactionFlattenedTrace'
            description: Traces associated with the transaction.
        block_timestamp:
          type: string
          format: date-time
          description: The timestamp of the block in which the event was emitted
          example: '2023-04-01T12:00:00Z'
        mint:
          type: string
          example: '0'
          description: >-
            This is for handling optimism rollup specific EIP-2718 transaction
            type field.
        rlp_encoded_tx:
          type: string
          example: >-
            0x02f582426882013d8502540be4008502540be41c830493e094a55416de5de61a0ac1aa8970a280e04388b1de4b6f843a4b66f1c0808080
          description: >-
            RLP encoded transaction as a hex string (prefixed with `0x`) for
            native compatibility with popular eth clients such as etherjs, viem
            etc.
      required:
        - from
        - to
      xml:
        name: ethereum_transaction
    SignedVoluntaryExitMessageMetadata:
      type: object
      description: >-
        Signed voluntary exit message metadata to be provided to beacon chain to
        exit a validator.
      properties:
        validator_pub_key:
          type: string
          example: >-
            8afc911804efa124d029ea06a13a2a7110e65a850ffe838624e4670f1da8cc82c6ed227d50a6f31249c7f783bca2b3fe
          description: The public key of the validator associated with the exit message.
        fork:
          type: string
          example: '0x04017000'
          description: The current fork version of the Ethereum beacon chain.
        signed_voluntary_exit:
          type: string
          description: >-
            A base64 encoded version of a json string representing a voluntary
            exit message.
      required:
        - validator_pub_key
        - fork
        - signed_voluntary_exit
    EthereumTransactionAccessList:
      type: object
      properties:
        access_list:
          type: array
          items:
            $ref: '#/components/schemas/EthereumTransactionAccess'
      xml:
        name: ethereum_transaction_access_list
    EthereumTransactionFlattenedTrace:
      type: object
      properties:
        error:
          type: string
        type:
          type: string
        from:
          type: string
        to:
          type: string
        value:
          type: string
        gas:
          type: integer
          format: uint64
        gas_used:
          type: integer
          format: uint64
        input:
          type: string
        output:
          type: string
        sub_traces:
          type: integer
          format: uint64
        trace_address:
          type: array
          items:
            type: integer
            format: uint64
        trace_type:
          type: string
        call_type:
          type: string
        trace_id:
          type: string
        status:
          type: integer
          format: uint64
        block_hash:
          type: string
        block_number:
          type: integer
          format: uint64
        transaction_hash:
          type: string
        transaction_index:
          type: integer
          format: uint64
      xml:
        name: ethereum_transaction_flattened_trace
    EthereumTransactionAccess:
      type: object
      properties:
        address:
          type: string
        storage_keys:
          type: array
          items:
            type: string
      xml:
        name: ethereum_transaction_access
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Enter your JSON Web Token (JWT) here. Refer to the [Generate
        JWT](/api-reference/authentication#2-generate-jwt-server-only) section
        of our Authentication docs for information on how to generate your
        Bearer Token.

````