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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://developers.fireblocks.com/feedback

```json
{
  "path": "/api-reference/earn-beta/create-and-execute-a-lending-action-deposit-or-withdraw",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Create and execute a lending action (deposit or withdraw)

> Creates and runs a sequence of on-chain steps for either a deposit into or a withdrawal from an earn
vault/market. Specify the operation with `action` in the request body (`DEPOSIT` or `WITHDRAW`).

**Note:** This endpoint is currently in beta and might be subject to changes.




## OpenAPI

````yaml https://docs.fireblocks.com/api/v1/swagger.yaml post /earn/actions
openapi: 3.0.0
info:
  title: Fireblocks API
  description: >
    Fireblocks provides a suite of applications to manage digital asset
    operations and a complete development platform to build your business on the
    blockchain.


    - Visit our website for more information: [Fireblocks
    Website](https://fireblocks.com)

    - Visit our developer docs: [Fireblocks
    DevPortal](https://developers.fireblocks.com)
  version: 1.6.2
  contact:
    email: developers@fireblocks.com
servers:
  - url: https://api.fireblocks.io/v1
    description: Fireblocks Production Environment Base URL
  - url: https://sandbox-api.fireblocks.io/v1
    description: Fireblocks Sandbox Environment Base URL
security: []
paths:
  /earn/actions:
    post:
      tags:
        - Earn (Beta)
      summary: Create and execute a lending action (deposit or withdraw)
      description: >
        Creates and runs a sequence of on-chain steps for either a deposit into
        or a withdrawal from an earn

        vault/market. Specify the operation with `action` in the request body
        (`DEPOSIT` or `WITHDRAW`).


        **Note:** This endpoint is currently in beta and might be subject to
        changes.
      operationId: createEarnAction
      parameters:
        - $ref: '#/components/parameters/X-Idempotency-Key'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEarnActionRequest'
      responses:
        '200':
          description: OK
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateEarnActionResponse'
        '400':
          description: >-
            Bad request: missing/invalid fields, unsupported amount, or
            malformed payload.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '403':
          description: >-
            Forbidden: insufficient permissions, disabled feature, or restricted
            provider.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '404':
          description: >-
            Not found: requested resource does not exist (e.g., opportunity,
            provider, or wallet).
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '429':
          description: 'Rate limit exceeded: slow down and retry later.'
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        '500':
          description: Internal error while processing the request.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/X-Request-ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorSchema'
        default:
          $ref: '#/components/responses/Error'
      x-codeSamples:
        - lang: TypeScript
          source: >-
            const response:
            Promise<FireblocksResponse<CreateEarnActionResponse>> =
            fireblocks.earnBeta.createEarnAction(earnBetaApiCreateEarnActionRequest);
        - lang: Java
          source: >-
            CompletableFuture<ApiResponse<CreateEarnActionResponse>> response =
            fireblocks.earnBeta().createEarnAction(createEarnActionRequest,
            idempotencyKey);
        - lang: Python
          source: >-
            response =
            fireblocks.earn_beta.create_earn_action(create_earn_action_request,
            idempotency_key);
components:
  parameters:
    X-Idempotency-Key:
      name: Idempotency-Key
      in: header
      description: >-
        A unique identifier for the request. If the request is sent multiple
        times with the same idempotency key, the server will return the same
        response as the first request. The idempotency key is valid for 24
        hours.
      required: false
      schema:
        type: string
  schemas:
    CreateEarnActionRequest:
      type: object
      properties:
        action:
          type: string
          description: Whether to deposit into or withdraw from the lending opportunity.
          example: DEPOSIT
          enum:
            - DEPOSIT
            - WITHDRAW
        opportunityId:
          type: string
          description: Identifier of the vault or market (lending opportunity).
          example: morpho-usdc-vault-1
        vaultAccountId:
          type: string
          description: Fireblocks vault account that will execute the action.
          example: '12345'
        amount:
          type: string
          description: >-
            Human-readable token amount (e.g. "1.6") or the keyword "max" for
            the full position or available balance.
          example: '1000.0'
      required:
        - action
        - opportunityId
        - vaultAccountId
        - amount
    CreateEarnActionResponse:
      type: object
      properties:
        id:
          type: string
          description: ActionIntent UUID for tracking the lending action workflow.
          example: 550e8400-e29b-41d4-a716-446655440000
        status:
          type: string
          description: Lifecycle status (e.g. CREATED, IN_PROGRESS, COMPLETED).
          example: CREATED
          enum:
            - CREATED
            - IN_PROGRESS
            - COMPLETED
            - CANCELED
            - FAILED
      required:
        - id
        - status
    ErrorSchema:
      type: object
      properties:
        message:
          type: string
        code:
          type: number
  headers:
    X-Request-ID:
      schema:
        type: string
      description: >-
        Unique ID correlated to the API request. Please provide it in any
        support ticket you create or on Github issues related to Fireblocks SDKs
  responses:
    Error:
      description: Error Response
      headers:
        X-Request-ID:
          $ref: '#/components/headers/X-Request-ID'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorSchema'

````