> ## 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.

# Update Custom Emission Group

> Update metadata of an existing custom emission group

# Update Custom Emission Group

Update the name and description of an existing custom emission group.

<Note>
  You can only update the `name` and `description` fields. To change `category` or `ghg_type`, delete the group and create a new one.
</Note>

## 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:** `ff4adcc7-8172-45fe-9cf1-e90a6de53aa9`
</ParamField>

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

  **Example:** `a1b2c3d4-e5f6-7890-abcd-ef1234567890`
</ParamField>

### Path Parameters

<ParamField path="id" type="string" required>
  UUID of the Custom Emission Group to update
</ParamField>

### Body Parameters

All fields are optional - only include the fields you want to update.

<ParamField body="name" type="string">
  Updated name for the group

  **Example:** `"Supplier ABC Materials 2024 (Updated)"`
</ParamField>

<ParamField body="description" type="string">
  Updated description

  **Example:** `"EPD-verified emission factors, updated Q2 2024"`
</ParamField>

## Response

Returns the complete updated group object.

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "group-uuid",
  "name": "Supplier ABC Materials 2024 (Updated)",
  "category": "purchases",
  "description": "EPD-verified emission factors, updated Q2 2024",
  "ghg_type": 1
}
```

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X PATCH "https://api.dcycle.io/api/v1/custom_emission_groups/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 '{
      "name": "Supplier ABC Materials 2024 (Updated)",
      "description": "EPD-verified emission factors, updated Q2 2024"
    }'
  ```

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

  headers = {
      "Authorization": f"Bearer {os.getenv('DCYCLE_API_KEY')}",
      "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      "x-user-id": os.getenv("DCYCLE_USER_ID"),
      "Content-Type": "application/json"
  }

  group_id = "group-uuid"

  update_data = {
      "name": "Supplier ABC Materials 2024 (Updated)",
      "description": "EPD-verified emission factors, updated Q2 2024"
  }

  response = requests.patch(
      f"https://api.dcycle.io/api/v1/custom_emission_groups/{group_id}",
      headers=headers,
      json=update_data
  )

  updated_group = response.json()
  print(f"✅ Updated: {updated_group['name']}")
  ```

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

  const headers = {
    'Authorization': `Bearer ${process.env.DCYCLE_API_KEY}`,
    'x-organization-id': process.env.DCYCLE_ORG_ID,
    'x-user-id': process.env.DCYCLE_USER_ID,
    'Content-Type': 'application/json'
  };

  const groupId = 'group-uuid';

  const updateData = {
    name: 'Supplier ABC Materials 2024 (Updated)',
    description: 'EPD-verified emission factors, updated Q2 2024'
  };

  axios.patch(
    `https://api.dcycle.io/api/v1/custom_emission_groups/${groupId}`,
    updateData,
    { headers }
  )
  .then(response => {
    const updatedGroup = response.data;
    console.log(`✅ Updated: ${updatedGroup.name}`);
  })
  .catch(error => console.error(error));
  ```
</CodeGroup>

## Use Cases

### Update Description with Audit Trail

Add documentation updates to description:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
group = requests.get(
    f"https://api.dcycle.io/api/v1/custom_emission_groups/{group_id}",
    headers=headers
).json()

from datetime import date

updated_description = f"{group['description']} | Updated {date.today().isoformat()} by procurement team"

requests.patch(
    f"https://api.dcycle.io/api/v1/custom_emission_groups/{group_id}",
    headers=headers,
    json={"description": updated_description}
)
```

### Rename Group

Update group name to reflect changes:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
requests.patch(
    f"https://api.dcycle.io/api/v1/custom_emission_groups/{group_id}",
    headers=headers,
    json={
        "name": "Supplier ABC Materials 2024-2025",
        "description": "Extended validity period for 2024-2025"
    }
)
```

## Common Errors

### 404 Not Found

**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.

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Get Group" icon="magnifying-glass" href="/api-docs/custom-emission-groups/get">
    View current values
  </Card>

  <Card title="Delete Group" icon="trash" href="/api-docs/custom-emission-groups/delete">
    Remove group
  </Card>
</CardGroup>
