{"openapi":"3.1.0","info":{"title":"POST /api/v1/fixed-assets/from-transactions","version":"1.0.0","description":"Create asset from transactions"},"servers":[{"url":"https://api.ondayzero.com","description":"Production"}],"paths":{"/api/v1/fixed-assets/from-transactions":{"post":{"tags":["fixed-assets"],"summary":"Create asset from transactions","description":"Capitalize ledger transactions into a fixed asset.\n\nCreates a fixed asset whose cost basis is the sum of the selected\ntransactions' absolute amounts. All transactions must belong to the\nbusiness and be assigned to `ledger_id` (typically an account tagged\ndepreciable/amortizable in the chart of accounts).\n\n**Request Body:**\n- `ledger_id`: Ledger the source transactions are assigned to (required)\n- `transaction_ids`: Transactions to capitalize, at least one (required)\n- `name`: Asset name, 1-255 chars (required)\n- `useful_life_months`: Useful life in months, 1-600 (optional, defaults to 60)\n- `depreciation_method`: straight_line, declining_balance, double_declining, units_of_production (optional, defaults to 'straight_line')\n- `in_service_date`: In-service date, YYYY-MM-DD (optional, defaults to the latest transaction date)\n- `salvage_value`: Salvage value in cents (optional, defaults to 0)\n- `auto_place_in_service`: Place the asset in service immediately so depreciation can start (optional, defaults to true)\n\n**Returns:** The created asset and its projected depreciation schedule.","operationId":"create_asset_from_transactions","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Authorization"}},{"name":"x-business-id","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Business-Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateAssetFromTransactionsRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessEnvelope_CreateAssetFromTransactionsResponse_"}}}},"400":{"description":"Bad Request - Invalid input","content":{"application/json":{"example":{"error":"validation_error","message":"Validation failed: due_date: Input should be a valid date","errors":{"due_date":"Input should be a valid date"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized - Missing/invalid token or no access to this business","content":{"application/json":{"example":{"error":"unauthorized","message":"Authentication required","code":"AUTH_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"error":"forbidden","message":"You don't have permission to access this resource","code":"AUTH_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"error":"not_found","message":"Resource not found","code":"NOT_FOUND_001","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"},"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"validation_error","message":"Validation failed: amount: Input should be a valid integer","errors":{"amount":"Input should be a valid integer"},"code":"GEN_002","request_id":"3f0e7c2a-9b4d-4e1a-8c6f-2d5b7a1e9c30"}}}}},"x-fastapi-operation-id":"create_asset_from_transactions_api_v1_fixed_assets_from_transactions_post"}}},"components":{"schemas":{"AssetStatus":{"type":"string","enum":["draft","active","fully_depreciated","disposed"],"title":"AssetStatus","description":"Fixed asset lifecycle status."},"CreateAssetFromTransactionsRequest":{"properties":{"ledger_id":{"type":"string","title":"Ledger Id","description":"Ledger the source transactions are assigned to"},"transaction_ids":{"items":{"type":"string"},"type":"array","minItems":1,"title":"Transaction Ids","description":"Transactions to capitalize into the asset"},"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","description":"Asset name"},"useful_life_months":{"type":"integer","maximum":600.0,"minimum":1.0,"title":"Useful Life Months","description":"Expected useful life in months","default":60},"depreciation_method":{"$ref":"#/components/schemas/DepreciationMethod","description":"Depreciation calculation method","default":"straight_line"},"in_service_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"In Service Date","description":"In-service date (defaults to the latest transaction date when auto-placing in service)"},"salvage_value":{"type":"integer","minimum":0.0,"title":"Salvage Value","description":"Estimated salvage value in cents","default":0},"auto_place_in_service":{"type":"boolean","title":"Auto Place In Service","description":"Place the asset in service immediately so depreciation can start (otherwise it is created as a draft)","default":true}},"type":"object","required":["ledger_id","transaction_ids","name"],"title":"CreateAssetFromTransactionsRequest","description":"Schema for creating a fixed asset from ledger transactions.\n\nCapitalizes the selected transactions of a (depreciation-tagged) ledger\ninto a single fixed asset whose cost basis is the sum of their absolute\namounts."},"CreateAssetFromTransactionsResponse":{"properties":{"asset":{"$ref":"#/components/schemas/FixedAssetResponse","description":"Created fixed asset"},"schedule":{"$ref":"#/components/schemas/DepreciationScheduleResponse","description":"Projected depreciation schedule for the asset"}},"type":"object","required":["asset","schedule"],"title":"CreateAssetFromTransactionsResponse","description":"Response for creating a fixed asset from transactions."},"DepreciationMethod":{"type":"string","enum":["straight_line","declining_balance","double_declining","units_of_production"],"title":"DepreciationMethod","description":"Depreciation calculation methods."},"DepreciationScheduleEntry":{"properties":{"period":{"type":"integer","title":"Period","description":"Period number (1-based)"},"period_date":{"type":"string","format":"date","title":"Period Date","description":"First day of the period"},"beginning_book_value":{"type":"integer","title":"Beginning Book Value","description":"Book value at start of period, in cents"},"depreciation_amount":{"type":"integer","title":"Depreciation Amount","description":"Depreciation for this period, in cents"},"accumulated_depreciation":{"type":"integer","title":"Accumulated Depreciation","description":"Cumulative depreciation, in cents"},"ending_book_value":{"type":"integer","title":"Ending Book Value","description":"Book value at end of period, in cents"}},"type":"object","required":["period","period_date","beginning_book_value","depreciation_amount","accumulated_depreciation","ending_book_value"],"title":"DepreciationScheduleEntry","description":"A single entry in a depreciation schedule."},"DepreciationScheduleResponse":{"properties":{"asset_id":{"type":"string","title":"Asset Id","description":"Asset ID"},"asset_name":{"type":"string","title":"Asset Name","description":"Asset name"},"original_cost":{"type":"integer","title":"Original Cost","description":"Original purchase cost in cents"},"salvage_value":{"type":"integer","title":"Salvage Value","description":"Estimated salvage value in cents"},"useful_life_months":{"type":"integer","title":"Useful Life Months","description":"Useful life in months"},"depreciation_method":{"$ref":"#/components/schemas/DepreciationMethod","description":"Depreciation method used"},"schedule":{"items":{"$ref":"#/components/schemas/DepreciationScheduleEntry"},"type":"array","title":"Schedule","description":"Period-by-period depreciation schedule"}},"type":"object","required":["asset_id","asset_name","original_cost","salvage_value","useful_life_months","depreciation_method","schedule"],"title":"DepreciationScheduleResponse","description":"Full depreciation schedule for an asset."},"DisposalMethod":{"type":"string","enum":["sold","traded","scrapped","lost","donated"],"title":"DisposalMethod","description":"How an asset was disposed."},"FixedAssetResponse":{"properties":{"name":{"type":"string","maxLength":255,"minLength":1,"title":"Name","description":"Asset name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description","description":"Asset description"},"asset_number":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Asset Number","description":"User-defined asset tracking number"},"serial_number":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Serial Number","description":"Manufacturer serial number"},"purchase_date":{"type":"string","format":"date","title":"Purchase Date","description":"Date the asset was purchased"},"original_cost":{"type":"integer","minimum":0.0,"title":"Original Cost","description":"Purchase cost in cents"},"salvage_value":{"type":"integer","minimum":0.0,"title":"Salvage Value","description":"Estimated salvage value in cents","default":0},"useful_life_months":{"type":"integer","maximum":600.0,"minimum":1.0,"title":"Useful Life Months","description":"Expected useful life in months","default":60},"depreciation_method":{"$ref":"#/components/schemas/DepreciationMethod","description":"Depreciation calculation method","default":"straight_line"},"location":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Location","description":"Physical location of the asset"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes","description":"Additional notes"},"id":{"type":"string","title":"Id","description":"Asset ID"},"category_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Id","description":"Asset category ID"},"category_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Category Name","description":"Asset category name"},"vendor_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Vendor Id","description":"Vendor ID"},"in_service_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"In Service Date","description":"Date placed in service"},"total_expected_units":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Total Expected Units","description":"Total expected units (units-of-production method)"},"units_used_to_date":{"type":"integer","title":"Units Used To Date","description":"Cumulative units used to date","default":0},"status":{"$ref":"#/components/schemas/AssetStatus","description":"Asset lifecycle status: draft, active, fully_depreciated, disposed"},"disposal_date":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Disposal Date","description":"Date the asset was disposed"},"disposal_amount":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Disposal Amount","description":"Sale/trade proceeds in cents"},"disposal_method":{"anyOf":[{"$ref":"#/components/schemas/DisposalMethod"},{"type":"null"}],"description":"How the asset was disposed"},"depreciable_amount":{"type":"integer","title":"Depreciable Amount","description":"Cost minus salvage value, in cents"},"accumulated_depreciation":{"type":"integer","title":"Accumulated Depreciation","description":"Total depreciation taken to date, in cents"},"book_value":{"type":"integer","title":"Book Value","description":"Current book value (cost - accumulated depreciation), in cents"},"monthly_depreciation_amount":{"type":"integer","title":"Monthly Depreciation Amount","description":"Monthly depreciation amount, in cents"},"remaining_life_months":{"type":"integer","title":"Remaining Life Months","description":"Remaining useful life in months"},"created_at":{"type":"string","format":"date-time","title":"Created At","description":"Record creation timestamp"},"updated_at":{"type":"string","format":"date-time","title":"Updated At","description":"Last update timestamp"}},"type":"object","required":["name","purchase_date","original_cost","id","status","depreciable_amount","accumulated_depreciation","book_value","monthly_depreciation_amount","remaining_life_months","created_at","updated_at"],"title":"FixedAssetResponse","description":"Schema for fixed asset response."},"SuccessEnvelope_CreateAssetFromTransactionsResponse_":{"properties":{"success":{"type":"boolean","title":"Success","default":true},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Code"},"data":{"anyOf":[{"$ref":"#/components/schemas/CreateAssetFromTransactionsResponse"},{"type":"null"}]}},"additionalProperties":true,"type":"object","title":"SuccessEnvelope[CreateAssetFromTransactionsResponse]"},"ErrorResponse":{"title":"ErrorResponse","type":"object","description":"Envelope returned by every non-2xx response. Branch on `code` (stable) rather than `message` (human-readable, may change).","required":["error","message","code"],"properties":{"error":{"type":"string","description":"Error category: `validation_error`, `unauthorized`, `forbidden`, `not_found`, `conflict`, `rate_limited`, `server_error`, or `service_unavailable`."},"message":{"type":"string","description":"Human-readable explanation, safe to show to end users."},"code":{"type":"string","description":"Stable machine-readable code in `CATEGORY_NNN` form (e.g. `NOT_FOUND_006`, `AUTH_010`, `GEN_002`)."},"request_id":{"type":"string","description":"Correlation id for support requests. Echoes the `x-request-id` request header when one was supplied."},"errors":{"type":"object","additionalProperties":{"type":"string"},"description":"Field-level validation messages keyed by field name. Present on 400/422 validation failures only."}}}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}