> ## 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 Database Version

> Create a version in a custom emission factor database

[← Custom Emission Factors](/api-reference/custom-emission-factors/overview)

A version is a release of the database's factors, typically one per reference year. Its `id` is the `source_id` of the record endpoints.

<Warning>
  **Beta.** Part of the custom emission factors API, currently in beta. The contract may still change before general
  availability.
</Warning>

<RequestExample>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/emission-factors/custom-databases/5f1c2e7a-3b4d-4e8f-9a01-2c3d4e5f6a7b/versions" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "version": "2024 measured",
      "reference_year": 2024
    }'
  ```

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

  import requests

  response = requests.post(
      "https://api.dcycle.io/v1/emission-factors/custom-databases/5f1c2e7a-3b4d-4e8f-9a01-2c3d4e5f6a7b/versions",
      headers={
          "x-api-key": os.environ["DCYCLE_API_KEY"],
          "x-organization-id": os.environ["DCYCLE_ORG_ID"],
      },
      json={
          "version": "2024 measured",
          "reference_year": 2024
      },
      timeout=30,
  )
  response.raise_for_status()
  print(response.json())
  ```

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

  const response = await axios.post('https://api.dcycle.io/v1/emission-factors/custom-databases/5f1c2e7a-3b4d-4e8f-9a01-2c3d4e5f6a7b/versions', {
    "version": "2024 measured",
    "reference_year": 2024
  }, {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
    },
  });
  console.log(response.status, response.data);
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={"theme":{"light":"github-light","dark":"github-dark"}}
  {
    "id": "7a8b9c0d-1e2f-4a3b-8c4d-5e6f7a8b9c0d",
    "name": "custom:5f1c2e7a-3b4d-4e8f-9a01-2c3d4e5f6a7b:acme-measured-factors",
    "version": "2024 measured",
    "internal_incremental_version": 1,
    "reference_year": 2024,
    "url": null,
    "record_count": 0,
    "matching_record_count": null
  }
  ```
</ResponseExample>

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

<ParamField path="database_id" type="uuid" required>
  The database id.

  **Example:** `5f1c2e7a-3b4d-4e8f-9a01-2c3d4e5f6a7b`
</ParamField>

### Body Parameters

<ParamField body="version" type="string" required>
  Version label, 1 to 255 characters.

  **Example:** `"2024 measured"`
</ParamField>

<ParamField body="reference_year" type="integer | null">
  Year the factors refer to, between 1900 and 2200.

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

<ParamField body="url" type="string | null">
  Reference URL (e.g. the report the factors come from), up to 2,048 characters.
</ParamField>

## Response

The created version (`201 Created`):

<ResponseField name="id" type="uuid">Version id: the `source_id` used in record paths.</ResponseField>
<ResponseField name="name" type="string">Internal name, generated from the database.</ResponseField>
<ResponseField name="version" type="string">The version label you set.</ResponseField>
<ResponseField name="internal_incremental_version" type="integer">1 for the first version of the database, then 2, 3…</ResponseField>
<ResponseField name="reference_year" type="integer | null">Year the factors refer to.</ResponseField>
<ResponseField name="url" type="string | null">Reference URL.</ResponseField>
<ResponseField name="record_count" type="integer">Number of records.</ResponseField>
<ResponseField name="matching_record_count" type="integer | null">Records linked to the `activity_category` you filtered by; `null` without the filter.</ResponseField>

## Common Errors

### 401 Unauthorized

Missing or invalid API key.

### 403 Forbidden

`LOGGED_USER_NOT_MEMBER`: the API key's user is not a member of the organization in `x-organization-id`.

### 404 CUSTOM\_DATABASE\_NOT\_FOUND

The database does not exist or is not visible to your organization.

### 403 CUSTOM\_DATABASE\_NOT\_OWNER

Only the organization that owns the database can add versions.

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Create Record" icon="plus" href="/api-reference/custom-emission-factors/create-record">
    Next step: a factor in the version
  </Card>

  <Card title="List Versions" icon="list" href="/api-reference/custom-emission-factors/list-versions">
    Versions of a database
  </Card>
</CardGroup>
