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

# Portfolio Execute

> Execute transactions for a portfolio

This endpoint allows you to execute transactions on behalf of a portfolio. It can be used for custom transactions, manual rebalancing, or any operation that requires using the portfolio's vault to interact with other contracts.

## Path Parameters

<ParamField path="portfolioId" type="string" required>
  The unique identifier of the portfolio
</ParamField>

## Query Parameters

<ParamField query="dryRun" type="boolean" default="false">
  If true, simulate the transaction without executing it on-chain
</ParamField>

## Request Headers

<ParamField header="X-API-KEY" type="string" required>
  Your API key
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be set to `application/json`
</ParamField>

## Request Body

<ParamField body="chainId" type="string" required>
  Chain ID for transaction execution
</ParamField>

<ParamField body="params" type="object" required>
  Transaction parameters

  <Expandable title="Properties">
    <ParamField body="calls" type="array or object" required>
      Transaction call(s) to execute. Can be a single call object or an array of call objects.

      <Expandable title="Call Object">
        <ParamField body="to" type="string" required>
          Contract address to call
        </ParamField>

        <ParamField body="data" type="string" required>
          Transaction calldata (hex-encoded)
        </ParamField>

        <ParamField body="value" type="string">
          Amount of native token to send with the call (in wei)
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="nonce" type="string">
      Optional nonce to use for the transaction
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="Properties">
    <ResponseField name="executionId" type="string">
      Unique identifier for this execution request
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status of the execution (e.g., "pending", "completed", "failed")
    </ResponseField>

    <ResponseField name="transaction" type="object">
      Transaction details

      <Expandable title="Transaction Object">
        <ResponseField name="hash" type="string">
          Transaction hash (if submitted)
        </ResponseField>

        <ResponseField name="data" type="string">
          Transaction data
        </ResponseField>

        <ResponseField name="from" type="string">
          Address sending the transaction
        </ResponseField>

        <ResponseField name="to" type="string">
          Address receiving the transaction
        </ResponseField>

        <ResponseField name="chainId" type="string">
          Chain ID for the transaction
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="simulation" type="object">
      Simulation results (if dryRun=true)

      <Expandable title="Simulation Object">
        <ResponseField name="success" type="boolean">
          Whether the simulation was successful
        </ResponseField>

        <ResponseField name="gasEstimate" type="string">
          Estimated gas usage
        </ResponseField>

        <ResponseField name="trace" type="array">
          Execution trace information
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Check Execution Status

```
GET /portfolio/:portfolioId/execute/status/:executionId
```

This endpoint allows you to check the status of a previously submitted execution.

### Path Parameters

<ParamField path="portfolioId" type="string" required>
  The unique identifier of the portfolio
</ParamField>

<ParamField path="executionId" type="string" required>
  The execution identifier returned from the execute endpoint
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="Properties">
    <ResponseField name="status" type="string">
      Current status of the execution: "pending", "processing", "completed", "failed"
    </ResponseField>

    <ResponseField name="executionId" type="string">
      The execution identifier
    </ResponseField>

    <ResponseField name="transaction" type="object">
      Transaction details

      <Expandable title="Transaction Object">
        <ResponseField name="hash" type="string">
          Transaction hash
        </ResponseField>

        <ResponseField name="status" type="string">
          Transaction status: "pending", "confirmed", "failed"
        </ResponseField>

        <ResponseField name="blockNumber" type="number">
          Block number (if confirmed)
        </ResponseField>

        <ResponseField name="timestamp" type="number">
          Timestamp of transaction confirmation (if confirmed)
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="result" type="object">
      Execution result (if completed)

      <Expandable title="Result Object">
        <ResponseField name="success" type="boolean">
          Whether the execution succeeded
        </ResponseField>

        <ResponseField name="gasUsed" type="string">
          Amount of gas used
        </ResponseField>

        <ResponseField name="events" type="array">
          Events emitted by the transaction
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="error" type="object">
      Error information (if failed)

      <Expandable title="Error Object">
        <ResponseField name="code" type="string">
          Error code
        </ResponseField>

        <ResponseField name="message" type="string">
          Error message
        </ResponseField>

        <ResponseField name="details" type="string">
          Detailed error information
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Example Request

```bash theme={null}
curl -X POST "https://api.glider.fi/portfolio/port_1a2b3c4d5e6f/execute" \
  -H "X-API-KEY: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "chainId": "1",
    "params": {
      "calls": [
        {
          "to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "data": "0xa9059cbb000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045000000000000000000000000000000000000000000000000000000002540be400",
          "value": "0"
        }
      ]
    }
  }'
```

## Example Response

```json theme={null}
{
  "success": true,
  "data": {
    "executionId": "exec_a1b2c3d4e5f6",
    "status": "pending",
    "transaction": {
      "hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
      "data": "0x...",
      "from": "0x1234...5678",
      "to": "0xA0b8...eB48",
      "chainId": "1"
    }
  }
}
```

## Example Status Check

```bash theme={null}
curl -X GET "https://api.glider.fi/portfolio/port_1a2b3c4d5e6f/execute/status/exec_a1b2c3d4e5f6" \
  -H "X-API-KEY: YOUR_API_KEY"
```

## Example Status Response

```json theme={null}
{
  "success": true,
  "data": {
    "status": "completed",
    "executionId": "exec_a1b2c3d4e5f6",
    "transaction": {
      "hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
      "status": "confirmed",
      "blockNumber": 16123456,
      "timestamp": 1684147200
    },
    "result": {
      "success": true,
      "gasUsed": "51234",
      "events": [
        {
          "name": "Transfer",
          "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "args": {
            "from": "0x1234...5678",
            "to": "0xd8da...6045",
            "value": "1000000000"
          }
        }
      ]
    }
  }
}
```

## Error Codes

<ResponseField name="NOT_FOUND" type="404">
  The specified portfolio or execution ID could not be found
</ResponseField>

<ResponseField name="UNAUTHORIZED" type="401">
  Invalid or missing API key
</ResponseField>

<ResponseField name="FORBIDDEN" type="403">
  The API key does not have permission to execute transactions for this portfolio
</ResponseField>

<ResponseField name="BAD_REQUEST" type="400">
  The request body is invalid or missing required fields
</ResponseField>

<ResponseField name="SIMULATION_FAILED" type="400">
  Transaction simulation failed
</ResponseField>

<ResponseField name="EXECUTION_FAILED" type="500">
  Transaction execution failed
</ResponseField>

## Notes

* Use the `dryRun` parameter to simulate transactions before executing them
* The execution process is asynchronous - use the status endpoint to check completion
* Transactions are executed through the portfolio's vault, which must have sufficient permissions and balances
* For security reasons, transactions have built-in limits and validations to protect portfolio assets
* Multiple calls can be batched into a single transaction for efficiency
