> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create LCA Portfolio

> Create a new Life Cycle Assessment portfolio for your organization

# Create LCA Portfolio

Creates a new LCA portfolio for your organization. A portfolio declares one or more output co-products with their functional units, along with the impact categories to assess and the time period for the analysis.

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  Must be `application/json`
</ParamField>

### Body Parameters

<ParamField body="name" type="string" required>
  Name of the LCA portfolio

  **Example:** `"Product A - Environmental Impact 2024"`
</ParamField>

<ParamField body="start_date" type="string" required>
  Start date of the assessment period

  **Format:** `YYYY-MM-DD`
</ParamField>

<ParamField body="end_date" type="string" required>
  End date of the assessment period

  **Format:** `YYYY-MM-DD`
</ParamField>

<ParamField body="impact_categories" type="array[string]" required>
  List of impact category identifiers to include in the assessment

  **Common values:** `gwp` (Global Warming Potential), `ap` (Acidification), `ep` (Eutrophication), `pocp` (Photochemical Ozone Creation), `adp` (Abiotic Depletion)
</ParamField>

<ParamField body="products" type="array[object]">
  Output co-products with their functional units. Either `products` or both `value` + `unit_id` must be provided.

  <Expandable title="product object fields">
    <ResponseField name="name" type="string" required>
      Display name of the co-product
    </ResponseField>

    <ResponseField name="quantity" type="number" required>
      Functional-unit quantity (must be > 0)
    </ResponseField>

    <ResponseField name="unit_id" type="string" required>
      UUID of the unit for the quantity
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField body="value" type="number">
  Legacy single-product functional unit quantity. Use `products` instead for new integrations.
</ParamField>

<ParamField body="unit_id" type="string">
  Legacy functional unit identifier. Required when using `value` instead of `products`.
</ParamField>

## Response

Returns HTTP 201 with the created portfolio structure.

<ResponseField name="acv_id" type="string">
  UUID of the created LCA portfolio
</ResponseField>

<ResponseField name="process" type="object">
  The root process block (canvas node)

  <Expandable title="block object fields">
    <ResponseField name="id" type="string">
      UUID of the block
    </ResponseField>

    <ResponseField name="name" type="string | null">
      Block name
    </ResponseField>

    <ResponseField name="entity_id" type="array | null">
      Entity identifiers linked to this block
    </ResponseField>

    <ResponseField name="entity_type" type="string">
      Type of entity this block represents: `process`, `final_product`, `material`, `transport`
    </ResponseField>

    <ResponseField name="coordinates_x" type="integer">
      X position on the LCA canvas
    </ResponseField>

    <ResponseField name="coordinates_y" type="integer">
      Y position on the LCA canvas
    </ResponseField>

    <ResponseField name="inputs" type="array | null">
      Input connections
    </ResponseField>

    <ResponseField name="outputs" type="array | null">
      Output connections
    </ResponseField>

    <ResponseField name="created_at" type="datetime">
      When the block was created
    </ResponseField>

    <ResponseField name="updated_at" type="datetime | null">
      When the block was last updated
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="final_product" type="object">
  Primary output product block (same structure as `process`)
</ResponseField>

<ResponseField name="final_products" type="array[object]">
  All output co-product blocks (same structure as `process`)
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/lca/portfolio" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Product A - Environmental Impact 2024",
      "start_date": "2024-01-01",
      "end_date": "2024-12-31",
      "impact_categories": ["gwp", "ap", "ep"],
      "products": [
        {
          "name": "Product A",
          "quantity": 1.0,
          "unit_id": "550e8400-e29b-41d4-a716-446655440000"
        }
      ]
    }'
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  response = requests.post(
      "https://api.dcycle.io/v1/lca/portfolio",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
      json={
          "name": "Product A - Environmental Impact 2024",
          "start_date": "2024-01-01",
          "end_date": "2024-12-31",
          "impact_categories": ["gwp", "ap", "ep"],
          "products": [
              {
                  "name": "Product A",
                  "quantity": 1.0,
                  "unit_id": "550e8400-e29b-41d4-a716-446655440000",
              }
          ],
      },
  )

  portfolio = response.json()
  print(f"Created LCA portfolio: {portfolio['acv_id']}")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  axios.post('https://api.dcycle.io/v1/lca/portfolio', {
    name: 'Product A - Environmental Impact 2024',
    start_date: '2024-01-01',
    end_date: '2024-12-31',
    impact_categories: ['gwp', 'ap', 'ep'],
    products: [
      {
        name: 'Product A',
        quantity: 1.0,
        unit_id: '550e8400-e29b-41d4-a716-446655440000',
      },
    ],
  }, {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
    },
  })
  .then(({ data }) => {
    console.log(`Created LCA portfolio: ${data.acv_id}`);
  });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "acv_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "process": {
    "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    "name": null,
    "entity_id": null,
    "entity_type": "process",
    "coordinates_x": 0,
    "coordinates_y": 0,
    "inputs": [],
    "outputs": [],
    "created_at": "2024-01-15T10:00:00Z",
    "updated_at": "2024-01-15T10:00:00Z"
  },
  "final_product": {
    "id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
    "name": "Product A",
    "entity_id": null,
    "entity_type": "final_product",
    "coordinates_x": 400,
    "coordinates_y": 0,
    "inputs": [],
    "outputs": [],
    "created_at": "2024-01-15T10:00:00Z",
    "updated_at": "2024-01-15T10:00:00Z"
  },
  "final_products": [
    {
      "id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
      "name": "Product A",
      "entity_id": null,
      "entity_type": "final_product",
      "coordinates_x": 400,
      "coordinates_y": 0,
      "inputs": [],
      "outputs": [],
      "created_at": "2024-01-15T10:00:00Z",
      "updated_at": "2024-01-15T10:00:00Z"
    }
  ]
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

### 422 Unprocessable Entity

**Cause:** Missing required fields or invalid product definition

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["body", "__root__"],
      "msg": "either 'products' or both 'value' and 'unit_id' must be provided",
      "type": "value_error"
    }
  ]
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List LCA Portfolios" icon="list" href="/api-reference/lca/list">
    Browse all LCA portfolios
  </Card>

  <Card title="Get LCA Portfolio" icon="magnifying-glass" href="/api-reference/lca/get">
    Get portfolio details
  </Card>

  <Card title="LCA Dashboard" icon="chart-pie" href="/api-reference/lca/dashboard">
    Get environmental impact results
  </Card>
</CardGroup>
