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

> Create asset from transactions

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

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

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 401 — Unauthorized - Missing/invalid token or no access to this business

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 403 — Forbidden - Insufficient permissions

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

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

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

### 422 — Validation Error

Schema: `ErrorResponse`

- `error` (string · required) — Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`.
- `message` (string · required) — Human-readable explanation, safe to show to end users.
- `code` (string · required) — Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`).
- `request_id` (string) — Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied.
- `errors` (object) — Field-level validation messages keyed by field name. Present on 400/422 validation failures only.

## 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 (markdown bundle: https://www.ondayzero.com/docs/reference/fixed-assets.md, OpenAPI: https://www.ondayzero.com/docs/reference/fixed-assets/openapi.json)
- Endpoint catalog: https://www.ondayzero.com/docs/reference/index.md
