> ## 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 Custom Emission Factor

> Create a new custom emission factor within a group

> [!WARNING]
>
> **Legacy API.** This page documents the previous version of the API. This particular
> operation has no documented equivalent in the current API yet, so this remains the
> documented way to do it. Prefer the current API for everything it already covers.

Add a new custom emission factor to an existing Custom Emission Group. This endpoint allows you to define organization-specific emission factors with detailed GHG breakdowns.

> [!NOTE]
>
> You must first create a Custom Emission Group before adding factors to it. See [Custom Emission Groups](https://code.dcycle.io/api-reference/legacy/custom-emission-groups/create.md).

## Request

### Headers

**x-api-key** `string` *required*

Your API key for authentication

**Example:** `sk_live_1234567890abcdef`

**x-organization-id** `string` *required*

Your organization UUID

**Example:** `ff4adcc7-8172-45fe-9cf1-e90a6de53aa9`

**x-user-id** `string`

Optional and ignored: the request acts as the member who created the API key

**Example:** `a1b2c3d4-e5f6-7890-abcd-ef1234567890`

### Path Parameters

**id** `string` *required*

UUID of the Custom Emission Group to add this factor to

**Example:** `"group-uuid-here"`

### Body Parameters

**ef\_name** `string` *required*

Descriptive name for the emission factor

**Example:** `"Recycled Aluminum - Supplier ABC"`

**unit\_id** `string` *required*

UUID of the measurement unit (from `/api/v1/units`)

**Example:** `"kg-unit-uuid"`

**factor\_uploaded\_by** `string` *required*

Reference to person/team who uploaded this factor

**Example:** `"sustainability_team@company.com"`

**tag** `string` *required*

Complexity level of the factor

**Values:** `"simple"` or `"advanced"`

**emission\_factor\_values** `array` *required*

Array of emission values by gas type

Each object must contain:

* `gas_type` (string): `"CO2"`, `"CH4"`, `"N2O"`, `"HFC"`, `"PFC"`, `"SF6"`, or `"NF3"`
* `value` (float): Emission value (kg gas per unit)

**Minimum:** At least CO2 must be provided

**uncertainty\_grade** `float`

Confidence level of the factor (0-100%)

**Example:** `15.5` (lower is more certain)

**factor\_start\_date** `date`

Validity start date (YYYY-MM-DD)

**Example:** `"2024-01-01"`

**factor\_end\_date** `date`

Validity end date (YYYY-MM-DD)

**Example:** `"2024-12-31"`

**additional\_docs** `string`

Documentation reference or notes

**Example:** `"EPD No. ABC-2024-001, Third-party verified"`

**renewable\_percentage** `float`

For energy factors: percentage of renewable content (0-100)

**Example:** `100.0`

**hazardous** `boolean`

For waste factors: whether waste is hazardous

**Example:** `false`

**recycled** `boolean`

For waste/material factors: whether material is recycled

**Example:** `true`

**low\_code** `string`

For waste factors: LER/LOW waste code

Retrieve available options from [`GET /api/v1/wastes/low_codes`](https://code.dcycle.io/api-reference/legacy/wastes/codes) — `waste_region` is required; pass `GLO`

**Example:** `"15 01 01"`

**rd\_code** `string`

For waste factors: RD disposal method code

Retrieve available options from [`GET /api/v1/wastes/rd_ler_list`](https://code.dcycle.io/api-reference/legacy/wastes/codes)

**Example:** `"R3"`

## Response

Returns the created custom emission factor object with generated ID.

## Example

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dcycle.io/api/v1/custom_emission_factors/group-uuid" \
  -H "Authorization: Bearer ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "x-user-id: ${DCYCLE_USER_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "ef_name": "Recycled Aluminum - Supplier ABC",
    "unit_id": "kg-unit-uuid",
    "factor_uploaded_by": "sustainability@company.com",
    "tag": "advanced",
    "uncertainty_grade": 15,
    "factor_start_date": "2024-01-01",
    "factor_end_date": "2024-12-31",
    "additional_docs": "EPD No. ABC-2024-001",
    "emission_factor_values": [
      {
        "gas_type": "CO2",
        "value": 2.15
      },
      {
        "gas_type": "CH4",
        "value": 0.008
      },
      {
        "gas_type": "N2O",
        "value": 0.002
      }
    ],
    "recycled": true
  }'
```

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

api_key = os.getenv("DCYCLE_API_KEY")
org_id = os.getenv("DCYCLE_ORG_ID")
user_id = os.getenv("DCYCLE_USER_ID")

headers = {
    "Authorization": f"Bearer {api_key}",
    "x-organization-id": org_id,
    "x-user-id": user_id,
    "Content-Type": "application/json"
}

group_id = "group-uuid"

factor_data = {
    "ef_name": "Recycled Aluminum - Supplier ABC",
    "unit_id": "kg-unit-uuid",
    "factor_uploaded_by": "sustainability@company.com",
    "tag": "advanced",
    "uncertainty_grade": 15,
    "factor_start_date": "2024-01-01",
    "factor_end_date": "2024-12-31",
    "additional_docs": "EPD No. ABC-2024-001",
    "emission_factor_values": [
        {"gas_type": "CO2", "value": 2.15},
        {"gas_type": "CH4", "value": 0.008},
        {"gas_type": "N2O", "value": 0.002}
    ],
    "recycled": True
}

response = requests.post(
    f"https://api.dcycle.io/api/v1/custom_emission_factors/{group_id}",
    headers=headers,
    json=factor_data
)

factor = response.json()
print(f"✅ Custom emission factor created: {factor['id']}")
```

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

const apiKey = process.env.DCYCLE_API_KEY;
const orgId = process.env.DCYCLE_ORG_ID;
const userId = process.env.DCYCLE_USER_ID;

const headers = {
  'Authorization': `Bearer ${apiKey}`,
  'x-organization-id': orgId,
  'x-user-id': userId,
  'Content-Type': 'application/json'
};

const groupId = 'group-uuid';

const factorData = {
  ef_name: 'Recycled Aluminum - Supplier ABC',
  unit_id: 'kg-unit-uuid',
  factor_uploaded_by: 'sustainability@company.com',
  tag: 'advanced',
  uncertainty_grade: 15,
  factor_start_date: '2024-01-01',
  factor_end_date: '2024-12-31',
  additional_docs: 'EPD No. ABC-2024-001',
  emission_factor_values: [
    { gas_type: 'CO2', value: 2.15 },
    { gas_type: 'CH4', value: 0.008 },
    { gas_type: 'N2O', value: 0.002 }
  ],
  recycled: true
};

axios.post(
  `https://api.dcycle.io/api/v1/custom_emission_factors/${groupId}`,
  factorData,
  { headers }
)
.then(response => {
  const factor = response.data;
  console.log(`✅ Custom emission factor created: ${factor.id}`);
})
.catch(error => console.error(error));
```

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "factor-uuid",
  "factor_id": "factor-uuid",
  "ef_name": "Recycled Aluminum - Supplier ABC",
  "unit_id": "kg-unit-uuid",
  "factor_uploaded_by": "sustainability@company.com",
  "tag": "advanced",
  "uncertainty_grade": 15.0,
  "factor_start_date": "2024-01-01",
  "factor_end_date": "2024-12-31",
  "additional_docs": "EPD No. ABC-2024-001",
  "emission_factor_values": [
    {
      "gas_type": "CO2",
      "value": 2.15
    },
    {
      "gas_type": "CH4",
      "value": 0.008
    },
    {
      "gas_type": "N2O",
      "value": 0.002
    }
  ],
  "recycled": true,
  "renewable_percentage": null,
  "hazardous": null,
  "low_code": null,
  "rd_code": null
}
```

## Common Errors

### 400 Bad Request - Invalid Group ID

**Cause:** Custom emission group not found

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "Custom emission group not found",
  "code": "NOT_FOUND"
}
```

**Solution:** Verify the group ID exists using `/api/v1/custom_emission_groups`.

### 422 Validation Error - Missing CO2

**Cause:** At least CO2 emission value must be provided

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "At least CO2 emission value must be provided",
  "code": "VALIDATION_ERROR"
}
```

**Solution:** Include at least one emission value for CO2.

### 422 Validation Error - Invalid Tag

**Cause:** The custom emission factor data tag specified is invalid

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "The custom emission factor data tag specified is invalid",
  "code": "VALIDATION_ERROR"
}
```

**Solution:** Use `"simple"` or `"advanced"` for the tag field.

### 422 Validation Error - Invalid Uncertainty

**Cause:** The custom emission factor data uncertainty\_grade specified is invalid

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": "The custom emission factor data uncertainty_grade specified is invalid",
  "code": "VALIDATION_ERROR"
}
```

**Solution:** Uncertainty grade must be between 0 and 100.

## Best Practices

### 1. Include All Relevant GHGs

Don't just provide CO2 - include CH4 and N2O when available:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
emission_factor_values = [
    {"gas_type": "CO2", "value": 2.15},
    {"gas_type": "CH4", "value": 0.008},  # Important for waste/agriculture
    {"gas_type": "N2O", "value": 0.002}   # High GWP (265x CO2)
]
```

### 2. Document Your Sources

Always include documentation references:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
additional_docs = "EPD No. ABC-2024-001, Third-party verified by Bureau Veritas, dated 2024-01-15"
```

### 3. Set Realistic Validity Periods

Update factors annually or when supplier data changes:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
factor_start_date = "2024-01-01"
factor_end_date = "2024-12-31"  # Review next year
```

### 4. Be Honest About Uncertainty

Track confidence levels to prioritize data improvement:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# High confidence - supplier EPD
uncertainty_grade = 15

# Medium confidence - industry average
uncertainty_grade = 35

# Low confidence - estimate
uncertainty_grade = 65
```

## Related Endpoints

> [card] [List Factors](https://code.dcycle.io/api-reference/legacy/custom-emission-factors/list.md)
>
> View all factors in a group

> [card] [Update Factor](https://code.dcycle.io/api-reference/legacy/custom-emission-factors/update.md)
>
> Modify existing factor

> [card] [Create Group](https://code.dcycle.io/api-reference/legacy/custom-emission-groups/create.md)
>
> Create a new emission group first

> [card] [Overview](https://code.dcycle.io/api-reference/legacy/custom-emission-factors/overview.md)
>
> Learn about custom factors


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.