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

# POST Execute Step

> Execute a specific intent step based on execution mode

## Endpoint

```http theme={null}
POST /actions/:actionId/intents/:intentIndex/steps/:stepIndex
```

## Path Parameters

| Parameter     | Type     | Required | Description            |
| ------------- | -------- | -------- | ---------------------- |
| `actionId`    | `string` | Yes      | Action ID              |
| `intentIndex` | `number` | Yes      | Intent index (0-based) |
| `stepIndex`   | `number` | Yes      | Step index (0-based)   |

<Warning>
  `non-7702:presign` mode is **not yet implemented**. Only `7702` and `non-7702:on-demand` modes are currently functional.
</Warning>

## Request Body by Mode

<Tabs>
  <Tab title="7702">
    For EIP-7702 intents, simply trigger execution:

    ```json theme={null}
    {
      "action": "execute"
    }
    ```

    The solver executes the delegated calls using the stored authorization.
  </Tab>

  <Tab title="non-7702:presign (Not Implemented)">
    <Warning>
      This mode exists in schema but execution is not yet implemented.
    </Warning>

    For presigned transactions:

    **Register hash (store for later):**

    ```json theme={null}
    {
      "action": "register",
      "hash": "0xTransactionHash..."
    }
    ```

    **Execute (broadcast stored tx):**

    ```json theme={null}
    {
      "action": "execute"
    }
    ```
  </Tab>

  <Tab title="non-7702:on-demand">
    User sends their own transaction, then notifies the API:

    **Register (store hash only, for logging):**

    ```json theme={null}
    {
      "action": "register",
      "hash": "0xUserSubmittedTxHash..."
    }
    ```

    **Execute (verify tx + update balances + trigger solver):**

    ```json theme={null}
    {
      "action": "execute",
      "hash": "0xUserSubmittedTxHash..."
    }
    ```
  </Tab>
</Tabs>

## Response

### Success Response (200)

```json theme={null}
{
  "status": "success",
  "transactionHash": "0x..."
}
```

| Field             | Type     | Description                      |
| ----------------- | -------- | -------------------------------- |
| `status`          | `string` | Step status after execution      |
| `transactionHash` | `string` | Transaction hash (if applicable) |

### Already Processed (202)

If the step is not in `created` status:

```json theme={null}
{
  "status": "executing"
}
```

## Execution Flow

### 7702 Mode

1. Solver retrieves stored calls and authorization
2. Broadcasts transaction with delegated execution
3. Updates step status on confirmation

### non-7702:on-demand Mode

When `action: "execute"` with a transaction hash:

1. **Verify Transaction**: Check tx exists on-chain and succeeded
2. **Replay Prevention**: Reject if hash already processed
3. **Update Balances**: Credit user's Spice balance from token transfers
4. **Execute Solver Transfers**: Send tokens on destination chain(s)
5. **Auto-Advance**: Automatically execute remaining steps (solver transfers)

When `action: "register"`:

1. **Verify Transaction**: Check tx exists and succeeded
2. **Store Reference**: Save hash for tracking, no balance updates
3. **Status**: Set to `registered` instead of `success`

## Error Responses

### 400 Bad Request

```json theme={null}
{
  "error": "schema validation failed",
  "issues": { /* Validation details */ }
}
```

```json theme={null}
{
  "error": "Transaction already processed"
}
```

```json theme={null}
{
  "error": "Transaction failed or pending"
}
```

### 404 Not Found

```json theme={null}
{
  "error": "could not find intent",
  "actionId": "act_...",
  "intentIndex": 0,
  "stepIndex": 0
}
```

### 500 Internal Server Error

```json theme={null}
{
  "error": "error executing intent step",
  "actionId": "act_...",
  "intentIndex": 0,
  "stepIndex": 0,
  "message": "Error details..."
}
```

## Example Requests

### 7702 Mode

```bash theme={null}
curl -X POST /actions/act_abc123/intents/0/steps/0 \
  -H "Content-Type: application/json" \
  -d '{"action": "execute"}'
```

### non-7702:on-demand Mode

```bash theme={null}
# User sends their own transaction first, then:
curl -X POST /actions/act_abc123/intents/0/steps/0 \
  -H "Content-Type: application/json" \
  -d '{
    "action": "execute",
    "hash": "0x1234567890abcdef..."
  }'
```

## Notes

* Steps must be executed in order (0, 1, 2, ...)
* For `non-7702:on-demand`, the user is responsible for sending the source chain transaction
* After a successful `execute` action, remaining steps (solver transfers on destination chains) are auto-executed
