> ## 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 /actions

> Create a new action with one or more intents for cross-chain execution

## Endpoint

```http theme={null}
POST /actions
```

## Description

This is the **unified entry point** for creating cross-chain intents. An action groups related intents together and provides a single tracking ID. Each intent within an action can have its own execution mode and chain batches.

## Request Body

```typescript theme={null}
{
  user: Address;                           // User wallet address
  chainAuthorizations?: ChainAuth7702[];   // Required for 7702 mode
  intents: Intent[];                       // Array of intents (min 1)
}
```

### Execution Modes

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

<Tabs>
  <Tab title="7702">
    EIP-7702 mode uses delegate contract for execution.

    ```typescript theme={null}
    {
      mode: "7702",
      signatureType: string,
      signature: Hex,
      nbf: number,           // Not before timestamp
      exp: number,           // Expiration timestamp
      chainBatches: [{
        hash: Hex,
        chainId: number,
        tokenTransfers: TokenTransfer[],
        calls: Call[]
      }]
    }
    ```
  </Tab>

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

    Presigned transactions for execution by the solver.

    ```typescript theme={null}
    {
      mode: "non-7702:presign",
      chainBatches: [{
        chainId: number,
        tokenTransfers: TokenTransfer[],
        call: {
          to: Address,
          value: bigint,
          data: Hex,
          signature: Hex     // User's presigned tx signature
        }
      }]
    }
    ```
  </Tab>

  <Tab title="non-7702:on-demand">
    User sends transactions themselves, registers hash for solver fulfillment.

    ```typescript theme={null}
    {
      mode: "non-7702:on-demand",
      chainBatches: [{
        chainId: number,
        tokenTransfers: TokenTransfer[],
        call: {
          to: Address,
          value: bigint,
          data: Hex
        }
      }]
    }
    ```
  </Tab>
</Tabs>

### Schema Details

#### TokenTransfer

| Field    | Type                  | Description                                  |
| -------- | --------------------- | -------------------------------------------- |
| `from`   | `Address \| "solver"` | Sender address or "solver" for solver-funded |
| `to`     | `Address`             | Recipient address                            |
| `token`  | `Address`             | Token contract address                       |
| `amount` | `bigint`              | Amount in wei                                |

#### ChainAuthorization (7702 only)

| Field     | Type      | Required | Description              |
| --------- | --------- | -------- | ------------------------ |
| `address` | `Address` | Yes      | Address being authorized |
| `chainId` | `number`  | Yes      | Chain ID                 |
| `nonce`   | `number`  | Yes      | Authorization nonce      |
| `r`       | `Hex`     | Yes      | ECDSA signature R value  |
| `s`       | `Hex`     | Yes      | ECDSA signature S value  |
| `yParity` | `number`  | No       | Y parity (default: 0)    |

## Response

### Success Response (201)

```json theme={null}
{
  "actionId": "act_a1b2c3d4e5f6...",
  "intentIds": [
    "act_a1b2c3d4e5f6.../0",
    "act_a1b2c3d4e5f6.../1"
  ]
}
```

| Field       | Type       | Description                                        |
| ----------- | ---------- | -------------------------------------------------- |
| `actionId`  | `string`   | Unique action identifier                           |
| `intentIds` | `string[]` | Array of intent IDs (format: `{actionId}/{index}`) |

### Error Responses

<Accordion title="400 Bad Request">
  ```json theme={null}
  {
    "error": "schema validation failed",
    "issues": { /* Zod validation errors */ }
  }
  ```

  ```json theme={null}
  {
    "error": "chainAuthorizations required for 7702 intents"
  }
  ```
</Accordion>

## Example Request

```bash theme={null}
curl -X POST /actions \
  -H "Content-Type: application/json" \
  -d '{
    "user": "0x742d35Cc6634C0532925a3b844e4B7db0D6d8E5c",
    "chainAuthorizations": [{
      "address": "0x742d35Cc6634C0532925a3b844e4B7db0D6d8E5c",
      "chainId": 84532,
      "nonce": 1,
      "r": "0x...",
      "s": "0x...",
      "yParity": 0
    }],
    "intents": [{
      "mode": "7702",
      "signatureType": "eip712",
      "signature": "0x...",
      "nbf": 0,
      "exp": 1999999999,
      "chainBatches": [{
        "hash": "0x...",
        "chainId": 84532,
        "tokenTransfers": [{
          "from": "0x742d35Cc6634C0532925a3b844e4B7db0D6d8E5c",
          "to": "0xVenueAddress...",
          "token": "0xTokenAddress...",
          "amount": "1000000000000000000"
        }],
        "calls": [{
          "to": "0xTokenAddress...",
          "value": "0",
          "data": "0xa9059cbb..."
        }]
      }]
    }]
  }'
```

## Workflow

1. **Create Action**: Submit action with intents
2. **Track Progress**: Use returned `actionId` and `intentIds` to monitor status
3. **Execute Steps**: Call `POST /actions/:actionId/intents/:intentIndex/steps/:stepIndex` for each step

## Next Steps

After creating an action:

* [Get Action Status](/api-reference/endpoint/actions-get) - Monitor action and intent status
* [Execute Step](/api-reference/endpoint/actions-execute) - Execute individual steps
