{"openapi":"3.0.0","info":{"title":"Manglai Public API","summary":"Manglai API for Carbon Footprint Management","description":"Manglai API for Carbon Footprint Management","contact":{"email":"admin@manglai.io","name":"Manglai Support","url":"https://manglai.io"},"termsOfService":"https://manglai.io/privacy","version":"1.0"},"components":{"securitySchemes":{"apiTokenAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"parameters":{"PaginationPage":{"name":"page","in":"query","description":"Page number (1-based).","required":false,"schema":{"type":"integer","minimum":1,"default":1}},"PaginationLimit":{"name":"limit","in":"query","description":"Maximum items per page. Use pagination for large datasets. Recommended maximum is 200.","required":false,"schema":{"type":"integer","minimum":1,"maximum":200,"default":200}}},"schemas":{"Mapping":{"type":"object","description":"One value of the company's source system and the Manglai value it maps to.","properties":{"id":{"type":"string"},"companyId":{"type":"string"},"integrationCode":{"type":"string","description":"Integration the mapping belongs to, for example unifikas."},"type":{"type":"string","enum":["input","unit"],"description":"Manglai catalogue the value maps to. input is the catalogue of /api/v1/inputs (fuels, vehicle fuels and refrigerant gases); unit is the catalogue of /api/v1/units."},"externalCode":{"type":"string","description":"Identifier of the value in the source system."},"externalName":{"type":"string","description":"Label of the value in the source system."},"code":{"type":"string","nullable":true,"description":"Manglai code. Null when Manglai has no equivalent for the external value."},"name":{"type":"string","nullable":true,"description":"Manglai label of the code."},"inputTypes":{"type":"array","items":{"type":"string"},"description":"Only for type input. Types of the Manglai input (fuel, vehicleFuel, gasLeak). Empty when code is null."}}},"List":{"type":"object","properties":{"data":{"type":"array","description":"The list of items.","items":{"type":"object","description":"The item of model.","properties":{"id":{"type":"string","description":"The unique identifier of the item."}}}},"pagination":{"type":"object","description":"The pagination of the list.","properties":{"page":{"type":"number","description":"The page number."},"limit":{"type":"number","description":"The limit of the list.","maximum":200},"total":{"type":"number","description":"The total of the list."}}}}},"EmissionsDashboard":{"allOf":[{"$ref":"#/components/schemas/Dashboard"},{"type":"object","properties":{"total":{"type":"object","properties":{"total":{"type":"object","properties":{"emissions":{"type":"number"},"numberOfEmissions":{"type":"integer"}}}}},"monthly":{"type":"object","properties":{"[ month: string ]":{"type":"object","properties":{"building":{"type":"object"},"category":{"type":"object"},"categoryByBuilding":{"type":"object"},"company":{"type":"object"},"emissions":{"type":"number"},"numberOfEmissions":{"type":"integer"},"uncertainty":{"type":"object","properties":{"fe":{"type":"number"},"da":{"type":"number"}}}}}}},"scope":{"type":"object","properties":{"[ scopeCode: string ]":{"type":"object","properties":{"id":{"type":"string"},"color":{"type":"string"},"emissionSources":{"type":"array","items":{"type":"string","nullable":true}},"emissions":{"type":"number"},"numberOfEmissions":{"type":"integer"},"uncertainty":{"type":"object","properties":{"fe":{"type":"number"},"da":{"type":"number"}}},"name":{"type":"string"},"code":{"type":"string"}}}}},"category":{"type":"object","properties":{"[ categoryCode: string ]":{"type":"object","properties":{"id":{"type":"string"},"color":{"type":"string"},"emissions":{"type":"number"},"numberOfEmissions":{"type":"integer"},"uncertainty":{"type":"object","properties":{"fe":{"type":"number"},"da":{"type":"number"}}},"name":{"type":"string"},"code":{"type":"string"},"parents":{"type":"object","properties":{"[ parentType: string ]":{"type":"string"}}}}}}},"subcategory":{"type":"object","properties":{"[ subcategoryCode: string ]":{"type":"object","properties":{"id":{"type":"string"},"emissions":{"type":"number"},"numberOfEmissions":{"type":"integer"},"uncertainty":{"type":"object","properties":{"fe":{"type":"number"},"da":{"type":"number"}}},"name":{"type":"string"},"code":{"type":"string"},"color":{"type":"string"},"parents":{"type":"object","properties":{"[ parentType: string ]":{"type":"string"}}},"emissionSources":{"type":"array","items":{"type":"string","nullable":true}}}}}}}}]},"EmissionGasBreakdown":{"type":"object","description":"CO2e per gas, in emissionsUnit. The four values sum to the emissions figure they accompany.","properties":{"co2":{"type":"number"},"ch4":{"type":"number"},"n2o":{"type":"number"},"other":{"type":"number"}}},"EmissionAirPollutantBreakdown":{"type":"object","description":"Mass of each air-quality pollutant (not CO2e), in airPollutantsUnit. Only present for companies with the air-pollutants feature.","properties":{"nox":{"type":"number"},"co":{"type":"number"},"pt":{"type":"number"},"hc":{"type":"number"}}},"EmissionsByBuilding":{"type":"object","properties":{"company":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}},"building":{"type":"object","description":"The requested building or, when only a vehicle is requested, the vehicle's own building.","properties":{"id":{"type":"string"},"name":{"type":"string"},"externalId":{"type":"string","nullable":true}}},"period":{"type":"object","properties":{"year":{"type":"integer"},"month":{"type":"integer"},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"}}},"filters":{"type":"object","properties":{"input":{"type":"object","description":"The code resolved from the inputCode parameter (a fuel, vehicle fuel, refrigerant gas, electricity or renewable energy type).","properties":{"code":{"type":"string"},"id":{"type":"string","nullable":true,"description":"Id of the Manglai input. Null for electricity and renewable energy types, which are not catalogue inputs."},"name":{"type":"string"},"types":{"type":"array","items":{"type":"string"},"description":"Types of the code (fuel, vehicleFuel, gasLeak, electricity, renewableEnergy)."}}},"vehicle":{"type":"object","properties":{"id":{"type":"string"},"externalId":{"type":"string","nullable":true},"licencePlate":{"type":"string"}}},"prorate":{"type":"boolean"},"includeVehicleConsumptions":{"type":"boolean","description":"Whether the consumptions of the vehicles assigned to the building are included."},"emissionsUnit":{"type":"string","enum":["kg","mt"],"description":"Unit of emissions and gases."},"airPollutantsUnit":{"type":"string","enum":["kg","mt"],"description":"Unit of airPollutants. Only present for companies with the air-pollutants feature."}}},"total":{"type":"object","properties":{"emissions":{"type":"number","description":"CO2e in emissionsUnit"},"numberOfConsumptions":{"type":"integer"},"numberOfEmissions":{"type":"integer"},"gases":{"$ref":"#/components/schemas/EmissionGasBreakdown"},"airPollutants":{"$ref":"#/components/schemas/EmissionAirPollutantBreakdown"}}},"consumptions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"externalId":{"type":"string","nullable":true},"source":{"type":"object","properties":{"type":{"type":"string","enum":["vehicle","invoice"]},"id":{"type":"string"},"externalId":{"type":"string","nullable":true},"licencePlate":{"type":"string"},"vehicleCategoryId":{"type":"string"},"invoiceType":{"type":"string","description":"Manglai invoice type of the source invoice. Legacy values are heat for combustion fuels and fuel for refrigerant gas leaks; the others are electricity, water, generated-energy, wastes, process-emissions and others."},"supplier":{"type":"string"},"renewableEnergyType":{"type":"string","description":"Renewable energy type of a generated-energy invoice (for example solartermia)."}}},"categoryId":{"type":"string"},"inputCode":{"type":"string","nullable":true,"description":"Manglai code of the consumption, the same value accepted by the inputCode parameter. Fuels, vehicle fuels and refrigerant gases come from extraData.fuelType; electricity consumptions report electricity and generated energy reports its renewable energy type. Null for consumptions without a code, such as water."},"quantity":{"type":"number","nullable":true},"unit":{"type":"string","nullable":true},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"appliedFraction":{"type":"number","description":"Share of the consumption period inside the requested period; 1 unless prorate applies."},"emissions":{"type":"number","description":"CO2e in emissionsUnit"},"gases":{"$ref":"#/components/schemas/EmissionGasBreakdown"},"airPollutants":{"$ref":"#/components/schemas/EmissionAirPollutantBreakdown"},"emissionDetails":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"categoryId":{"type":"string"},"emissions":{"type":"number"},"gases":{"$ref":"#/components/schemas/EmissionGasBreakdown"},"airPollutants":{"$ref":"#/components/schemas/EmissionAirPollutantBreakdown"}}}}}}}}},"Dashboard":{"type":"object","properties":{"monthly":{"type":"object","properties":{"[ month: string ]":{"type":"object","description":"A summary of the monthly dashboard."}}},"company":{"type":"object","properties":{"[ companyId: string ]":{"type":"number","description":"A summary of the company dashboard."}}},"building":{"type":"object","properties":{"[ buildingId: string ]":{"type":"number","description":"A summary of the building dashboard."}}},"category":{"type":"object","properties":{"[ categoryCode: string ]":{"type":"object","description":"A summary of the category dashboard."}}}}},"ConsumptionsDashboard":{"allOf":[{"$ref":"#/components/schemas/Dashboard"},{"type":"object","properties":{"building":{"type":"object","properties":{"[ buildingId: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"totalCost":{"type":"number"}}}}},"company":{"type":"object","properties":{"[ companyId: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"totalCost":{"type":"number"},"vehicleType":{"type":"object","properties":{"[ vehicleType: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"tonnes":{"type":"number"},"quantity":{"type":"number"}}}}},"supplier":{"type":"object","properties":{"[ supplierId: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"quantity":{"type":"number"},"tonnes":{"type":"number"}}}}}}}}},"entity":{"type":"object","properties":{"[ entityId: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"totalCost":{"type":"number"}}}}},"vehicleType":{"type":"object","properties":{"[ vehicleType: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"tonnes":{"type":"number"},"quantity":{"type":"number"}}}}},"supplier":{"type":"object","properties":{"[ supplierId: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"quantity":{"type":"number"},"tonnes":{"type":"number"}}}}},"totalEmissions":{"type":"number"},"count":{"type":"integer"},"totalCost":{"type":"number"},"quantity":{"type":"number"},"tonnes":{"type":"number"},"monthly":{"type":"object","properties":{"[ month: string ]":{"type":"object","properties":{"vehicleType":{"type":"object","properties":{"[ vehicleType: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"tonnes":{"type":"number"},"quantity":{"type":"number"}}}}},"supplier":{"type":"object","properties":{"[ supplierId: string ]":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"quantity":{"type":"number"},"tonnes":{"type":"number"}}}}}}}}}}}]}}},"security":[{"apiTokenAuth":[],"userAuth":[]}],"paths":{"/api/v1/purchased-goods/expenses":{"get":{"description":"Get a list of expenses","tags":["purchased-goods"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of expenses"}},"operationId":"getPurchasedGoodsExpenses"},"post":{"description":"Create or update an expense","tags":["purchased-goods"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","companyId","startDate","lines"],"properties":{"id":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"companyId":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"buildingId":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"transactionId":{"type":"string","description":"Invoice identifier","example":"INV-2024-001"},"startDate":{"type":"string","format":"date-time","example":"2024-01-01T00:00:00.000Z"},"endDate":{"type":"string","format":"date-time","example":"2024-01-31T00:00:00.000Z"},"totalAmount":{"type":"number","example":1210},"subTotalAmount":{"type":"number","example":1000},"totalTaxAmount":{"type":"number","example":210},"currency":{"type":"string","example":"EUR"},"expenseType":{"type":"string","enum":["goods","capital-goods","services-goods"]},"categoryCode":{"type":"string","description":"Input category code (e.g. from emission factor inputs). If not provided, AI will classify it automatically.","example":"STEEL"},"type":{"type":"string","description":"Calculation method","enum":["expense-base","activity-base"]},"productStatus":{"type":"string","enum":["primary-material-production","re-used","closed-loop-source"]},"client":{"type":"string","example":"Acme Corp"},"internalClassification":{"type":"string","example":"raw-materials"},"wasValidated":{"type":"boolean","example":false},"shouldEstimateQuantity":{"type":"boolean","description":"If true, AI will estimate material quantities from line descriptions","example":false},"removedAt":{"type":"string","format":"date-time","description":"Set to soft-delete the expense"},"lines":{"type":"array","items":{"type":"object","required":["id","concept","description"],"properties":{"id":{"type":"string","format":"uuid"},"externalId":{"type":"string"},"concept":{"type":"string","example":"Steel sheets"},"description":{"type":"string","example":"Cold-rolled steel sheets 1mm"},"netAmount":{"type":"number","example":500},"totalAmount":{"type":"number","example":605},"taxRate":{"type":"number","example":21},"quantity":{"type":"number","example":100},"unit":{"type":"string","example":"kg"}}}}}}}}},"responses":{"200":{"description":"Expense created or updated","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postPurchasedGoodsExpenses"}},"/api/v1/purchased-goods/expenses/dashboard":{"get":{"description":"Get aggregated dashboard metrics for expenses (totals by category, status, etc.)","tags":["purchased-goods"],"parameters":[{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"unit","in":"query","description":"Output unit for emissions (kg or mt). Defaults to kg.","required":false,"schema":{"type":"string","enum":["kg","mt"]}},{"name":"wasValidated","in":"query","description":"Filter by validation status (1 = validated, 0 = not validated)","required":false,"schema":{"type":"string","enum":["0","1"]}},{"name":"wasUnclassified","in":"query","description":"Filter by classification status (1 = unclassified, 0 = classified)","required":false,"schema":{"type":"string","enum":["0","1"]}},{"name":"filters","in":"query","description":"JSON-encoded filters object","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Aggregated dashboard metrics","content":{"application/json":{"schema":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"},"category":{"type":"object","additionalProperties":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"}}}},"categoryWithStatus":{"type":"object","additionalProperties":{"type":"object","properties":{"totalEmissions":{"type":"number"},"count":{"type":"integer"}}}}}}}}}},"operationId":"getPurchasedGoodsExpensesDashboard"}},"/api/v1/purchased-goods/expenses/alerts":{"get":{"description":"Aggregate purchased goods alert counts for the current filter scope","tags":["purchased-goods"],"operationId":"getPurchasedGoodsExpensesAlerts","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/product-use/config/series":{"get":{"description":"List the distinct equipment series present in the company group's product-use catalog","tags":["product-use"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"productType","in":"query","required":false,"description":"Narrows the series to a single product type","schema":{"type":"string"}}],"responses":{"200":{"description":"List of series","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"operationId":"getProductUseConfigSeries"}},"/api/v1/product-use/config/product-types":{"get":{"description":"List the distinct product types present in the company group's product-use catalog","tags":["product-use"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of product types","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"operationId":"getProductUseConfigProductTypes"}},"/api/v1/product-use/config/heating-types":{"get":{"description":"List the distinct heating types present in the company group's product-use catalog","tags":["product-use"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"productType","in":"query","required":false,"description":"Narrows the heating types to a single product type","schema":{"type":"string"}}],"responses":{"200":{"description":"List of heating types","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"operationId":"getProductUseConfigHeatingTypes"}},"/api/v1/product-use/config/data-origins":{"get":{"description":"List the distinct data origins present in the company group's product-use catalog","tags":["product-use"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of data origins","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"operationId":"getProductUseConfigDataOrigins"}},"/api/v1/mappings/units":{"get":{"description":"Units of measure of the company's source system and the Manglai unit each one maps to. `externalCode` and `externalName` are the identifier and label of the source system (for Unifikas, the unit OID and label of query 10192, such as `5` and `litros`). `code` is the Manglai unit code reported as `unit` by `/api/v1/emissions/by-building` and listed by `/api/v1/units`; `name` is its Manglai label. Rows carry the type `unit`. Empty when the company has no integration with mappings. Not paginated.","tags":["mappings"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Unit mappings of the company","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Mapping"}}}}}}},"409":{"description":"Invalid parameters"}},"operationId":"getMappingsUnits"}},"/api/v1/mappings/inputs":{"get":{"description":"Values of the company's source system that map to Manglai inputs, the catalogue of `/api/v1/inputs` (fuels, vehicle fuels and refrigerant gases). `externalCode` and `externalName` are the identifier and label in the source system (for Unifikas, the sub-aspect OID and name of catalogue 10202). `code` is the Manglai input code to send as `inputCode` to `/api/v1/emissions/by-building`, or null when Manglai has no input for that value (water, electricity, sub-meters...). `name` is the input's Manglai label and `inputTypes` its types (`fuel`, `vehicleFuel`, `gasLeak`), so a refrigerant is told apart from a fuel. The mapping is a translation and does not say whether the value is imported. Empty when the company has no integration with mappings. Not paginated.","tags":["mappings"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Input mappings of the company","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Mapping"}}}}}}},"409":{"description":"Invalid parameters"}},"operationId":"getMappingsInputs"}},"/api/v1/invoices/waste-with-recycled-percentage":{"post":{"description":"Create a waste invoice split into open-loop (recycled) and landfill (disposed) entries based on a recycled percentage. DEFRA-only — LER classification uses the standard bulk endpoint.\n","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","buildingId","startDate","endDate","wasteType","wasteMode","quantity","unit","percentageRecycled"],"properties":{"companyId":{"type":"string","format":"uuid"},"buildingId":{"type":"string","format":"uuid"},"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"},"wasteType":{"type":"string"},"wasteMode":{"type":"string","enum":["defra"]},"wasteDisposalMethod":{"type":"string"},"isHazardous":{"type":"boolean"},"lerCode":{"type":"string"},"lerCodeManage":{"type":"string"},"quantity":{"type":"number","description":"Must be > 0"},"unit":{"type":"string"},"totalCost":{"type":"string"},"currency":{"type":"string"},"percentageRecycled":{"type":"number","minimum":0,"maximum":100},"externalId":{"type":"string","description":"Optional. Kept on the non-recycled disposal invoice; the recycled (open-loop) invoice gets `{externalId}-2`.\n"},"historyId":{"type":"string","description":"Bulk import history id for grouped delete"},"status":{"type":"string","enum":["valid","draft"]},"countryCode":{"type":"string"},"supplier":{"type":"string"},"rawProvider":{"type":"string"},"details":{"type":"object","additionalProperties":true}}}}}},"responses":{"200":{"description":"Open-loop and landfill invoices created","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postInvoicesWasteWithRecycledPercentage"}},"/api/v1/invoices/waste-chronological":{"get":{"description":"Returns waste invoices (DIs) within the given date window for the chronological archive report, with `details.packingDate` (storage start date) computed on the fly by chaining each DI to the transport date of the previous DI in the same stream (companyId + nima/buildingId + lerCode).\n","tags":["invoices"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string"}},{"name":"startDate","in":"query","required":false,"schema":{"type":"string"}},{"name":"endDate","in":"query","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"Waste invoices with computed storage start dates."}},"operationId":"getInvoicesWasteChronological"}},"/api/v1/invoices/upload-invoice":{"post":{"summary":"Upload, scan & save an invoice","description":"Uploads an invoice file together with its metadata. The system will automatically scan the document, extract relevant data, and create or update the invoice in the database. If any step of the process (upload, scan, or save) fails, an exception is thrown.\n","tags":["invoices"],"consumes":["multipart/form-data"],"parameters":[{"in":"formData","name":"invoice","type":"file","required":true,"description":"Invoice file to be uploaded and scanned."},{"in":"query","name":"id","type":"string","required":false,"description":"Unique identifier of the invoice."},{"in":"query","name":"companyId","type":"string","required":true,"description":"Company associated with the invoice. If the ai found a best match company, this will be ignored."},{"in":"query","name":"buildingId","type":"string","required":false,"description":"Used to associate the invoice with a building by default if the invoice does not contain it or ai cannot extract it. If the ai found a best match building, this will be ignored."},{"in":"query","name":"externalId","type":"string","required":false,"description":"External identifier for the invoice (optional)."},{"in":"query","name":"model","type":"string","required":false,"description":"Model used for processing (optional)."},{"in":"query","name":"documentType","type":"string","required":false,"description":"Type of document (optional)."},{"in":"query","name":"prompt","type":"string","required":false,"description":"Prompt for processing (optional)."}],"responses":{"200":{"description":"Invoice successfully uploaded, scanned, and stored.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"invoice":{"$ref":"#/definitions/Invoice"}}}}}},"400":{"description":"Bad request — missing required fields, invalid metadata, or file not provided."},"409":{"description":"Conflict — invoice with the same ID already exists."},"422":{"description":"Unprocessable entity — scan or validation failed."},"500":{"description":"Internal server error during upload, scan, or save operation."}},"operationId":"postInvoicesUploadInvoice"}},"/api/v1/invoices/split-by-building":{"post":{"description":"Create a parent invoice and split it across one or more buildings using a distribution metric (square metres or employee count). Requires the company to have the estimations feature flag enabled. An empty `buildingIds` array splits across every building of the company.\n","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","metric","startDate","endDate","type","supplier","totalCost","lines"],"properties":{"companyId":{"type":"string","format":"uuid"},"buildingIds":{"type":"array","description":"Empty array splits across all company buildings","items":{"type":"string","format":"uuid"}},"metric":{"type":"string","enum":["m2","employees"]},"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"},"type":{"type":"string","description":"Invoice type (heat, fuel, electricity, water, wastes, ...)"},"currency":{"type":"string"},"supplier":{"type":"string"},"rawProvider":{"type":"string"},"totalCost":{"type":"string"},"lines":{"type":"array","minItems":1,"items":{"type":"object","required":["quantity"],"properties":{"quantity":{"type":"number"},"unit":{"type":"string"},"fuel":{"type":"string"},"type":{"type":"string"},"categoryId":{"type":"string"},"gdo":{"type":"string"},"emissionFactor":{"type":"number"},"renewablePercentage":{"type":"number"}}}},"wasteType":{"type":"string"},"wasteDisposalMethod":{"type":"string"},"wasteMode":{"type":"string","enum":["lerCode","defra"]},"isHazardous":{"type":"boolean"},"lerCode":{"type":"string"},"lerCodeManage":{"type":"string"},"nima":{"type":"string"},"status":{"type":"string","enum":["valid","draft"]},"countryCode":{"type":"string"},"details":{"type":"object","additionalProperties":true}}}}}},"responses":{"200":{"description":"Splitted invoices created","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postInvoicesSplitByBuilding"}},"/api/v1/invoices/save-bulk":{"post":{"description":"Insert or update many invoices in one request. Each item is upserted independently: a failing invoice does not abort the rest, it comes back with its own error. Invoices sharing an externalId are saved sequentially to avoid duplicating them.\n","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","invoices"],"properties":{"companyId":{"type":"string","description":"Fallback company for invoices without companyId."},"invoices":{"type":"array","minItems":1,"items":{"$ref":"#/definitions/Invoice"}}}}}}},"responses":{"200":{"description":"Per-invoice result","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"saved":{"type":"number"},"failed":{"type":"number"},"results":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"externalId":{"type":"string"},"status":{"type":"string","enum":["ok","error"]},"invoiceId":{"type":"string"},"errorCode":{"type":"string"},"error":{"type":"string"}}}}}}}}},"400":{"description":"Missing companyId, empty invoices array or too many invoices"}},"operationId":"postInvoicesSaveBulk"}},"/api/v1/invoices/restore-bulk":{"post":{"description":"Restore soft-deleted invoices by id within a company","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","ids"],"properties":{"companyId":{"type":"string","format":"uuid"},"ids":{"type":"array","items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Invoices restored"}},"operationId":"postInvoicesRestoreBulk"}},"/api/v1/invoices/recalculate-bulk":{"post":{"description":"Recalculate emissions for up to 40 invoices by id within a company","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","ids"],"properties":{"companyId":{"type":"string","format":"uuid"},"ids":{"type":"array","minItems":1,"maxItems":40,"items":{"type":"string","format":"uuid"}}}}}}},"responses":{"200":{"description":"Per-invoice recalculation result"}},"operationId":"postInvoicesRecalculateBulk"}},"/api/v1/invoices":{"get":{"description":"Get a list of invoices","tags":["invoices"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"startDate","in":"query","description":"Start date","required":true,"schema":{"type":"string"}},{"name":"endDate","in":"query","description":"End date","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of invoices"}},"operationId":"getInvoices"},"post":{"summary":"Insert or update an invoice","description":"Creates a new invoice record or updates an existing one based on its unique identifier (`id`). This endpoint supports multiple invoice types (e.g. heat, fuel, electricity, wastes, etc.). - If the `id` exists, the record is updated. - If the `id` does not exist, a new record is inserted.\n⚠️ **Special rules:** - `emissionFactor` in `lines` is **optional**. - `companySplitOriginalValues` is **optional**. - `wasteType` and `wasteDisposalMethod` are **required only when `type = waste`**.\n","tags":["invoices"],"consumes":["application/json"],"parameters":[{"in":"body","name":"invoice","description":"Invoice data to be inserted or updated.","required":true,"schema":{"type":"object","required":["id","type","companyId","totalCost","currency","startDate","endDate"],"properties":{"id":{"type":"string","description":"Unique identifier of the invoice."},"type":{"type":"string","description":"Type of the invoice.","enum":["heat","fuel","electricity","generated-energy","process-emissions","water","wastes","wastes-expenses","others","waste-water"]},"companyId":{"type":"string","description":"Company associated with the invoice."},"buildingId":{"type":"string","description":"Building associated with the invoice."},"cup":{"type":"string","description":"Unique identifier for the invoice (e.g., CUP code)."},"totalCost":{"type":"number","description":"Total cost of the invoice."},"currency":{"type":"string","description":"Currency of the invoice (e.g., USD, EUR)."},"startDate":{"type":"string","format":"date","description":"Start date of the invoice period."},"endDate":{"type":"string","format":"date","description":"End date of the invoice period."},"supplier":{"type":"string","description":"Supplier name."},"rawProvider":{"type":"string","description":"Raw provider for the invoice."},"wasteType":{"type":"string","description":"Waste type (⚠️ required only if `type = waste`)."},"wasteDisposalMethod":{"type":"string","description":"Waste disposal method (⚠️ required only if `type = waste`)."},"status":{"type":"string","description":"Invoice status.","enum":["valid","draft"]},"lines":{"type":"array","description":"Line items associated with the invoice.","items":{"type":"object","required":["quantity","unit"],"properties":{"fuel":{"type":"string"},"type":{"type":"string"},"quantity":{"type":"number","description":"Quantity of the item."},"unit":{"type":"string","description":"Measurement unit (e.g., kWh, liters)."},"emissions":{"type":"number","description":"Emissions associated with the line item (in kg of CO2e)."},"emissionFactor":{"type":"number","description":"Emission factor (optional)."},"gdo":{"type":"string"},"prevGdo":{"type":"string"},"regoId":{"type":"string"},"renewablePercentage":{"type":"number"},"emissionEntityId":{"type":"string"}}}},"attachedFilePath":{"type":"string","description":"Path to the attached file."},"removedAt":{"type":"string","format":"date","description":"Date when the invoice was removed."},"countryCode":{"type":"string","description":"ISO country code of the company (e.g., ES, FR)."},"externalId":{"type":"string","description":"External identifier for the invoice."},"splitPercentage":{"type":"number","description":"Percentage for splitting the invoice."},"splitYear":{"type":"number","description":"Year associated with the split."},"splitId":{"type":"string","description":"Identifier of the split."},"wasValidated":{"type":"boolean","description":"Indicates if the invoice was validated."},"validation":{"type":"object","description":"Validation data for the invoice."},"relationalId":{"type":"string","description":"Relational ID for the invoice."},"companySplitOriginalValues":{"type":"object","description":"Snapshot of values before splitting. ⚠️ Optional: only provided if the invoice was split.\n","properties":{"quantity":{"type":"number"},"totalCost":{"type":"number"},"configurationSnapshot":{"type":"object"}}}}}}],"responses":{"200":{"description":"Invoice successfully inserted or updated.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"invoice":{"$ref":"#/definitions/Invoice"}}}}}},"400":{"description":"Bad request — missing required fields or invalid data."},"500":{"description":"Internal server error during upsert operation."}},"operationId":"postInvoices"}},"/api/v1/invoices/estimation-by-buildings-avg":{"post":{"description":"Generate an estimated invoice for a target building based on the average of sibling buildings in the same company, normalized by the chosen metric (m2 or employees).\n","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["buildingId","startDate","endDate","type"],"properties":{"buildingId":{"type":"string","format":"uuid","description":"Building that receives the estimated invoice"},"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"},"type":{"type":"string","description":"Invoice type (electricity, combustion, water, waste-water, ...)"},"metric":{"type":"string","enum":["m2","employees"],"default":"m2"}}}}}},"responses":{"200":{"description":"Estimated invoice created","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postInvoicesEstimationByBuildingsAvg"}},"/api/v1/invoices/delete-bulk":{"delete":{"description":"Delete many invoices by id within a company","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","ids"],"properties":{"companyId":{"type":"string","format":"uuid"},"ids":{"type":"array","items":{"type":"string","format":"uuid"}},"deleteAllCompanySplitRelatedInvoices":{"type":"boolean","description":"If true, also deletes all split-related invoices linked to the given ids"}}}}}},"responses":{"200":{"description":"Invoices deleted","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}},"400":{"description":"Missing companyId or empty ids array"}},"operationId":"deleteInvoicesDeleteBulk"}},"/api/v1/invoices/estimation-by-buildings-avg/bulk":{"post":{"description":"Bulk generate estimated invoices for buildings without consumption in the selected period, using the average per m² from sibling buildings. Supports dry-run preview and per-building execution.\n","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","startDate","endDate","type"],"properties":{"companyId":{"type":"string","format":"uuid"},"type":{"type":"string"},"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"},"excludedBuildingIds":{"type":"array","items":{"type":"string"}},"dryRun":{"type":"boolean","default":false},"buildingIds":{"type":"array","items":{"type":"string"},"description":"Required when dryRun is false"}}}}}},"responses":{"200":{"description":"Bulk estimation preview or execution result"}},"operationId":"postInvoicesEstimationByBuildingsAvgBulk"}},"/api/v1/investments":{"get":{"description":"Get a list of investments","tags":["investments"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"A list of investments"}},"operationId":"getInvestments"}},"/api/v1/investments/dashboard":{"get":{"description":"Get a summary of investments","tags":["investments"],"parameters":[{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"startDate","in":"query","description":"Start date","required":true,"schema":{"type":"string"}},{"name":"endDate","in":"query","description":"End date","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of investments"}},"operationId":"getInvestmentsDashboard"}},"/api/v1/goals":{"get":{"description":"Get a list of goals","tags":["goals"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"operationId":"getGoals","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/goals/generate-report":{"get":{"description":"Generate and download a goals action-plan report as a .docx document","tags":["goals"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"year","in":"query","required":true,"schema":{"type":"integer"}},{"name":"language","in":"query","required":true,"schema":{"type":"string","example":"en"}},{"name":"scopes","in":"query","description":"List of emission scopes to include","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"Word document containing the action plan report","content":{"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{"schema":{"type":"string","format":"binary"}}}}},"operationId":"getGoalsGenerateReport"}},"/api/v1/goals/tasks":{"get":{"description":"Get a list of tasks","tags":["goals"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"ownerId","in":"query","description":"OwnerId","required":false,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"status","in":"query","description":"Status","required":false,"schema":{"type":"string"}},{"name":"priority","in":"query","description":"Priority","required":false,"schema":{"type":"string"}},{"name":"currentYear","in":"query","description":"Current year","required":false,"schema":{"type":"number"}}],"responses":{"200":{"description":"A list of tasks"}},"operationId":"getGoalsTasks"}},"/api/v1/goals/{goalId}/tasks":{"post":{"description":"Create or update a task within a goal's action plan","tags":["goals"],"parameters":[{"name":"goalId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","goalId","companyId","name","status"],"properties":{"id":{"type":"string","format":"uuid"},"goalId":{"type":"string","format":"uuid"},"ownerId":{"type":"string","format":"uuid"},"companyId":{"type":"string","format":"uuid"},"buildingId":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":"string"},"estimationDescription":{"type":"string"},"categoryId":{"type":"string"},"reductionEstimation":{"type":"number"},"dateStart":{"type":"string","format":"date"},"dateEnd":{"type":"string","format":"date"},"status":{"type":"string","enum":["pending","in-progress","paused","canceled","done"]},"costEstimation":{"type":"number"},"savingsEstimation":{"type":"number"},"currency":{"type":"string"},"currentValue":{"type":"number"},"startValue":{"type":"number"},"endValue":{"type":"number"},"valueUnit":{"type":"string"},"position":{"type":"number"},"createdAt":{"type":"string","format":"date-time","nullable":true},"removedAt":{"type":"string","format":"date-time","nullable":true}}}}}},"responses":{"200":{"description":"Goal task created or updated","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postGoalsByIdTasks"}},"/api/v1/goals/{goalId}":{"post":{"description":"Create or update a goal. The path `goalId` is informational — the persisted id comes from the body.","tags":["goals"],"parameters":[{"name":"goalId","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","companyId","type","name","dateStart","dateCompromise","measurementFrequency"],"properties":{"id":{"type":"string","format":"uuid"},"companyId":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["absolute","intensity"]},"name":{"type":"string"},"dateStart":{"type":"string","format":"date"},"dateCompromise":{"type":"string","format":"date"},"measurementFrequency":{"type":"string"},"createdAt":{"type":"string","format":"date-time","nullable":true},"removedAt":{"type":"string","format":"date-time","nullable":true},"ownerId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Goal created or updated","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postGoalsById"}},"/api/v1/files/zip":{"post":{"description":"Download a set of tenant-scoped storage files as a single ZIP archive","tags":["files"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["files"],"properties":{"files":{"type":"array","minItems":1,"maxItems":200,"items":{"type":"object","required":["path","name"],"properties":{"path":{"type":"string","description":"GCS object key or storage URL under the caller's company prefix"},"name":{"type":"string","description":"File name inside the archive (de-duplicated server-side)"}}}},"zipName":{"type":"string","description":"Archive name without extension; defaults to \"files\""}}}}}},"responses":{"200":{"description":"ZIP archive containing the requested files","content":{"application/zip":{"schema":{"type":"string","format":"binary"}}}},"403":{"description":"A requested path is outside the caller's tenant scope or bucket allow-list"},"409":{"description":"Request body validation failed"}},"operationId":"postFilesZip"}},"/api/v1/emissions/total-by-year":{"get":{"description":"Total carbon emissions per year (t CO2e) for the requested scopes. Each year entry also carries `airPollutants` ({ nox, co, pt, hc } in kg of each substance, not CO2e) for companies with the `air-pollutants` feature; years without data are null.","tags":["emissions"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string"}},{"name":"companyIds","in":"query","description":"Explicit list of companies; overrides addChildrenRelations.","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"scopes","in":"query","description":"Scope codes to include (e.g. scope-1, scope-2, scope-3).","required":true,"schema":{"type":"array","items":{"type":"string"}}},{"name":"fromYear","in":"query","required":true,"schema":{"type":"integer"}},{"name":"toYear","in":"query","required":true,"schema":{"type":"integer"}},{"name":"addChildrenRelations","in":"query","description":"Include the companies below companyId in the organizational chart.","required":false,"schema":{"type":"boolean"}}],"responses":{"200":{"description":"Emissions per year"}},"operationId":"getEmissionsTotalByYear"}},"/api/v1/emissions/by-building":{"get":{"description":"Emissions of one building for a year or a month, optionally restricted to one input (fuel, vehicle fuel or refrigerant gas) and to one vehicle, with the total first (CO2e in kg unless `emissionsUnit=mt`, per-gas breakdown and, for companies with the `air-pollutants` feature, `airPollutants` of NOx/CO/PT/HC in kg unless `airPollutantsUnit=mt`) followed by every underlying consumption and its emission documents. Identify the building with `buildingId` or, when it was imported from an external system, with `buildingExternalId`; or ask for one vehicle alone with `vehicleId` or `vehicleExternalId`, and the building is the vehicle's own. A building answers its own consumptions plus those of the vehicles assigned to it unless `includeVehicleConsumptions=false`. Not paginated.","tags":["emissions"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string"}},{"name":"buildingId","in":"query","description":"Manglai building id. Required unless buildingExternalId, vehicleId or vehicleExternalId is given.","required":false,"schema":{"type":"string"}},{"name":"buildingExternalId","in":"query","description":"The building externalId (your own identifier). Mutually exclusive with buildingId.","required":false,"schema":{"type":"string"}},{"name":"vehicleId","in":"query","description":"Manglai vehicle id. Only the consumptions of that vehicle are returned. Without buildingId or buildingExternalId, the building is the vehicle's own. Mutually exclusive with vehicleExternalId.","required":false,"schema":{"type":"string"}},{"name":"vehicleExternalId","in":"query","description":"The vehicle externalId (your own identifier). Only the consumptions of that vehicle are returned. Without buildingId or buildingExternalId, the building is the vehicle's own.","required":false,"schema":{"type":"string"}},{"name":"year","in":"query","required":true,"schema":{"type":"integer"}},{"name":"month","in":"query","description":"1 to 12. Restricts the period to that calendar month.","required":false,"schema":{"type":"integer"}},{"name":"inputCode","in":"query","description":"Manglai input code, as translated from your own values by /api/v1/mappings/inputs. It accepts inputs of type fuel, vehicleFuel or gasLeak (for example b10, natural-gas, hfc-134a), including the company custom inputs (for example r-513-a); electricity, which returns every electricity consumption of the building whatever its voltage; and renewable energy types such as solartermia, which return the self-consumption (generated energy) of that type. Only consumptions of that code are returned; filters.input echoes the resolved code with its types. Unknown codes answer 400 INPUT_NOT_FOUND.","required":false,"schema":{"type":"string"}},{"name":"prorate","in":"query","description":"Default true. When true, a consumption whose period exceeds the requested year or month contributes the day-proportional share and reports it in appliedFraction. When false the whole consumption is included as soon as it overlaps the period.","required":false,"schema":{"type":"boolean"}},{"name":"includeVehicleConsumptions","in":"query","description":"Default true. When true, the building answers its own consumptions plus those of the vehicles and machinery assigned to it; when false, only its own (invoices). filters.includeVehicleConsumptions echoes it. It cannot be false together with vehicleId or vehicleExternalId.","required":false,"schema":{"type":"boolean"}},{"name":"emissionsUnit","in":"query","description":"Default kg. Unit of every emissions figure and per-gas breakdown, kg or mt (metric tonnes) of CO2e; filters.emissionsUnit echoes it. It does not change quantity, which keeps the unit of each consumption.","required":false,"schema":{"type":"string","enum":["kg","mt"]}},{"name":"airPollutantsUnit","in":"query","description":"Default kg. Unit of every airPollutants figure, kg or mt (metric tonnes) of each pollutant; filters.airPollutantsUnit echoes it. Only applies to companies with the `air-pollutants` feature.","required":false,"schema":{"type":"string","enum":["kg","mt"]}}],"responses":{"200":{"description":"Totals and consumptions of the building","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"data":{"$ref":"#/components/schemas/EmissionsByBuilding"}}}}}},"400":{"description":"Unknown inputCode"},"404":{"description":"Building or vehicle not found in the company"},"409":{"description":"Invalid parameters, or several buildings or vehicles share the externalId"}},"operationId":"getEmissionsByBuilding"}},"/api/v1/effluents":{"get":{"description":"Get a list of effluents","tags":["effluents"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"buildingId","in":"query","description":"Building id","required":false,"schema":{"type":"string"}},{"name":"type","in":"query","description":"Type of effluent (limit or quality)","required":false,"schema":{"type":"string","enum":["limit","quality"]}},{"name":"year","in":"query","description":"Year","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"A list of effluents"}},"operationId":"getEffluents"},"post":{"summary":"Insert or update an effluent","description":"Insert a new effluent record or update an existing one by its unique identifier.","tags":["effluents"],"consumes":["application/json"],"parameters":[{"in":"body","name":"effluent","description":"The effluent data to be inserted or updated.","required":true,"schema":{"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of the effluent."},"companyId":{"type":"string","description":"The company associated with the effluent."},"buildingIds":{"type":"array","items":{"type":"string"},"description":"The building IDs associated with the effluent."},"type":{"type":"string","description":"The type of the effluent.","enum":["limit","quality"]},"year":{"type":"number","description":"The year of the effluent data."},"dbo":{"type":"number","description":"Biochemical Oxygen Demand (mg/L)."},"dqo":{"type":"number","description":"Chemical Oxygen Demand (mg/L)."},"ss":{"type":"number","description":"Suspended Solids (mg/L)."},"pt":{"type":"number","description":"Total Phosphorus (mg/L)."},"nt":{"type":"number","description":"Total Nitrogen (mg/L)."}}}}],"responses":{"200":{"description":"Successfully inserted or updated the effluent.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}},"400":{"description":"Bad request, missing required fields or invalid data."},"500":{"description":"Internal server error during upsert operation."}},"operationId":"postEffluents"}},"/api/v1/effluents/{id}":{"delete":{"summary":"Delete an effluent","description":"Delete an effluent record by its unique identifier.","tags":["effluents"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the effluent to delete.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully deleted the effluent.","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}},"404":{"description":"Effluent not found."},"500":{"description":"Internal server error during delete operation."}},"operationId":"deleteEffluentsById"}},"/api/v1/custom-metrics":{"get":{"description":"Get a list of custom metrics","tags":["custom-metrics"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of custom metrics"}},"operationId":"getCustomMetrics"}},"/api/v1/custom-metrics/dashboard":{"get":{"description":"Get a summary of custom metrics","tags":["custom-metrics"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A summary of custom metrics"}},"operationId":"getCustomMetricsDashboard"}},"/api/v1/consumptions/dashboard":{"get":{"description":"Get a summary of consumptions filtered by company, date range, categories, buildings and entities (vehicle, invoice, survey answer...).","tags":["consumptions"],"parameters":[{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"startDate","in":"query","example":"2025-01-01","required":false,"schema":{"type":"string","format":"date"}},{"name":"endDate","in":"query","example":"2025-01-31","required":false,"schema":{"type":"string","format":"date"}},{"name":"categoryIds","in":"query","description":"List of category id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"entityIds","in":"query","description":"List of entity id (vehicleId, invoiceId, surveyAnswerId)","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"hasCountries","in":"query","description":"Include country-level data","required":false,"schema":{"type":"boolean"}},{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"}],"responses":{"200":{"description":"A summary of consumptions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConsumptionsDashboard"}}}}},"operationId":"getConsumptionsDashboard"}},"/api/v1/companies/{id}/waste-water/recalculate":{"get":{"description":"Read wastewater recalculation progress for the company tree (admin or impersonation)","tags":["companies"],"operationId":"getCompaniesByIdWasteWaterRecalculate","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"description":"Recreate auto-generated wastewater invoices from water invoices (admin or impersonation)","tags":["companies"],"operationId":"postCompaniesByIdWasteWaterRecalculate","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/companies/{id}/waste-water/organization":{"get":{"description":"List child companies and groups with custom wastewater configuration","tags":["companies"],"operationId":"getCompaniesByIdWasteWaterOrganization","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/companies/{id}/waste-water":{"get":{"description":"Get company-level wastewater configuration for a year","tags":["companies"],"operationId":"getCompaniesByIdWasteWater","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"description":"Upsert company-level wastewater configuration","tags":["companies"],"operationId":"postCompaniesByIdWasteWater","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/companies/{id}/waste-water/clear-configs":{"post":{"description":"Clear custom company or building wastewater configurations","tags":["companies"],"operationId":"postCompaniesByIdWasteWaterClearConfigs","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/companies/{id}/waste-water/buildings":{"get":{"description":"List buildings with custom wastewater configuration","tags":["companies"],"operationId":"getCompaniesByIdWasteWaterBuildings","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/comments":{"get":{"description":"Get a list of comments","tags":["comments"],"parameters":[{"$ref":"#/components/parameters/PaginationPage"},{"$ref":"#/components/parameters/PaginationLimit"},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"entityId","in":"query","description":"entity id (invoice id, vehicle consumption id)","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of comments","content":{"application/json":{"schema":{"$ref":"#/components/schemas/List"}}}}},"operationId":"getComments"}},"/api/v1/waste-operators":{"get":{"description":"Get a list of waste operators","tags":["waste-operators"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"}},{"name":"role","in":"query","description":"Only return waste operators with this role","required":false,"schema":{"type":"string","enum":["manager","carrier"]}},{"name":"externalId","in":"query","description":"ExternalId","required":false,"schema":{"type":"string"}},{"name":"query","in":"query","description":"Query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of waste operators"}},"operationId":"getWasteOperators"},"post":{"description":"Upsert a new waste operator","tags":["waste-operators"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","required":true,"format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"name":{"type":"string","required":true,"example":"John Doe"},"roles":{"type":"array","required":false,"minItems":1,"uniqueItems":true,"default":["manager"],"description":"Roles of the waste operator. One company can be both manager and carrier. Defaults to manager when omitted.","items":{"type":"string","enum":["manager","carrier"]},"example":["manager","carrier"]},"nima":{"type":"string","required":false,"example":"2800012345"},"cif":{"type":"string","required":false,"example":"B12345678"},"countryCode":{"type":"string","required":false,"example":"ES"},"email":{"type":"string","required":true,"example":"john@doe.com"},"address":{"type":"string","required":true,"example":"123 Main St, New York, NY 10001"},"companyId":{"type":"string","required":true,"format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"externalId":{"type":"string","required":false,"example":"123456789"}}}}}},"responses":{"200":{"description":"The waste operator","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"name":{"type":"string","example":"John Doe"},"email":{"type":"string"}}}}}}},"operationId":"postWasteOperators"}},"/api/v1/vehicles":{"get":{"description":"Get a list of vehicles","tags":["vehicles"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"licencePlates","in":"query","description":"Licence plates","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of vehicles"}},"operationId":"getVehicles"},"post":{"description":"Create or update a vehicle","tags":["vehicles"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["id","type","companyId","buildingId","licencePlate"],"properties":{"id":{"type":"string"},"type":{"type":"string"},"vehicleCategoryId":{"type":"string"},"motorType":{"type":"string"},"fuelTypeId":{"type":"string"},"companyId":{"type":"string"},"buildingId":{"type":"string"},"licencePlate":{"type":"string"},"transportType":{"type":"string"},"vehicleTransportSize":{"type":"string"},"control":{"type":"string","nullable":true},"operationalControl":{"type":"string","nullable":true},"startDate":{"type":"string","format":"date-time","nullable":true},"endDate":{"type":"string","format":"date-time","nullable":true},"brand":{"type":"string"},"class":{"type":"string"},"model":{"type":"string"},"removedAt":{"type":"string","format":"date-time","nullable":true},"isGeneric":{"type":"boolean","nullable":true}}}}}},"responses":{"200":{"description":"Vehicle created or updated"}},"operationId":"postVehicles"}},"/api/v1/vehicles/fleet-summary":{"get":{"description":"Get consolidated fleet summary with vehicle counts grouped by motor type (combustion, hybrid, electric) with scope labels","tags":["vehicles"],"parameters":[{"name":"companyId","in":"query","description":"Company ID","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"Filter by building IDs","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"Fleet summary with total count and breakdown by motor type"}},"operationId":"getVehiclesFleetSummary"}},"/api/v1/vehicles/dashboard":{"get":{"description":"Get a summary of vehicles","tags":["vehicles"],"parameters":[{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"startDate","in":"query","description":"Start date","required":true,"schema":{"type":"string"}},{"name":"endDate","in":"query","description":"End date","required":true,"schema":{"type":"string"}}],"operationId":"getVehiclesDashboard","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/vehicles/control-dashboard":{"get":{"description":"Get vehicle counts by control category (own, leased, subleased, services) for emission impact panel","tags":["vehicles"],"parameters":[{"name":"companyId","in":"query","description":"Company ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Counts and showPanel flag"}},"operationId":"getVehiclesControlDashboard"}},"/api/v1/vehicles/{id}":{"get":{"summary":"Retrieve a specific vehicle record","description":"Fetch details of a vehicle record by its unique identifier.","tags":["vehicles"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the vehicle record.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully retrieved the vehicle record."}},"operationId":"getVehiclesById"}},"/api/v1/users/invite":{"post":{"description":"Invite a user","tags":["users"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","description":"User email"},"companyId":{"type":"string","description":"Company id"},"roles":{"type":"array","description":"Roles of the user. The possible values are:\n- ROLE_OWNER # Business manager\n- ROLE_MANAGER # Inventory manager\n- ROLE_VALIDATOR # Validator\n- ROLE_VIEWER # Viewer\n","required":true,"items":{"type":"string","enum":["ROLE_OWNER","ROLE_MANAGER","ROLE_VALIDATOR","ROLE_VIEWER"]}}}},"examples":{"Business manager":{"value":{"email":"businessManager@manglai.io","companyId":"094cba11-9f25-4fc6-8398-c7d0c49a18b9","roles":["ROLE_OWNER"]}},"Inventory manager":{"value":{"email":"inventoryManager@manglai.io","companyId":"094cba11-9f25-4fc6-8398-c7d0c49a18b9","roles":["ROLE_MANAGER"]}}}}}},"responses":{"200":{"description":"The user"}},"operationId":"postUsersInvite"}},"/api/v1/users":{"get":{"description":"Get a list of users","tags":["users"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"A list of users"}},"operationId":"getUsers"},"post":{"description":"Create a new user","tags":["users"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","required":true,"format":"uuid"},"companies":{"type":"array","required":true,"items":{"type":"object","properties":{"companyId":{"required":true,"type":"string"}}}},"password":{"type":"string"},"language":{"type":"string","example":"es"},"name":{"type":"string"},"phone":{"type":"string"},"externalId":{"type":"string"},"roles":{"type":"string","example":"ROLE_OWNER","required":true,"enum":["ROLE_OWNER","ROLE_MANAGER","ROLE_VALIDATOR","ROLE_VIEWER"]}}}}}},"responses":{"200":{"description":"A new user"}},"operationId":"postUsers"},"patch":{"description":"Update user data fast (lastLoginAt)","tags":["users"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","required":true,"format":"uuid"}}}}}},"responses":{"200":{"description":"User data updated successfully"}},"operationId":"patchUsers"}},"/api/v1/tasks-and-reminders":{"get":{"description":"List task-and-reminder templates (recurring assignments that spawn individual user tasks)","tags":["tasks-and-reminders"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"userId","in":"query","required":false,"schema":{"type":"string","format":"uuid"}},{"name":"reporterId","in":"query","required":false,"schema":{"type":"string","format":"uuid"}},{"name":"category","in":"query","required":false,"schema":{"type":"string"}},{"name":"filters","in":"query","description":"JSON-encoded filters object","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Paginated list of task-and-reminder templates"}},"operationId":"getTasksAndReminders"},"post":{"description":"Create or update a task-and-reminder template","tags":["tasks-and-reminders"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","categories","userId","companyId","mode"],"properties":{"id":{"type":"string","format":"uuid"},"categories":{"type":"array","items":{"type":"string"}},"userId":{"type":"string","format":"uuid"},"reporterId":{"type":"string","format":"uuid"},"companyId":{"type":"string","format":"uuid"},"buildingIds":{"type":"array","items":{"type":"string","format":"uuid"}},"mode":{"type":"string"},"timeInterval":{"type":"string"},"executionDate":{"type":"string","format":"date","nullable":true},"startDate":{"type":"string","format":"date","nullable":true},"endDate":{"type":"string","format":"date","nullable":true},"reminderDelayPeriod":{"type":"string"},"sendMailNow":{"type":"boolean"},"lockValues":{"type":"boolean"},"creationMode":{"type":"string"},"creationModeDate":{"type":"string"}}}}}},"responses":{"200":{"description":"Task-and-reminder template created or updated","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postTasksAndReminders"}},"/api/v1/tasks-and-reminders/dashboard":{"get":{"description":"Aggregated dashboard for task-and-reminder templates and their derived user tasks","tags":["tasks-and-reminders"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"ids","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","format":"uuid"}}},{"name":"userId","in":"query","required":false,"schema":{"type":"string","format":"uuid"}},{"name":"reporterId","in":"query","required":false,"schema":{"type":"string","format":"uuid"}},{"name":"year","in":"query","required":false,"schema":{"type":"integer"}},{"name":"status","in":"query","required":false,"schema":{"type":"string"}},{"name":"category","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Aggregated dashboard metrics"}},"operationId":"getTasksAndRemindersDashboard"}},"/api/v1/tasks-and-reminders/{id}":{"get":{"description":"Get a single task-and-reminder template by id","tags":["tasks-and-reminders"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Task-and-reminder template"},"404":{"description":"Not found"}},"operationId":"getTasksAndRemindersById"},"delete":{"description":"Soft-delete a task-and-reminder template by id","tags":["tasks-and-reminders"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Task-and-reminder template deleted"}},"operationId":"deleteTasksAndRemindersById"}},"/api/v1/tasks":{"get":{"description":"List user tasks (instances of task-and-reminder templates assigned to a user)","tags":["tasks"],"parameters":[{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","required":false,"schema":{"type":"string","format":"uuid"}},{"name":"userId","in":"query","required":false,"schema":{"type":"string","format":"uuid"}},{"name":"reporterId","in":"query","required":false,"schema":{"type":"string","format":"uuid"}},{"name":"taskAndReminderIds","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","format":"uuid"}}},{"name":"year","in":"query","required":false,"schema":{"type":"integer"}},{"name":"status","in":"query","required":false,"schema":{"type":"string"}},{"name":"category","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Paginated list of user tasks"}},"operationId":"getTasks"},"post":{"description":"Create or update a user task","tags":["tasks"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id"],"properties":{"id":{"type":"string","format":"uuid"},"userTaskId":{"type":"string","format":"uuid"},"userId":{"type":"string","format":"uuid"},"reporterId":{"type":"string","format":"uuid"},"companyId":{"type":"string","format":"uuid"},"buildingId":{"type":"string","format":"uuid"},"description":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"doneAt":{"type":"string","format":"date-time","nullable":true},"validatedAt":{"type":"string","format":"date-time","nullable":true},"configuration":{"type":"object","additionalProperties":true},"removedAt":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"User task created or updated","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postTasks"}},"/api/v1/tasks/{id}":{"get":{"description":"Get a single user task by id","tags":["tasks"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"User task"},"404":{"description":"Not found"}},"operationId":"getTasksById"},"delete":{"description":"Soft-delete a user task by id","tags":["tasks"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"User task deleted"}},"operationId":"deleteTasksById"}},"/api/v1/surveys/alerts":{"get":{"description":"Aggregate survey alert counts for employee commuting participants","tags":["surveys"],"parameters":[{"name":"surveyId","in":"query","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"query","required":true,"schema":{"type":"string"}},{"name":"filters","in":"query","description":"JSON-encoded DynamicFilters payload","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Alert counts for the survey participants scope"}},"operationId":"getSurveysAlerts"}},"/api/v1/suppliers":{"get":{"description":"Get a list of suppliers","tags":["suppliers"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"}},{"name":"type","in":"query","description":"Type","required":false,"schema":{"type":"string","enum":["suppliers","clients"]}},{"name":"externalId","in":"query","description":"ExternalId","required":false,"schema":{"type":"string"}},{"name":"query","in":"query","description":"Query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of suppliers"}},"operationId":"getSuppliers"},"post":{"description":"Upsert a new supplier","tags":["suppliers"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","companyId","type"],"properties":{"id":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"name":{"type":"string","example":"John Doe"},"email":{"type":"string","example":"john@doe.com"},"address":{"type":"string","example":"123 Main St, New York, NY 10001"},"companyId":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"type":{"type":"string","enum":["suppliers","clients"]},"externalId":{"type":"string","example":"123456789"}}}}}},"responses":{"200":{"description":"The supplier","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"name":{"type":"string","example":"John Doe"},"email":{"type":"string"}}}}}}},"operationId":"postSuppliers"}},"/api/v1/service-footprint/glec":{"get":{"summary":"Retrieve the list of GLEC service footprint","description":"Fetch the list of GLEC service footprint.","tags":["service-footprint-glec"],"parameters":[{"name":"companyId","in":"query","description":"The unique identifier of the company.","required":true,"schema":{"type":"string"}},{"name":"clientId","in":"query","description":"The unique identifier of the client/supplier.","schema":{"type":"string"}},{"name":"vehicleId","in":"query","description":"The unique identifier of the vehicle.","schema":{"type":"string"}},{"name":"externalId","in":"query","description":"The unique identifier of the external service footprint entry.","schema":{"type":"string"}},{"name":"startDate","in":"query","description":"The start date of the period.","required":true,"schema":{"type":"string","format":"date"},"example":"2024-01-01"},{"name":"endDate","in":"query","description":"The end date of the period.","required":true,"schema":{"type":"string","format":"date"},"example":"2024-12-01"},{"name":"supplierId","in":"query","description":"The unique identifier of the supplier.","schema":{"type":"string"}},{"name":"clientId","in":"query","description":"The unique identifier of the client.","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response with emissions data","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"authorship":{"type":"object","properties":{"lastImpersonatedBy":{"type":"string","nullable":true},"lastModifiedBy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"roles":{"type":"array","items":{"type":"string"}},"isLoggedIn":{"type":"boolean"},"language":{"type":"string"},"company":{"type":"object","properties":{"classification":{"type":"string"}}}}},"owner":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"email":{"type":"string"},"roles":{"type":"array","items":{"type":"string"}},"isLoggedIn":{"type":"boolean"},"language":{"type":"string"},"company":{"type":"object","properties":{"classification":{"type":"string"}}}}},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"validation":{"type":"object"}}},"id":{"type":"string"},"companyId":{"type":"string"},"clientId":{"type":"string"},"externalId":{"type":"string","nullable":true},"startDate":{"type":"string","format":"date-time"},"endDate":{"type":"string","format":"date-time"},"load":{"type":"number"},"loadUnit":{"type":"string","enum":["kg","mt"],"example":"mt"},"from":{"type":"string"},"to":{"type":"string"},"distance":{"type":"number"},"actions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"mode":{"type":"string"},"vehicleId":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"},"distance":{"type":"number"},"load":{"type":"number"},"loadUnit":{"type":"string","enum":["kg","mt"],"example":"mt"},"energyQuantity":{"type":"string"},"driver":{"type":"string"},"emission":{"type":"number"},"emissions":{"type":"array","items":{"type":"object","properties":{"emission":{"type":"number"},"emissionFactorSnapshot":{"type":"object","properties":{"id":{"type":"string"},"countryCode":{"type":"string"},"entityName":{"type":"string"},"year":{"type":"integer"},"emissionFactor":{"type":"number"},"conversion":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"entity":{"type":"object","properties":{"fuelType":{"type":"string"},"fuelLifeCycle":{"type":"string"}}},"origin":{"type":"string"},"source":{"type":"string"},"unit":{"type":"string"},"unitType":{"type":"string"},"status":{"type":"string"}}}}}},"sourceEmission":{"type":"object","properties":{"energy":{"type":"number"},"distance":{"type":"number"}}},"sourceEmissions":{"type":"object","properties":{"energy":{"type":"array","items":{"type":"object","properties":{"emission":{"type":"number"},"emissionFactorSnapshot":{"type":"object","properties":{"id":{"type":"string"},"countryCode":{"type":"string"},"entityName":{"type":"string"},"year":{"type":"integer"},"emissionFactor":{"type":"number"},"conversion":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"entity":{"type":"object","properties":{"fuelType":{"type":"string"},"fuelLifeCycle":{"type":"string"}}},"origin":{"type":"string"},"source":{"type":"string"},"unit":{"type":"string"},"unitType":{"type":"string"},"status":{"type":"string"}}}}}},"distance":{"type":"array","items":{"type":"object","properties":{"emission":{"type":"number"},"emissionFactorSnapshot":{"type":"object","properties":{"id":{"type":"string"},"countryCode":{"type":"string"},"entityName":{"type":"string"},"year":{"type":"integer"},"emissionFactor":{"type":"number"},"conversion":{"type":"string","nullable":true},"description":{"type":"string","nullable":true},"entity":{"type":"object","properties":{"vehicleType":{"type":"string"},"vehicleCategoryType":{"type":"string"},"fuelType":{"type":"string"},"fuelLifeCycle":{"type":"string"}}},"origin":{"type":"string"},"source":{"type":"string"},"unit":{"type":"string"},"unitType":{"type":"string"},"status":{"type":"string"}}}}}}}}}}},"emission":{"type":"number"},"emissionByScope":{"type":"object","properties":{"scope-1":{"type":"number"},"scope-3":{"type":"number"}}},"sourceEmission":{"type":"object","properties":{"energy":{"type":"number"},"distance":{"type":"number"}}},"sourceEmissionByScope":{"type":"object","properties":{"energy":{"type":"object","properties":{"scope-1":{"type":"number"},"scope-3":{"type":"number"}}},"distance":{"type":"object","properties":{"scope-3":{"type":"number"},"scope-1":{"type":"number"}}}}}}}},"pagination":{"type":"object","properties":{"total":{"type":"integer"},"page":{"type":"integer"},"limit":{"type":"integer"}}}}}}}}},"operationId":"getServiceFootprintGlec"},"post":{"summary":"Create a new GLEC service footprint entry","description":"This endpoint creates a new entry for the GLEC service footprint.","tags":["service-footprint-glec"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","required":true,"format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"externalId":{"type":"string","example":""},"clientId":{"type":"string","format":"uuid","required":true,"example":"d0486f00-d1fc-4f96-95d3-155b038e98a7"},"startDate":{"type":"string","format":"date","required":true,"example":"2024-07-03"},"endDate":{"type":"string","format":"date","required":true,"example":"2024-07-18"},"actions":{"type":"array","required":true,"items":{"type":"object","properties":{"id":{"type":"string","format":"uuid","required":true,"example":"ba7b8856-2ee7-43b4-ae42-9017a0bc273b"},"externalId":{"type":"string","example":"123456789"},"mode":{"type":"string","required":true,"enum":["internal","external"],"example":"internal"},"vehicleId":{"type":"string","format":"uuid","example":"76aada41-80d3-4164-8dac-a1a638eccd16"},"from":{"type":"string","example":"Granada, Spain"},"to":{"type":"string","example":"Barcelona, Spain"},"distance":{"type":"string","example":"842.021"},"vehicleClassification":{"type":"string","description":"Vehicle classification (Only needed if the  classification vehicle is not defined)","example":"Trailer diésel / Articulado / 40 t GVW"},"vehicleType":{"type":"string","description":"Vehicle type (Only needed if the vehicleClassification is not defined)","example":"hgv_diesel","enum":["vans","hgv_diesel","flight","train"]},"transportType":{"oneOf":[{"type":"string","description":"Transport type (Only needed if the vehicleClassification is not 'hgv_diesel').","enum":["rigid","articulated","average"],"example":"articulated"},{"type":"string","description":"Transport type specific to flights (Only applicable if vehicleType is 'flight').","enum":["freighter","bellyFreight","average"],"example":"freighter"},{"type":"string","description":"Transport type specific to flights (Only applicable if vehicleType is 'train').","enum":["average"],"example":"average"},{"type":"string","description":"Transport type specific to flights (Only applicable if vehicleType is 'vans').","enum":["average"],"example":"average"}]},"vehicleTransportSize":{"oneOf":[{"type":"string","description":"Transport size (Only needed if the vehicleClassification is not \"hgv_diesel / rigid\").","enum":["3.5-7.5_t_gvw","7.5-12_t_gvw","12-20_t_gvw","20-26_t_gvw","26-32_t_gvw"],"example":"articulated"},{"type":"string","description":"Transport size (Only needed if the vehicleClassification is not \"hgv_diesel / articulated\").","enum":["34_t_gvw","40_t_gvw"],"example":"articulated"},{"type":"string","description":"Transport type specific to flights (Only applicable if vehicleType is 'vans / average').","enum":["<_3.5_t"],"example":"<_3.5_t"}]},"load":{"type":"number","example":"100"},"loadUnit":{"type":"string","enum":["kg","mt"],"example":"mt"},"licensePlate":{"type":"string","example":"123456789"},"energyQuantity":{"type":"string","example":"0.53"},"energyQuantityUnit":{"type":"string","enum":["l","kg","kwh","l/km","kg/km","kwh/km"],"example":"l/km"},"driver":{"type":"string","example":""},"hasCleaning":{"type":"boolean","example":true},"kind":{"type":"string","description":"Leg kind. Defaults to transport. A hub leg is a stop at a warehouse, platform or terminal (GLEC HOC); two consecutive hub legs are rejected.","enum":["transport","hub"],"example":"transport"},"hubId":{"type":"string","format":"uuid","description":"Hub legs only, required. Id of a hub of the company catalog (GET /api/v1/service-footprint/glec/hubs). hoc, hubName, mode, location and buildingId are copied from the catalog and override any value sent.","example":"0b4e3a2e-5f6c-4d1e-9a1b-2c3d4e5f6a7b"},"hoc":{"type":"string","description":"Hub legs only, read-only snapshot taken from the catalog hub. GLEC hub operation category.","enum":["hub-transshipment-ambient","hub-transshipment-mixed","hub-storage_transshipment-ambient","hub-storage_transshipment-mixed","hub-warehouse-ambient","hub-warehouse-mixed","hub-liquid_bulk_terminal-ambient","hub-liquid_bulk_terminal-mixed","hub-intermodal_terminal-ambient","hub-intermodal_terminal-temperature_controlled"],"example":"hub-storage_transshipment-ambient"},"hubName":{"type":"string","description":"Hub legs only, read-only snapshot of the catalog hub name.","example":"Plataforma Zaragoza"},"location":{"type":"string","description":"Hub legs only, read-only snapshot of the catalog hub address.","example":"Zaragoza, Spain"},"activityUnit":{"type":"string","description":"Hub legs only. Defaults to the hub defaultActivityUnit. Intermodal terminals use container; the rest use tonne or teu.","enum":["tonne","teu","container"],"example":"tonne"},"activityQuantity":{"type":"number","description":"Hub legs only, required. Outbound activity of the hub in activityUnit.","example":12},"containerCargoClass":{"type":"string","description":"Hub legs only, when activityUnit is teu. Converts TEU to tonnes (light 6 t, average 10 t, heavy 14.5 t).","enum":["light","average","heavy"],"example":"average"}}}},"from":{"type":"string","example":"Granada, Spain"},"to":{"type":"string","example":"Barcelona"},"companyId":{"type":"string","format":"uuid","example":"e72a084e-e2ca-4a28-831c-be00bad46a93"}},"required":["id","clientId","startDate","endDate","actions","companyId"]}}}},"responses":{"200":{"description":"Successfully created GLEC service footprint entry","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"GLEC service footprint entry created successfully."},"id":{"type":"string","format":"uuid","example":"557628f1-1969-4222-9172-fa66e1c378de"}}}}}},"400":{"description":"Bad request. Errors carry `{ errorCode, errorCodeSpecific, why, fix, extraData }`. Specific codes:\n- `LOGISTICS_SERVICE_INVALID_CHAIN`: two consecutive hub legs (`extraData.index` is the offending leg).\n- `HUB_HOC_UNKNOWN`: the hoc of a hub leg has no GLEC factor.\n- `HUB_ACTIVITY_MISSING`: a hub leg has no activityQuantity.\n- `HUB_ACTIVITY_UNIT_NOT_ALLOWED`: the activityUnit is not valid for that hoc.\n- `HUB_REQUIRES_CATALOG`: a hub leg has no hubId.\n"},"404":{"description":"`LOGISTICS_HUB_NOT_FOUND`: a hub leg references a hubId that does not belong to the company."},"409":{"description":"`LOGISTICS_SERVICE_ALREADY_EXIST`: another service of the company has the same externalId."},"500":{"description":"Internal server error"}},"operationId":"postServiceFootprintGlec"}},"/api/v1/service-footprint/glec/dashboard":{"get":{"summary":"Retrieve the dashboard of the GLEC service footprint","description":"Fetch the dashboard of the GLEC service footprint.","tags":["service-footprint-glec"],"parameters":[{"name":"companyId","in":"query","description":"The unique identifier of the company.","required":true,"schema":{"type":"string"}},{"name":"clientId","in":"query","description":"The unique identifier of the client/supplier.","required":true,"schema":{"type":"string"}},{"name":"vehicleId","in":"query","description":"The unique identifier of the vehicle.","required":true,"schema":{"type":"string"}},{"name":"externalId","in":"query","description":"The unique identifier of the external service footprint entry.","schema":{"type":"string"}},{"name":"startDate","in":"query","description":"The start date of the period.","required":true,"schema":{"type":"string","format":"date"}},{"name":"endDate","in":"query","description":"The end date of the period.","required":true,"schema":{"type":"string","format":"date"}},{"name":"calculationMode","in":"query","description":"The calculation mode.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response with emissions data","content":{"application/json":{"schema":{"type":"object","properties":{"monthly":{"type":"object","additionalProperties":{"type":"object","properties":{"totalEmissions":{"type":"number","format":"float","description":"Total emissions for the month in kilograms."},"numberOfServices":{"type":"integer","description":"Number of services for the month."}}}},"byClient":{"type":"object","additionalProperties":{"type":"object","properties":{"totalEmissions":{"type":"number","format":"float","description":"Total emissions for the client in kilograms."},"numberOfServices":{"type":"integer","description":"Number of services for the client."}}}},"mode":{"type":"object","properties":{"internal":{"type":"object","properties":{"totalEmissions":{"type":"number","format":"float","description":"Total emissions for internal services."},"numberOfActions":{"type":"integer","description":"Number of actions for internal services."}}},"external":{"type":"object","properties":{"totalEmissions":{"type":"number","format":"float","description":"Total emissions for external services."},"numberOfActions":{"type":"integer","description":"Number of actions for external services."}}}}},"emissionByScope":{"type":"object","properties":{"scope-1":{"type":"object","properties":{"totalEmissions":{"type":"number","format":"float","description":"Total Scope 1 emissions."}}},"scope-3":{"type":"object","properties":{"totalEmissions":{"type":"number","format":"float","description":"Total Scope 3 emissions."}}}}},"numberOfServices":{"type":"integer","description":"Total number of services."},"distance":{"type":"number","format":"float","description":"Total distance covered in kilometers."},"load":{"type":"integer","description":"Total load in tonnes."},"numberOfActions":{"type":"integer","description":"Total number of actions."},"totalEmissions":{"type":"number","format":"float","description":"Total emissions in kilograms."}}}}}}},"operationId":"getServiceFootprintGlecDashboard"}},"/api/v1/service-footprint/glec/{id}":{"delete":{"summary":"Delete a GLEC service footprint entry","description":"This endpoint deletes a GLEC service footprint entry.","tags":["service-footprint-glec"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the GLEC service footprint entry.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully deleted GLEC service footprint entry"},"400":{"description":"Bad request due to invalid input"},"500":{"description":"Internal server error"}},"operationId":"deleteServiceFootprintGlecById"}},"/api/v1/service-footprint/glec/hubs":{"get":{"summary":"List the logistics hubs (HOC) of a company","tags":["service-footprint-glec"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"page","in":"query","schema":{"type":"integer"}},{"name":"limit","in":"query","schema":{"type":"integer"}},{"name":"query","in":"query","description":"Matches hub name or externalId","schema":{"type":"string"}},{"name":"hoc","in":"query","schema":{"type":"string"}},{"name":"mode","in":"query","schema":{"type":"string","enum":["internal","external"]}}],"responses":{"200":{"description":"A paginated list of logistics hubs"}},"operationId":"getServiceFootprintGlecHubs","description":"List the logistics hubs (HOC) of a company"},"post":{"summary":"Create or update a logistics hub","tags":["service-footprint-glec"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","companyId","name","hoc","mode"],"properties":{"id":{"type":"string","format":"uuid"},"companyId":{"type":"string","format":"uuid"},"name":{"type":"string"},"externalId":{"type":"string"},"hoc":{"type":"string","example":"hub-storage_transshipment-ambient"},"mode":{"type":"string","enum":["internal","external"]},"buildingId":{"type":"string","description":"Required when mode is internal"},"supplierId":{"type":"string"},"location":{"type":"string"},"countryCode":{"type":"string"},"defaultActivityUnit":{"type":"string","enum":["tonne","teu","container"]}}}}}},"responses":{"200":{"description":"The saved logistics hub"},"400":{"description":"Bad request. Errors carry `{ errorCode, errorCodeSpecific, why, fix, extraData }`. Specific codes:\n- `HUB_HOC_UNKNOWN`: hoc is not one of the GLEC hub operation categories.\n- `HUB_BUILDING_REQUIRED`: mode is internal and buildingId is missing.\n- `HUB_BUILDING_NOT_IN_COMPANY`: buildingId does not exist or belongs to another company.\n- `HUB_SUPPLIER_NOT_IN_COMPANY`: supplierId does not exist or belongs to another company.\n"},"409":{"description":"`LOGISTICS_HUB_ALREADY_EXIST`: another hub of the company has the same name or externalId."}},"operationId":"postServiceFootprintGlecHubs","description":"Create or update a logistics hub"}},"/api/v1/service-footprint/glec/hubs/{id}":{"get":{"summary":"Get a logistics hub","tags":["service-footprint-glec"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The logistics hub"},"404":{"description":"`LOGISTICS_HUB_NOT_FOUND`: no hub with that id in the company."}},"operationId":"getServiceFootprintGlecHubsById","description":"Get a logistics hub"},"delete":{"summary":"Delete a logistics hub","description":"Soft deletes the hub. Fails with 409 when a non-removed logistics service references it.","tags":["service-footprint-glec"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Successfully deleted"},"404":{"description":"`LOGISTICS_HUB_NOT_FOUND`: no hub with that id in the company."},"409":{"description":"`LOGISTICS_HUB_IN_USE`: a non-removed logistics service references the hub. Remove or reassign those services first."}},"operationId":"deleteServiceFootprintGlecHubsById"}},"/api/v1/invoices/recalculate":{"post":{"description":"Recalculate emissions for all invoices sharing the given relationalId (splitted invoices group)","tags":["invoices"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["relationalId"],"properties":{"relationalId":{"type":"string","description":"Group identifier for splitted invoices"},"startDate":{"type":"string","format":"date","nullable":true},"endDate":{"type":"string","format":"date","nullable":true}}}}}},"responses":{"200":{"description":"Recalculation result","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"invoice":{"type":"object"}}}}}}},"operationId":"postInvoicesRecalculate"}},"/api/v1/invoices/incidents":{"get":{"description":"List invoice incidents (validation issues, missing data, anomalies) for a company","tags":["invoices"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"sort","in":"query","required":false,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","required":false,"schema":{"type":"array","items":{"type":"string","format":"uuid"}}},{"name":"types","in":"query","description":"Filter by invoice types","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"type","in":"query","required":false,"schema":{"type":"string"}},{"name":"startDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"endDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"filters","in":"query","description":"JSON-encoded filters object","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Invoice incidents payload; each alert may include agent (resource, why, howToFix). agentGuideByType maps alert types to the same guide."}},"operationId":"getInvoicesIncidents"}},"/api/v1/invoices/download":{"get":{"description":"Download all invoice attached files for a company as a ZIP archive","tags":["invoices"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"startDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"endDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"type","in":"query","description":"Filter by invoice type (heat, fuel, electricity, water, wastes, ...)","required":false,"schema":{"type":"string"}},{"name":"addChildrenRelations","in":"query","description":"Include related child entities in the export","required":false,"schema":{"type":"boolean"}}],"responses":{"200":{"description":"ZIP archive containing invoice files","content":{"application/zip":{"schema":{"type":"string","format":"binary"}}}}},"operationId":"getInvoicesDownload"}},"/api/v1/invoices/dashboard":{"get":{"description":"Get a summary of invoices filtered by company, date range and buildings.","tags":["invoices"],"parameters":[{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"startDate","in":"query","example":"2025-01-01","required":true,"schema":{"type":"string"}},{"name":"endDate","in":"query","example":"2025-01-31","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Maximum number of items per page","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"A summary of consumptions"}},"operationId":"getInvoicesDashboard"}},"/api/v1/invoices/{id}":{"get":{"summary":"Retrieve a specific invoice record","description":"Fetch details of a invoice record by its unique identifier.","tags":["invoices"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the invoice record.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully retrieved the invoice record."}},"operationId":"getInvoicesById"},"delete":{"summary":"Delete a specific invoice record","description":"Deletes an invoice record by its unique identifier.","tags":["invoices"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the invoice to be deleted.","required":true,"schema":{"type":"string"}},{"name":"companyId","in":"body","description":"The ID of the company requesting the deletion.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully deleted the invoice record."},"400":{"description":"Bad request, missing required parameters."},"404":{"description":"Invoice not found."},"500":{"description":"Internal server error during deletion."}},"operationId":"deleteInvoicesById"}},"/api/v1/inputs":{"get":{"description":"List input definitions (catalog of measurable activities used to record consumptions)","tags":["inputs"],"parameters":[{"name":"page","in":"query","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer"}},{"name":"countryCode","in":"query","required":false,"schema":{"type":"string"}},{"name":"types","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"codes","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"classifications","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"sources","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"Paginated list of inputs"}},"operationId":"getInputs"},"post":{"description":"Create or update an input definition","tags":["inputs"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","types","name","code","units"],"properties":{"id":{"type":"string","format":"uuid"},"types":{"type":"array","items":{"type":"string"}},"name":{"type":"string"},"code":{"type":"string"},"order":{"type":"number"},"year":{"type":"integer"},"units":{"type":"array","items":{"type":"string"}},"legalName":{"type":"string"},"countries":{"type":"array","items":{"type":"string"}},"excludedCountries":{"type":"array","items":{"type":"string"}},"classifications":{"type":"array","items":{"type":"string"}},"sources":{"type":"array","items":{"type":"string"}},"createdAt":{"type":"string","format":"date-time"},"removedAt":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"Input created or updated","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postInputs"}},"/api/v1/inputs/{id}":{"get":{"description":"Get a single input definition by id","tags":["inputs"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Input definition"},"404":{"description":"Not found"}},"operationId":"getInputsById"},"delete":{"description":"Soft-delete an input definition by id","tags":["inputs"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Input deleted"}},"operationId":"deleteInputsById"}},"/api/v1/inputs/recommended":{"get":{"description":"Get a list of recommended inputs","tags":["inputs"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"countryCode","in":"query","description":"Country code","required":false,"schema":{"type":"string"}},{"name":"countryCodes","in":"query","description":"Country codes","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"types","in":"query","description":"Input types","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"codes","in":"query","description":"Input codes","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"classifications","in":"query","description":"Input classifications","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"unifyByCode","in":"query","description":"When true, keep one input per code using the closest company. Omit for the full list.","required":false,"schema":{"type":"boolean"}}],"responses":{"200":{"description":"A list of recommended inputs"}},"operationId":"getInputsRecommended"}},"/api/v1/inputs/custom":{"get":{"description":"Get a list of custom inputs","tags":["inputs"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of custom inputs"}},"operationId":"getInputsCustom"}},"/api/v1/inputs/custom/{id}":{"get":{"summary":"Retrieve a specific custom input record","description":"Fetch details of a custom input record by its unique identifier.","tags":["inputs"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the custom input record.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully retrieved the custom input record."}},"operationId":"getInputsCustomById"}},"/api/v1/inputs/company-settings":{"get":{"description":"List per-company input settings (overrides applied to global input definitions)","tags":["inputs"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"inputTypes","in":"query","description":"Filter by input types (array or comma-separated string)","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"Company input settings","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object"}}}}}}}},"operationId":"getInputsCompanySettings"},"post":{"description":"Upsert per-company input settings in bulk","tags":["inputs"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["companyId","settings"],"properties":{"companyId":{"type":"string","format":"uuid"},"settings":{"type":"array","items":{"type":"object","additionalProperties":true}}}}}}},"responses":{"200":{"description":"Settings persisted","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"}}}}}},"400":{"description":"settings must be an array"}},"operationId":"postInputsCompanySettings"}},"/api/v1/goals/scenarios":{"get":{"description":"Get a list of scenarios","tags":["goals"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of scenarios"}},"operationId":"getGoalsScenarios"}},"/api/v1/goals/scenarios/{id}":{"get":{"summary":"Retrieve a specific scenario record","description":"Fetch details of a scenario record by its unique identifier.","tags":["goals"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the scenario record.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully retrieved the scenario record."}},"operationId":"getGoalsScenariosById"}},"/api/v1/employees":{"get":{"description":"Get a list of employees","tags":["employees"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of employees"}},"operationId":"getEmployees"}},"/api/v1/employees/{id}":{"get":{"summary":"Retrieve a specific employee record","description":"Fetch details of a employee record by its unique identifier.","tags":["employees"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the employee record.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully retrieved the employee record."}},"operationId":"getEmployeesById"}},"/api/v1/emissions":{"get":{"description":"Get a list of emissions","tags":["emissions"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"categoryIds","in":"query","description":"List of category id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"entityIds","in":"query","description":"List of consumptions","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"A list of emissions. Each emission carries an `airPollutants` annex ({ nox, co, pt, hc } in kg of each substance, plus factor `snapshots`) only for companies with the `air-pollutants` feature."}},"operationId":"getEmissions"}},"/api/v1/emissions/dashboard":{"get":{"description":"Get a summary of emissions filtered by company, date range, categories, buildings and entities.","tags":["emissions"],"parameters":[{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"startDate","in":"query","example":"2025-01-01","required":false,"schema":{"type":"string","format":"date"}},{"name":"endDate","in":"query","example":"2025-01-31","required":false,"schema":{"type":"string","format":"date"}},{"name":"categoryIds","in":"query","description":"List of category id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"entityIds","in":"query","description":"List of consumptions","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"hasCountries","in":"query","description":"Include country-level data","required":false,"schema":{"type":"boolean"}},{"name":"hasBiogenicEmissions","in":"query","description":"Adds `biogenicEmissions` (kg CO2, biogenic) to the total, scope and category entries.","required":false,"schema":{"type":"boolean"}},{"name":"hasAirPollutants","in":"query","description":"Adds `airPollutants` ({ nox, co, pt, hc } in kg of each substance, not CO2e) to the total, scope and category entries. Honoured only for companies with the `air-pollutants` feature; ignored otherwise.","required":false,"schema":{"type":"boolean"}},{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Maximum number of items per page","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"A summary of emissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmissionsDashboard"}}}}},"operationId":"getEmissionsDashboard"}},"/api/v1/emission-factors/{id}":{"get":{"description":"Get a single emission factor by id","tags":["emission-factors"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"locale","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Emission factor"},"404":{"description":"Not found"}},"operationId":"getEmissionFactorsById"},"delete":{"description":"Soft-delete an emission factor by id","tags":["emission-factors"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Emission factor deleted"}},"operationId":"deleteEmissionFactorsById"}},"/api/v1/emission-factors/private/search":{"get":{"description":"Search private ecoinvent emission factor catalog","tags":["emission-factors"],"operationId":"getEmissionFactorsPrivateSearch","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/private/filters":{"get":{"description":"List private emission factor facet filters","tags":["emission-factors"],"operationId":"getEmissionFactorsPrivateFilters","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/private/detail":{"post":{"description":"Get private emission factor detail","tags":["emission-factors"],"operationId":"postEmissionFactorsPrivateDetail","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/private/categories":{"get":{"description":"List private emission factor product categories","tags":["emission-factors"],"operationId":"getEmissionFactorsPrivateCategories","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/external/search":{"get":{"description":"Search external emission factor catalogs (Ecoinvent)","tags":["emission-factors"],"operationId":"getEmissionFactorsExternalSearch","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/external/import":{"post":{"description":"Import an external Ecoinvent emission factor as a custom emission factor","tags":["emission-factors"],"operationId":"postEmissionFactorsExternalImport","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/external/filters":{"get":{"description":"List external emission factor facet filters for a region and year","tags":["emission-factors"],"operationId":"getEmissionFactorsExternalFilters","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/external/detail":{"post":{"description":"Enrich an external emission factor from search with estimate data","tags":["emission-factors"],"operationId":"postEmissionFactorsExternalDetail","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/external/categories":{"get":{"description":"List external emission factor categories (Ecoinvent)","tags":["emission-factors"],"operationId":"getEmissionFactorsExternalCategories","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/emission-factors/custom":{"get":{"description":"Get a list of custom emission factors","tags":["emission-factors"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of custom emission factors"}},"operationId":"getEmissionFactorsCustom"}},"/api/v1/emission-factors/custom/dashboard":{"get":{"description":"Aggregated dashboard for custom (company-defined) emission factors","tags":["emission-factors"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"countryCode","in":"query","required":false,"schema":{"type":"string"}},{"name":"countryCodes","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"entityIds","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"entityName","in":"query","required":false,"schema":{"type":"string"}},{"name":"entityNames","in":"query","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"year","in":"query","required":false,"schema":{"type":"integer"}},{"name":"source","in":"query","required":false,"schema":{"type":"string"}},{"name":"status","in":"query","required":false,"schema":{"type":"string"}},{"name":"footprintType","in":"query","required":false,"schema":{"type":"string"}},{"name":"onlyMain","in":"query","required":false,"schema":{"type":"boolean"}}],"responses":{"200":{"description":"Aggregated dashboard metrics"}},"operationId":"getEmissionFactorsCustomDashboard"}},"/api/v1/emission-factors/custom/concepts":{"get":{"description":"List unique concepts used across custom emission factors for a company","tags":["emission-factors"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"List of concepts","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"}}}}}},"operationId":"getEmissionFactorsCustomConcepts"}},"/api/v1/emission-factors/custom/alerts":{"get":{"description":"Aggregate custom emission factor alert counts for the current filter scope","tags":["emission-factors"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"footprintType","in":"query","required":false,"schema":{"type":"string"}},{"name":"filters","in":"query","description":"JSON-encoded DynamicFilters payload","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Alert counts for the filtered custom emission factor scope"}},"operationId":"getEmissionFactorsCustomAlerts"}},"/api/v1/emission-factors/custom/{id}":{"get":{"description":"Get a single custom (company-defined) emission factor by id","tags":["emission-factors"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Custom emission factor"},"404":{"description":"Not found"}},"operationId":"getEmissionFactorsCustomById"}},"/api/v1/consumptions/logistics-alerts":{"get":{"description":"Aggregate supplier logistics alert counts for the current filter scope","tags":["consumptions"],"operationId":"getConsumptionsLogisticsAlerts","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/consumptions":{"get":{"description":"Get a list of consumptions","tags":["consumptions"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"categoryIds","in":"query","description":"List of category id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"entityIds","in":"query","description":"List of entity id (vehicleId, invoiceId, surveyAnswerId)","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"A list of consumptions"}},"operationId":"getConsumptions"},"post":{"summary":"Create or update a consumption record","description":"Creates a new consumption record or updates an existing one. For more information and see how to use this endpoint, see: https://manglai.notion.site/Consumptions-2af89a8b970b806e8359e8446b67f32e\n","tags":["consumptions"],"consumes":["application/json"],"parameters":[{"in":"body","name":"consumption","description":"Consumption data to be inserted or updated","required":true,"schema":{"type":"object","required":["id","entityId","categoryId","startDate","endDate","companyId","buildingId","quantity","unitType"],"properties":{"id":{"type":"string","description":"Unique identifier (UUID) for the consumption record","example":"550e8400-e29b-41d4-a716-446655440000"},"entityId":{"type":"string","description":"Foreign key reference to the source entity (UUID): - **For invoices:** invoice ID from `GET /api/v1/invoices` - **For vehicles:** vehicle ID from `GET /api/v1/vehicles?companyId={companyId}`. The vehicle must exist and be available during the consumption period. - **For surveys:** survey answer ID\n","example":"invoice-123-abc"},"categoryId":{"type":"string","description":"GHG Protocol category ID (UUID). Call `GET /api/v1/categories?level=subcategory` to obtain the list and send the selected `id`. - Vehicle categories: LAND_TRANSPORTATION, AIR_TRANSPORTATION, MARITIME_TRANSPORTATION, RAIL_TRANSPORTATION, FORESTRY_MACHINERY, FARM_MACHINERY, INDUSTRIAL_MACHINERY\n","example":"668f3fcb-7fb0-4b65-b77d-9303c551632f"},"startDate":{"type":"string","format":"date-time","description":"Start date of the consumption period (ISO 8601)","example":"2024-01-01T00:00:00.000Z"},"endDate":{"type":"string","format":"date-time","description":"End date of the consumption period (ISO 8601)","example":"2024-01-31T23:59:59.999Z"},"companyId":{"type":"string","description":"Company identifier (UUID). Retrieve it via `GET /api/v1/companies` and use the returned `id`.\n","example":"1b1e07a7-083d-4831-a1d2-84b6e93a1572"},"buildingId":{"type":"string","description":"Building identifier (UUID). Call `GET /api/v1/companies/{companyId}/buildings?companyId={companyId}` and use the building `id`. **For vehicle consumptions:** If the vehicle has a `buildingId` assigned, you can use that value. Otherwise, use a building from the company.\n","example":"7fef7760-f9e7-4de9-ae35-8c37db65e4a3"},"quantity":{"type":"number","description":"Quantity consumed (e.g., kWh, liters, km)","example":1500.5},"unitType":{"type":"string","description":"Unit of measurement for the quantity. Common values: kWh, MWh, m3, l, km, kg, mt\n","example":"kWh"},"provider":{"type":"string","description":"Provider/supplier code. For electricity consumptions call `GET /api/v1/inputs/recommended?companyId={companyId}&types=provider&countryCode={countryCode}` and send the `code`. **Required for vehicle consumptions:** If vehicle `motorType` is `electric` or `hybrid`, this field is mandatory.\n","example":"endesa"},"amount":{"type":"number","description":"Cost amount (excluding taxes if applicable)","example":250.75},"totalCost":{"type":"number","description":"Total cost including all charges","example":312.5},"currency":{"type":"string","description":"Currency code (ISO 4217)","example":"EUR"},"emissionEntityId":{"type":"string","description":"Custom emission factor ID (UUID). Obtain it via `GET /api/v1/emission-factors/custom?companyId={companyId}&entityName={entityName}&countryCode={countryCode}`.\n","example":"218b2369-b86d-4517-a9f0-392d5f9e80e3"},"countryCode":{"type":"string","description":"ISO country code (e.g., ES, FR, US)","example":"ES"},"fuelType":{"type":"string","description":"Fuel code. For combustion consumptions call `GET /api/v1/inputs/recommended?companyId={companyId}&types=fuel&countryCode={countryCode}`. For gas leaks use `types=gasLeak`. Send the `code`. **Required for vehicle consumptions:** If vehicle `motorType` is `combustion` or `hybrid`, this field must be provided in `extraData.fuelTypeId` or `extraData.fuelTypeCode`.\n","example":"diesel"},"vehicleType":{"type":"string","description":"Vehicle type code. **For vehicle consumptions:** This should be included in `extraData.vehicleCategory` with the vehicle category code. Vehicle types: `vehicle`, `machine`, `transport`\n","example":"vehicle"},"emission":{"type":"object","description":"Pre-calculated emission data (optional, usually system-calculated)"},"extraData":{"type":"object","description":"Additional metadata specific to the consumption type. May include: concept, gdo, renewablePercentage, wasteType, etc.\n","properties":{"fuelType":{"type":"string"},"fuelTypeId":{"type":"string","description":"Fuel type ID (UUID). **For vehicle consumptions with combustion/hybrid motorType:** Required. Use the `id` from `GET /api/v1/inputs/recommended?types=fuel`\n"},"fuelTypeCode":{"type":"string","description":"Fuel type code. **For vehicle consumptions:** Alternative to `fuelTypeId`, use the `code` from the fuel input.\n"},"vehicleType":{"type":"string"},"vehicleCategory":{"type":"string","description":"Vehicle category code. **For vehicle consumptions:** Include the vehicle category code from the vehicle's `vehicleCategoryId`.\n"},"unit":{"type":"string","description":"Unit of measurement (same as `unitType` at root level)"},"emission":{"type":"object"},"gdo":{"type":"string"},"renewablePercentage":{"type":"number"},"wasteType":{"type":"string","description":"Waste type code. For waste consumptions call `GET /api/v1/inputs/recommended?companyId={companyId}&types=waste&countryCode={countryCode}` and send the `code`.\n"},"wasteDisposalMethod":{"type":"string","description":"Waste disposal method code. Available in the waste inputs response or company waste configuration.\n"}}},"attachedFilePath":{"type":"string","description":"Path to attached file (e.g., invoice PDF)","example":"gs://bucket/company/invoice.pdf"},"efficiency":{"type":"object","description":"Efficiency data (optional). **For vehicle consumptions:** Can include distance and energy consumption data. Structure: `{ distance: number, distanceUnit: string, energy: number, energyUnit: string }`\n","properties":{"distance":{"type":"number","description":"Distance traveled (if applicable)"},"distanceUnit":{"type":"string","description":"Unit for distance (e.g., \"km\")"},"energy":{"type":"number","description":"Energy consumed (if applicable)"},"energyUnit":{"type":"string","description":"Unit for energy (e.g., \"kWh\", \"l\")"}}},"externalId":{"type":"string","description":"External system identifier for integration purposes","example":"EXT-2024-001"},"relationalId":{"type":"string","description":"Identifier to relate multiple consumptions","example":"batch-123"},"updateByExternalId":{"type":"boolean","description":"If true, updates existing consumption by externalId instead of id. Useful for integrations that don't know internal IDs.\n","example":false},"emissionsCategoryIds":{"type":"array","description":"Array of category IDs (UUID) for multi-category emissions. Retrieve IDs via `GET /api/v1/categories?level=subcategory`.\n**For general consumptions (optional):** Used when a consumption should generate emissions in multiple categories (e.g., electricity + energy-related-activities).\n**For vehicle consumptions (required):** Must always include two categories: - Primary category (same as `categoryId`) - Related activity category:\n  - Electric/Hybrid vehicles: `ENERGY_RELATED_ACTIVITIES` (47cb52b3-02e6-446e-bd70-e46316aa876b)\n  - Combustion vehicles: `FUEL_RELATED_ACTIVITIES` (dd16800c-c79f-4717-9de6-07e15f4ceb64)\n","items":{"type":"string"},"example":["493782d7-7c17-4ed6-b75c-4fae0e254ff2","47cb52b3-02e6-446e-bd70-e46316aa876b"]},"isRecalculated":{"type":"boolean","description":"If true, bypasses duplicate validation (used for recalculation flows)\n","example":false},"validation":{"type":"object","description":"Validation metadata (timestamps, validator info)"},"removedAt":{"type":"string","format":"date-time","description":"Soft delete timestamp (null if active)","example":null}}}}],"responses":{"200":{"description":"Consumption successfully created/updated and emissions calculated","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string","example":"ok"},"isUpdated":{"type":"boolean","description":"True if an existing record was updated","example":false},"isCreated":{"type":"boolean","description":"True if a new record was created","example":true}}}}}},"400":{"description":"Bad request — validation errors: - Invalid date range (startDate > endDate) - Missing required fields - Invalid category or building/vehicle IDs\n"},"409":{"description":"Conflict — consumption already exists with same parameters: - Same companyId, buildingId, entityId, categoryId - Same startDate, endDate, quantity, provider Error code: CONSUMPTION_ALREADY_EXIST\n"},"422":{"description":"Unprocessable entity — no valid emission factors found: - Category requires emission factor but none available - Quantity is zero and no emission factor exists Error code: CONSUMPTION_WITHOUT_EMISSIONS_FACTOR\n"},"500":{"description":"Internal server error during consumption/emission calculation"}},"operationId":"postConsumptions"}},"/api/v1/consumptions/alerts":{"get":{"description":"Aggregate consumption alert counts for the current filter scope (vehicles)","tags":["consumptions"],"parameters":[{"name":"companyId","in":"query","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"startDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"endDate","in":"query","required":false,"schema":{"type":"string","format":"date"}},{"name":"filters","in":"query","description":"JSON-encoded DynamicFilters payload","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Alert counts for the filtered consumption scope"}},"operationId":"getConsumptionsAlerts"}},"/api/v1/consumptions/{id}":{"get":{"summary":"Retrieve a specific consumption record","description":"Fetch details of a consumption record by its unique identifier.","tags":["consumptions"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the consumption record.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully retrieved the consumption record.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of the consumption."},"data":{"type":"object","description":"The detailed information about the consumption."}}}}}},"404":{"description":"Consumption record not found."}},"operationId":"getConsumptionsById"}},"/api/v1/companies":{"get":{"description":"Get a list of companies","tags":["companies"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyIds","in":"query","description":"List of company id","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"A list of companies"}},"operationId":"getCompanies"}},"/api/v1/companies/{id}/emissions-summary":{"get":{"summary":"Get company emissions summary by year","description":"Returns a markdown summary of company emissions, consumptions and invoices for a given year. Uses CompanySummarizer service (same data used by AI insights). Supports carbon footprint, water footprint (WFN) and water footprint (ISO). For carbon footprint, the summary adds an \"Air Pollutants\" section (kg NOx/CO/PT/HC) when the company has the `air-pollutants` feature.","tags":["companies"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Company UUID. Retrieve via GET /api/v1/companies."},{"name":"year","in":"query","required":false,"schema":{"type":"integer","example":2025},"description":"Year for the summary. Defaults to current year."},{"name":"footprintType","in":"query","required":false,"schema":{"type":"string","enum":["carbon-footprint","water-footprint","water-footprint-iso"]},"description":"Footprint type. Defaults to carbon-footprint."},{"name":"locale","in":"query","required":false,"schema":{"type":"string","example":"es"},"description":"Locale for the summary. Defaults to es."}],"responses":{"200":{"description":"Company emissions summary for the requested year","content":{"application/json":{"schema":{"type":"object","properties":{"companyId":{"type":"string"},"year":{"type":"integer"},"footprintType":{"type":"string"},"startDate":{"type":"string","format":"date"},"endDate":{"type":"string","format":"date"},"summary":{"type":"string","description":"Markdown summary of emissions, buildings, consumptions and invoices"}}}}}},"400":{"description":"Invalid year parameter"}},"operationId":"getCompaniesByIdEmissionsSummary"}},"/api/v1/companies/{id}/buildings":{"get":{"description":"Get a list of buildings","tags":["companies"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}}],"responses":{"200":{"description":"A list of buildings"}},"operationId":"getCompaniesByIdBuildings"},"post":{"description":"Create or update a building","tags":["companies"],"parameters":[{"name":"id","in":"path","description":"Company ID","required":true,"schema":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["id","companyId","name","address","country","city"],"properties":{"id":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"companyId":{"type":"string","format":"uuid","example":"c5b87f15-33ed-4522-90eb-d23473ab911d"},"name":{"type":"string","example":"Main Office"},"type":{"type":"string","example":"office"},"address":{"type":"string","example":"123 Main St, New York, NY 10001"},"city":{"type":"string","example":"New York"},"country":{"type":"string","example":"US"},"m2":{"type":"number","example":500},"isActive":{"type":"boolean","example":true},"startDate":{"type":"string","format":"date-time","example":"2023-01-01T00:00:00.000Z"},"endDate":{"type":"string","format":"date-time","example":"2024-12-31T00:00:00.000Z"},"controlType":{"type":"string","enum":["operational","financial","shareholding"]},"control":{"type":"string","enum":["own","rented","subcontracted"]},"operationalControl":{"type":"string","enum":["own","rented","subcontracted"]},"electricityCUP":{"type":"string","example":"ES0021000000000000AA"},"electricityCUPs":{"type":"array","items":{"type":"string"}},"combustionCUP":{"type":"string","example":"ES0021000000000000AA"},"combustionCUPs":{"type":"array","items":{"type":"string"}},"waterCUPs":{"type":"array","items":{"type":"string"}},"externalId":{"type":"string","example":"EXT-001"},"aliases":{"type":"string","example":"HQ, Headquarters"},"nima":{"type":"string"},"pprp":{"type":"string"},"metricsByYear":{"type":"object","additionalProperties":{"type":"object","properties":{"m2":{"type":"number"},"employees":{"type":"number"}}},"example":{"2023":{"m2":500,"employees":50}}}}}}}},"responses":{"200":{"description":"The created or updated building","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object"},"status":{"type":"string","example":"ok"}}}}}}},"operationId":"postCompaniesByIdBuildings"}},"/api/v1/companies/{id}/year-configuration":{"get":{"description":"Get a list of year configurations","tags":["companies"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of year configurations"}},"operationId":"getCompaniesByIdYearConfiguration"}},"/api/v1/companies/{id}/organization-limits":{"get":{"description":"Get a list of company organization limits","tags":["companies"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"id","in":"query","description":"Company ID","required":true,"schema":{"type":"string"}},{"name":"relatedCompanyId","in":"query","description":"Related Company ID filter","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of company organization limits"}},"operationId":"getCompaniesByIdOrganizationLimits"},"post":{"description":"Create or update a company organization limit","tags":["companies"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"companyId":{"type":"string"},"relatedCompanyId":{"type":"string"},"organizationLimit":{"type":"string"},"percentage":{"type":"number"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"Organization limit created or updated successfully"}},"operationId":"postCompaniesByIdOrganizationLimits"}},"/api/v1/companies/{id}/organization-limits/{limitId}":{"get":{"description":"Get a specific company organization limit by ID","tags":["companies"],"parameters":[{"name":"id","in":"path","description":"Company ID","required":true,"schema":{"type":"string"}},{"name":"limitId","in":"path","description":"Organization Limit ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Company organization limit details"},"404":{"description":"Organization limit not found"}},"operationId":"getCompaniesByIdOrganizationLimitsById"},"put":{"description":"Update a specific company organization limit","tags":["companies"],"parameters":[{"name":"id","in":"path","description":"Company ID","required":true,"schema":{"type":"string"}},{"name":"limitId","in":"path","description":"Organization Limit ID","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"companyId":{"type":"string"},"relatedCompanyId":{"type":"string"},"organizationLimit":{"type":"string"},"percentage":{"type":"number"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}}}},"responses":{"200":{"description":"Organization limit updated successfully"}},"operationId":"putCompaniesByIdOrganizationLimitsById"},"delete":{"description":"Delete a specific company organization limit","tags":["companies"],"parameters":[{"name":"id","in":"path","description":"Company ID","required":true,"schema":{"type":"string"}},{"name":"limitId","in":"path","description":"Organization Limit ID","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Organization limit deleted successfully"},"404":{"description":"Organization limit not found"}},"operationId":"deleteCompaniesByIdOrganizationLimitsById"}},"/api/v1/companies/{id}/departments":{"get":{"description":"Get a list of departments","tags":["companies"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"query","in":"query","description":"Search departments by name","required":false,"schema":{"type":"string"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of departments"}},"operationId":"getCompaniesByIdDepartments"}},"/api/v1/companies/{id}/buildings/surface-summary":{"get":{"description":"Sum of building surface (m²) for a reporting year","tags":["companies","buildings"],"operationId":"getCompaniesByIdBuildingsSurfaceSummary","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/companies/{id}/buildings/regos":{"get":{"description":"Get a list of regos","tags":["companies","buildings"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"buildingId","in":"query","description":"BuildingId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of buildings"}},"operationId":"getCompaniesByIdBuildingsRegos"}},"/api/v1/companies/{id}/buildings/regos-dashboard":{"get":{"description":"Get a list of regos dashboard","tags":["companies","buildings"],"parameters":[{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"buildingId","in":"query","description":"BuildingId","required":true,"schema":{"type":"string"}},{"name":"cup","in":"query","description":"Cup","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of buildings"}},"operationId":"getCompaniesByIdBuildingsRegosDashboard"}},"/api/v1/companies/{id}/buildings/operational-control-stats":{"get":{"description":"Building counts by operational control dashboard category (aggregate)","tags":["companies","buildings"],"operationId":"getCompaniesByIdBuildingsOperationalControlStats","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/companies/{id}/buildings/dashboard":{"get":{"description":"Get building counts by control category (own, leased, subleased, investments, services) for emission impact panel","tags":["companies","buildings"],"parameters":[{"name":"companyId","in":"query","description":"Company ID (can also use id from path)","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Counts and showPanel flag"}},"operationId":"getCompaniesByIdBuildingsDashboard"}},"/api/v1/companies/{id}/buildings/alerts":{"get":{"description":"Aggregate building alert counts for the current filter scope","tags":["companies"],"operationId":"getCompaniesByIdBuildingsAlerts","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/certificates":{"get":{"description":"Get a list of certificates","tags":["certificates"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"A list of certificates"}},"operationId":"getCertificates"}},"/api/v1/certificates/{id}":{"get":{"summary":"Retrieve a specific certificate record","description":"Fetch details of a certificate record by its unique identifier.","tags":["certificates"],"parameters":[{"name":"id","in":"path","description":"The unique identifier of the certificate record.","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Successfully retrieved the certificate record.","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"The unique identifier of the certificate."},"data":{"type":"object","description":"The detailed information about the certificate."}}}}}},"404":{"description":"certificate record not found."}},"operationId":"getCertificatesById"}},"/api/v1/categories":{"get":{"description":"Get a list of categories","tags":["categories"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"level","in":"query","description":"Level","required":false,"schema":{"type":"string","enum":["scope","category","subcategory"]}}],"responses":{"200":{"description":"A list of categories"}},"operationId":"getCategories"}},"/api/v1/business-travels":{"get":{"description":"Get a list of business travels","tags":["business-travels"],"parameters":[{"name":"page","in":"query","description":"Page number","required":false,"schema":{"type":"integer"}},{"name":"limit","in":"query","description":"Limit","required":false,"schema":{"type":"integer"}},{"name":"companyId","in":"query","description":"CompanyId","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"List of building id","required":false,"schema":{"type":"array","items":{"type":"string"}}}],"responses":{"200":{"description":"A list of business travel"}},"operationId":"getBusinessTravels"},"post":{"description":"Create or update a business travel","tags":["business-travels"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["id","companyId","date","transportType"],"properties":{"id":{"type":"string"},"externalId":{"type":"string"},"companyId":{"type":"string"},"employeeId":{"type":"string"},"buildingId":{"type":"string"},"date":{"type":"string","format":"date-time"},"transportType":{"type":"string"},"transportTypeClass":{"type":"string"},"carMotorType":{"type":"string"},"railType":{"type":"string"},"class":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"},"country":{"type":"string"},"distance":{"type":"number"},"unit":{"type":"string"},"hotelNights":{"type":"number"},"isRoundTrip":{"type":"boolean"},"relationalId":{"type":"string"},"historyId":{"type":"string"},"attachedFilePath":{"type":"string"},"supplierName":{"type":"string"},"removedAt":{"type":"string","format":"date-time","nullable":true},"wasValidated":{"type":"boolean"},"validation":{"type":"object","properties":{"isValidatedAt":{"type":"string","format":"date-time"},"validatedBy":{"type":"string"},"validatedByName":{"type":"string"},"isValidatedAtByClimateExpert":{"type":"string","format":"date-time"},"validatedByClimateExpert":{"type":"string"},"validatedByClimateExpertName":{"type":"string"}}}}}}}},"responses":{"200":{"description":"Business travel created or updated"}},"operationId":"postBusinessTravels"}},"/api/v1/business-travels/dashboard":{"get":{"description":"Get dashboard data for business travels","tags":["business-travels"],"parameters":[{"name":"companyId","in":"query","description":"Company ID","required":true,"schema":{"type":"string"}},{"name":"buildingIds","in":"query","description":"List of building ids","required":false,"schema":{"type":"array","items":{"type":"string"}}},{"name":"employeeId","in":"query","description":"Employee ID","required":false,"schema":{"type":"string"}},{"name":"transportType","in":"query","description":"Transport type","required":false,"schema":{"type":"string"}},{"name":"startDate","in":"query","description":"Start date","required":false,"schema":{"type":"string"}},{"name":"endDate","in":"query","description":"End date","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Dashboard data for business travels"}},"operationId":"getBusinessTravelsDashboard"}},"/api/v1/business-travels/alerts":{"get":{"description":"Aggregate business travel alert counts for the current filter scope","tags":["business-travels"],"operationId":"getBusinessTravelsAlerts","responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/v1/auth/who-am-i":{"post":{"description":"Who am I","tags":["auth"],"responses":{"200":{"description":null}},"operationId":"postAuthWhoAmI"}},"/api/v1/auth/logout":{"post":{"description":"Logout a user","tags":["auth"],"responses":{"200":{"description":null}},"operationId":"postAuthLogout"}},"/api/v1/auth/login":{"post":{"description":"Login a user","tags":["auth"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","description":"User email encoded as UTF-8 Base64 (plaintext still accepted)"},"password":{"type":"string","description":"User password encoded as UTF-8 Base64 (plaintext still accepted)"}}}}}},"responses":{"200":{"description":"The user","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"401":{"description":"Unauthorized"}},"operationId":"postAuthLogin"}}},"tags":[],"servers":[{"url":"https://app.manglai.io","description":"Manglai production"}]}