# POST /api/v1/fixed-assets/from-transactions

> Create asset from transactions

- **Tag:** fixed-assets
- **Operation ID:** `create_asset_from_transactions_api_v1_fixed_assets_from_transactions_post`

## Description

Capitalize ledger transactions into a fixed asset.

Creates a fixed asset whose cost basis is the sum of the selected
transactions' absolute amounts. All transactions must belong to the
business and be assigned to `ledger_id` (typically an account tagged
depreciable/amortizable in the chart of accounts).

**Request Body:**
- `ledger_id`: Ledger the source transactions are assigned to (required)
- `transaction_ids`: Transactions to capitalize, at least one (required)
- `name`: Asset name, 1-255 chars (required)
- `useful_life_months`: Useful life in months, 1-600 (optional, defaults to 60)
- `depreciation_method`: straight_line, declining_balance, double_declining, units_of_production (optional, defaults to 'straight_line')
- `in_service_date`: In-service date, YYYY-MM-DD (optional, defaults to the latest transaction date)
- `salvage_value`: Salvage value in cents (optional, defaults to 0)
- `auto_place_in_service`: Place the asset in service immediately so depreciation can start (optional, defaults to true)

**Returns:** The created asset and its projected depreciation schedule.

## Authentication

Bearer token in `Authorization` header.
Required header: `x-business-id: <business uuid>`.

## Request body

Schema: `CreateAssetFromTransactionsRequest`

- `ledger_id` (string · required) — Ledger the source transactions are assigned to
- `transaction_ids` (array · string · required) — Transactions to capitalize into the asset
- `name` (string · required) — Asset name
- `useful_life_months` (integer) — Expected useful life in months
- `depreciation_method` (DepreciationMethod) → `DepreciationMethod` — Depreciation calculation method
- `in_service_date` (string · date) — In-service date (defaults to the latest transaction date when auto-placing in service)
- `salvage_value` (integer) — Estimated salvage value in cents
- `auto_place_in_service` (boolean) — Place the asset in service immediately so depreciation can start (otherwise it is created as a draft)

## Responses

### 201 — Successful Response

Schema: `SuccessEnvelope_CreateAssetFromTransactionsResponse_`

- `success` (boolean)
- `message` (string)
- `code` (string)
- `data` (CreateAssetFromTransactionsResponse)

### 400 — Bad Request - Invalid input

### 401 — Unauthorized - Authentication required

### 403 — Forbidden - Insufficient permissions

### 404 — Not Found - Resource does not exist

### 422 — Validation Error

Schema: `HTTPValidationError`

- `detail` (array · ValidationError) → `ValidationError`
  - `loc` (array · string | integer · required)
  - `msg` (string · required)
  - `type` (string · required)
  - `input` (object)
  - `ctx` (object)

## Code samples

### cURL

```bash
curl -X POST 'https://api.ondayzero.com/api/v1/fixed-assets/from-transactions' \
  -H 'Authorization: Bearer dz_your_token' \
  -H 'x-business-id: YOUR_BUSINESS_ID' \
  -H 'Content-Type: application/json' \
  -d '{
  "ledger_id": "string",
  "transaction_ids": [],
  "name": "string"
}'
```

### JavaScript

```javascript
const response = await fetch('https://api.ondayzero.com/api/v1/fixed-assets/from-transactions', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer dz_your_token',
    'x-business-id': 'YOUR_BUSINESS_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
  "ledger_id": "string",
  "transaction_ids": [],
  "name": "string"
}),
});
const data = await response.json();
```

### Python

```python
import httpx

headers = {
    "Authorization": "Bearer dz_your_token",
    "x-business-id": "YOUR_BUSINESS_ID",
}

payload = {
  "ledger_id": "string",
  "transaction_ids": [],
  "name": "string"
}

response = httpx.post("https://api.ondayzero.com/api/v1/fixed-assets/from-transactions", headers=headers, json=payload)
data = response.json()
```

## See also

- HTML version: https://www.ondayzero.com/docs/reference/fixed-assets/create-asset-from-transactions
- OpenAPI slice: https://www.ondayzero.com/docs/reference/fixed-assets/create-asset-from-transactions/openapi.json
- Other endpoints in **fixed-assets**: https://www.ondayzero.com/docs/reference/fixed-assets
