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

> Edit extracted file reading content before creating invoices or wastes

# Update File Reading

Use this endpoint to correct OCR or LLM extraction output before converting the reading into invoices or wastes.

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

### Path Parameters

<ParamField path="file_reading_id" type="string" required>
  File reading UUID from `GET /v1/files/readings`.
</ParamField>

### Body

Send the full updated `content.items` array. The shape depends on the reading category.

<ParamField body="content" type="object" required>
  Wrapper for the updated extracted content.
</ParamField>

<ParamField body="content.items" type="array" required>
  Updated parsed items. Replace the existing list with the corrected values.
</ParamField>

## Response

Returns the updated file reading (HTTP 200).

<ResponseField name="id" type="string">
  File reading UUID.
</ResponseField>

<ResponseField name="status" type="string">
  Processing status (e.g. `"success"`).
</ResponseField>

<ResponseField name="content" type="object">
  Updated extracted content.

  <Expandable title="Content Object">
    <ResponseField name="items" type="array[object]">
      Updated line items. Shape varies by reading category (e.g. invoice fields for energy, waste fields for wastes).
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X PUT "https://api.dcycle.io/v1/files/readings/22222222-2222-2222-2222-222222222222" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "content": {
        "items": [
          {
            "invoice_number": "WTR-2024-03",
            "quantity": 32.1,
            "unit": "cubic_metre_(m3)",
            "start_date": "2024-03-01",
            "end_date": "2024-03-31"
          }
        ]
      }
    }'
  ```

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

  requests.put(
      "https://api.dcycle.io/v1/files/readings/22222222-2222-2222-2222-222222222222",
      headers={
          "x-api-key": os.environ["DCYCLE_API_KEY"],
          "x-organization-id": os.environ["DCYCLE_ORG_ID"],
          "Content-Type": "application/json",
      },
      json={
          "content": {
              "items": [
                  {
                      "invoice_number": "WTR-2024-03",
                      "quantity": 32.1,
                      "unit": "cubic_metre_(m3)",
                      "start_date": "2024-03-01",
                      "end_date": "2024-03-31",
                  }
              ]
          }
      },
      timeout=30,
  ).raise_for_status()
  ```

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

  axios.put('https://api.dcycle.io/v1/files/readings/22222222-2222-2222-2222-222222222222', {
    content: {
      items: [
        {
          invoice_number: 'WTR-2024-03',
          quantity: 32.1,
          unit: 'cubic_metre_(m3)',
          start_date: '2024-03-01',
          end_date: '2024-03-31',
        },
      ],
    },
  }, {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
      'Content-Type': 'application/json',
    },
  }).then(response => console.log(response.data));
  ```
</CodeGroup>

### Successful Response

````json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "22222222-2222-2222-2222-222222222222",
  "status": "success",
  "content": {
    "items": [
      {
        "invoice_number": "WTR-2024-03",
        "quantity": 32.1,
        "unit": "cubic_metre_(m3)",
        "start_date": "2024-03-01",
        "end_date": "2024-03-31"
      }
    ]
  }
}

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json
{"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"}
```

### 404 Not Found

**Cause:** The file reading does not exist or belongs to another organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Not Found"}
```

### 422 Unprocessable Entity

**Cause:** Missing required `content.items` array

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "detail": [
    {
      "loc": ["body", "content"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}
```

## Notes

* Use this before calling `POST /v1/files/readings`.
* The API does not currently publish category-specific schemas in the docs, so clients should start from the values
  returned by `GET /v1/files/readings`, modify only the needed fields, and send the full `content.items` array back.

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List File Readings" icon="file-lines" href="/api-reference/files/readings">
    Retrieve readings to get the current content
  </Card>

  <Card title="Create Records" icon="plus" href="/api-reference/files/create-records">
    Convert the edited reading into invoices or wastes
  </Card>

  <Card title="Upload Files" icon="upload" href="/api-reference/files/upload">
    Upload new files via presigned S3 URLs
  </Card>

  <Card title="Files Overview" icon="book" href="/api-reference/files/overview">
    Learn about the Files API
  </Card>
</CardGroup>
