{"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_api_v1_fixed_assets_from_transactions_post","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":{"detail":"Invalid request parameters"}}}},"401":{"description":"Unauthorized - Authentication required","content":{"application/json":{"example":{"detail":"Not authenticated"}}}},"403":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"example":{"detail":"Not enough permissions"}}}},"404":{"description":"Not Found - Resource does not exist","content":{"application/json":{"example":{"detail":"Resource not found"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"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."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"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]"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Token","description":"API token authentication. Format: `Bearer dz_...`"}}},"security":[{"BearerAuth":[]}]}