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

# Create Transaction

> Create on-chain transactions for a contract: initialize it, start a distribution, or fund a direct transfer.

Create the on-chain transaction(s) for a distribution contract. The request
body is a discriminated union keyed on `action` — each action requires a
different set of fields.

**Route:** `POST /api/external/v1/transactions/create`

## Headers

| Header              | Required | Description                |
| ------------------- | -------- | -------------------------- |
| `Content-Type`      | Yes      | Must be `application/json` |
| `x-magna-api-token` | Yes      | Your Magna API token       |

## Body parameters

The `action` field selects the operation:

### `INITIALIZE`

Initializes a distribution contract.

| Field           | Type           | Required | Description                 |
| --------------- | -------------- | -------- | --------------------------- |
| `action`        | `"INITIALIZE"` | Yes      | Operation type              |
| `contractId`    | string (uuid)  | Yes      | Contract to initialize      |
| `adminWalletId` | string (uuid)  | Yes      | Admin wallet that will sign |

### `START_DISTRIBUTION`

Starts (and funds) a distribution for the given allocations.

| Field           | Type                   | Required | Description                           |
| --------------- | ---------------------- | -------- | ------------------------------------- |
| `action`        | `"START_DISTRIBUTION"` | Yes      | Operation type                        |
| `contractId`    | string (uuid)          | Yes      | Contract the allocations belong to    |
| `tokenId`       | string (uuid)          | Yes      | Token of the allocations              |
| `allocationIds` | string\[] (uuid)       | Yes      | Allocations to start (min 1)          |
| `adminWalletId` | string (uuid)          | No       | Admin wallet that will sign           |
| `fundTill`      | string (ISO date)      | No       | Fund the distribution up to this date |
| `memo`          | string                 | No       | Optional memo                         |

### `FUND_DISTRIBUTION`

Funds a direct-transfer distribution.

| Field                 | Type                  | Required | Description                                |
| --------------------- | --------------------- | -------- | ------------------------------------------ |
| `action`              | `"FUND_DISTRIBUTION"` | Yes      | Operation type                             |
| `tokenId`             | string (uuid)         | Yes      | Token of the allocations                   |
| `data`                | array                 | Yes      | List of `{ allocationId, amount }` (min 1) |
| `data[].allocationId` | string (uuid)         | Yes      | Allocation to fund                         |
| `data[].amount`       | number                | Yes      | Amount to fund (positive)                  |
| `isTest`              | boolean               | No       | Run as a test transaction                  |

## Request example

```sh theme={null}
curl -X POST https://app.magna.so/api/external/v1/transactions/create \
-H 'Content-Type: application/json' \
-H 'x-magna-api-token: YOUR_API_KEY' \
-d '{
  "action": "START_DISTRIBUTION",
  "contractId": "c1...uuid",
  "tokenId": "b3...uuid",
  "allocationIds": ["a1...uuid", "a2...uuid"]
}'
```

## Response example

```json theme={null}
{
  "transactions": [
    { "transactionId": "t1...uuid", "status": "PENDING" },
    { "transactionId": "t2...uuid", "status": "PENDING" }
  ]
}
```

Build the signable parameters for each returned `transactionId` with
[Transaction Signing Parameters](/apis/admin/transactions/transaction-signing-parameters),
then track progress with [Transaction Status](/apis/admin/transactions/transaction-status).
