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

> Create a custom emission factor database owned by your organization

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

A database groups your organization's custom factors. Create one per origin of factors (your own measurements, a supplier, a study…).

<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" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "acme-measured-factors",
      "display_name": "Acme measured factors",
      "countries": [
        "ES"
      ],
      "description": "Factors measured at our plants and provided by our waste managers"
    }'
  ```

  ```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",
      headers={
          "x-api-key": os.environ["DCYCLE_API_KEY"],
          "x-organization-id": os.environ["DCYCLE_ORG_ID"],
      },
      json={
          "name": "acme-measured-factors",
          "display_name": "Acme measured factors",
          "countries": [
              "ES"
          ],
          "description": "Factors measured at our plants and provided by our waste managers"
      },
      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', {
    "name": "acme-measured-factors",
    "display_name": "Acme measured factors",
    "countries": [
      "ES"
    ],
    "description": "Factors measured at our plants and provided by our waste managers"
  }, {
    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": "5f1c2e7a-3b4d-4e8f-9a01-2c3d4e5f6a7b",
    "name": "acme-measured-factors",
    "display_name": "Acme measured factors",
    "full_name": "Acme measured factors",
    "description": "Factors measured at our plants and provided by our waste managers",
    "website": null,
    "countries": [
      "ES"
    ],
    "organization_id": "a8315ef3-dd50-43f8-b7ce-d839e68d51fa",
    "owner_organization_name": "Acme Industrial S.L.",
    "child_access": "all_descendants",
    "image_url": null,
    "version_count": 0
  }
  ```
</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>

### Body Parameters

<ParamField body="name" type="string" required>
  Technical name, 1 to 255 characters. It must be **unique across all of Dcycle** (public databases included), so
  prefix it with your company, e.g. `acme-measured-factors`.

  **Example:** `"acme-measured-factors"`
</ParamField>

<ParamField body="display_name" type="string" required>
  Name shown in the platform, 1 to 255 characters.

  **Example:** `"Acme measured factors"`
</ParamField>

<ParamField body="full_name" type="string | null">
  Long name. Defaults to `display_name`.
</ParamField>

<ParamField body="description" type="string | null">
  Free text: where the factors come from.
</ParamField>

<ParamField body="website" type="string | null">
  Reference URL, up to 2,048 characters.
</ParamField>

<ParamField body="countries" type="array[string] | null">
  ISO 3166-1 alpha-2 codes the factors apply to.

  **Example:** `["ES"]`
</ParamField>

<ParamField body="child_access" type="string" default="all_descendants">
  Who in your group can use the database.

  **Available values:** `all_descendants` (every subsidiary), `private` (only your organization), `selected` (the
  subsidiaries you share it with explicitly).
</ParamField>

## Response

The created database (`201 Created`):

<ResponseField name="id" type="uuid">Database id.</ResponseField>
<ResponseField name="name" type="string">Unique technical name.</ResponseField>
<ResponseField name="display_name" type="string">Name shown in the platform.</ResponseField>
<ResponseField name="full_name" type="string">Long name; defaults to `display_name`.</ResponseField>
<ResponseField name="description" type="string | null">Free text.</ResponseField>
<ResponseField name="website" type="string | null">Reference URL.</ResponseField>
<ResponseField name="countries" type="array[string] | null">ISO 3166-1 alpha-2 codes the factors apply to.</ResponseField>
<ResponseField name="organization_id" type="uuid">Owning organization.</ResponseField>
<ResponseField name="owner_organization_name" type="string | null">Owning organization's name.</ResponseField>
<ResponseField name="child_access" type="string">Who in the group can use it. **Available values:** `private`, `all_descendants`, `selected`.</ResponseField>
<ResponseField name="image_url" type="string | null">Logo URL.</ResponseField>
<ResponseField name="version_count" type="integer">Number of versions.</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`.

### 409 CUSTOM\_DATABASE\_NAME\_EXISTS

A database (yours, another organization's or a public one) already has that `name`. Choose another.

### 422 Validation Error

A missing or too long field.

## Related Endpoints

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

  <Card title="List Databases" icon="list" href="/api-reference/custom-emission-factors/list-databases">
    Databases visible to your organization
  </Card>
</CardGroup>
