Skip to main content
POST
/
v1
/
lca
/
create-from-json
Create LCA from JSON
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': '<content-type>'
  },
  body: JSON.stringify({
    name: '<string>',
    unit: '<string>',
    value: 123,
    start_date: '<string>',
    end_date: '<string>',
    start_node: '<string>',
    nodes: {}
  })
};

fetch('https://api.dcycle.io/v1/lca/create-from-json', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
import requests

url = "https://api.dcycle.io/v1/lca/create-from-json"

payload = {
    "name": "<string>",
    "unit": "<string>",
    "value": 123,
    "start_date": "<string>",
    "end_date": "<string>",
    "start_node": "<string>",
    "nodes": {}
}
headers = {
    "x-api-key": "<x-api-key>",
    "x-organization-id": "<x-organization-id>",
    "Content-Type": "<content-type>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
curl --request POST \
  --url https://api.dcycle.io/v1/lca/create-from-json \
  --header 'Content-Type: <content-type>' \
  --header 'x-api-key: <x-api-key>' \
  --header 'x-organization-id: <x-organization-id>' \
  --data '
{
  "name": "<string>",
  "unit": "<string>",
  "value": 123,
  "start_date": "<string>",
  "end_date": "<string>",
  "start_node": "<string>",
  "nodes": {}
}
'
{
  "acv_id": "<string>",
  "summary": {}
}

Create LCA from JSON

Creates a complete LCA portfolio with all its components (processes, materials, energy, waste, transport) from a hierarchical JSON tree structure. This is the recommended endpoint for programmatic LCA creation.
This endpoint requires API key authentication only (x-api-key header).

Request

Authentication

x-api-key
string
required
Your API keyExample: sk_live_1234567890abcdef

Headers

x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa
Content-Type
string
required
Must be application/json

Body Parameters

name
string
required
Name of the LCA portfolio
unit
string
required
Functional unit name (e.g. "kg", "unit", "m2")
value
number
required
Functional unit quantity (must be >= 0)
start_date
string
required
Start date of the assessment periodFormat: YYYY-MM-DD
end_date
string
required
End date of the assessment period (must be after start_date)Format: YYYY-MM-DD
start_node
string
required
ID of the root node in the nodes dictionary. Must be a process type node.
nodes
object
required
Dictionary of node definitions keyed by node ID. Each node has a type that determines its fields.Node types:

Response

Returns HTTP 201 with the created LCA information.
acv_id
string
UUID of the created LCA portfolio
summary
object
Summary of the created LCA structure

Example

curl -X POST "https://api.dcycle.io/v1/lca/create-from-json" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Wooden Table LCA",
    "unit": "unit",
    "value": 1.0,
    "start_date": "2024-01-01",
    "end_date": "2024-12-31",
    "start_node": "assembly",
    "nodes": {
      "assembly": {
        "type": "process",
        "name": "Table Assembly",
        "location": "ES",
        "children": ["wood", "steel_bolts", "electricity", "transport_wood"],
        "attributes": {}
      },
      "wood": {
        "type": "material",
        "name": "Sawn timber, softwood",
        "supplier": "Forest Co",
        "location": "FI",
        "quantity": 15.0,
        "unit": "kg"
      },
      "steel_bolts": {
        "type": "material",
        "name": "Steel, low-alloyed",
        "supplier": "Steel Inc",
        "location": "DE",
        "quantity": 0.5,
        "unit": "kg"
      },
      "electricity": {
        "type": "energy",
        "name": "Electricity",
        "location": "ES",
        "quantity": 2.5,
        "unit": "kWh"
      },
      "transport_wood": {
        "type": "transport",
        "name": "Wood transport from Finland",
        "transport_type": "truck",
        "quantity": 45.0,
        "unit": "tkm",
        "children": ["wood"]
      }
    }
  }'
import requests
import os

response = requests.post(
    "https://api.dcycle.io/v1/lca/create-from-json",
    headers={
        "x-api-key": os.getenv("DCYCLE_API_KEY"),
        "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
    },
    json={
        "name": "Wooden Table LCA",
        "unit": "unit",
        "value": 1.0,
        "start_date": "2024-01-01",
        "end_date": "2024-12-31",
        "start_node": "assembly",
        "nodes": {
            "assembly": {
                "type": "process",
                "name": "Table Assembly",
                "location": "ES",
                "children": ["wood", "steel_bolts", "electricity"],
                "attributes": {},
            },
            "wood": {
                "type": "material",
                "name": "Sawn timber, softwood",
                "supplier": "Forest Co",
                "location": "FI",
                "quantity": 15.0,
                "unit": "kg",
            },
            "steel_bolts": {
                "type": "material",
                "name": "Steel, low-alloyed",
                "supplier": "Steel Inc",
                "location": "DE",
                "quantity": 0.5,
                "unit": "kg",
            },
            "electricity": {
                "type": "energy",
                "name": "Electricity",
                "location": "ES",
                "quantity": 2.5,
                "unit": "kWh",
            },
        },
    },
)

result = response.json()
print(f"Created LCA: {result['acv_id']}")
const axios = require('axios');

const response = await axios.post('https://api.dcycle.io/v1/lca/create-from-json', {
  name: 'Wooden Table LCA',
  unit: 'unit',
  value: 1.0,
  start_date: '2024-01-01',
  end_date: '2024-12-31',
  start_node: 'assembly',
  nodes: {
    assembly: {
      type: 'process',
      name: 'Table Assembly',
      location: 'ES',
      children: ['wood', 'steel_bolts', 'electricity'],
      attributes: {},
    },
    wood: {
      type: 'material',
      name: 'Sawn timber, softwood',
      supplier: 'Forest Co',
      location: 'FI',
      quantity: 15.0,
      unit: 'kg',
    },
    steel_bolts: {
      type: 'material',
      name: 'Steel, low-alloyed',
      supplier: 'Steel Inc',
      location: 'DE',
      quantity: 0.5,
      unit: 'kg',
    },
    electricity: {
      type: 'energy',
      name: 'Electricity',
      location: 'ES',
      quantity: 2.5,
      unit: 'kWh',
    },
  },
}, {
  headers: {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID,
  },
});

console.log(`Created LCA: ${response.data.acv_id}`);

Successful Response

{
  "acv_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "summary": {
    "name": "Wooden Table LCA",
    "nodes_created": 5,
    "processes": 1,
    "materials": 2,
    "energy": 1,
    "transport": 1
  }
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

422 Unprocessable Entity

Cause: Invalid tree structure, missing nodes, or broken references
{
  "detail": [
    {
      "loc": ["body", "start_node"],
      "msg": "start_node 'missing_node' not found in nodes",
      "type": "value_error"
    }
  ]
}

422 Unprocessable Entity — Invalid date range

Cause: Invalid or missing required fields in the request body
{
  "detail": [
    {
      "loc": ["body", "end_date"],
      "msg": "End date must be after start date",
      "type": "value_error"
    }
  ]
}

Create LCA Portfolio

Create a basic portfolio (without tree structure)

List LCA Portfolios

Browse all LCA portfolios

LCA Dashboard

View environmental impact results