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

# Retry File Processing

> Manually trigger document processing for a file that has already been uploaded and classified

# Retry File Processing

Use this endpoint when a file is already uploaded, but the downstream processing step has not yet produced a
`file_reading`.

Typical cases:

* retrying a stalled file
* re-queueing processing after operational issues
* manually nudging a file that was classified but never parsed into `file_reading`

This is a retry hook, not the primary upload flow. The normal path is still:

1. upload file
2. confirm upload
3. automatic classification
4. automatic processing into `file_reading`

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

### Body

<ParamField body="event_type" type="string" required>
  Use `PROCESS_DOCUMENT`.
</ParamField>

<ParamField body="detail" type="object" required>
  Additional event detail payload.
</ParamField>

<ParamField body="detail.file_id" type="string" required>
  File UUID to process.
</ParamField>

## Response

Returns `true` (HTTP 200) when the processing event has been accepted and queued. The actual document processing runs asynchronously.

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X POST "https://api.dcycle.io/v1/files/send-event" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}" \
    -H "Content-Type: application/json" \
    -d '{
      "event_type": "PROCESS_DOCUMENT",
      "detail": {
        "file_id": "11111111-1111-1111-1111-111111111111"
      }
    }'
  ```

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

  response = requests.post(
      "https://api.dcycle.io/v1/files/send-event",
      headers={
          "x-api-key": os.environ["DCYCLE_API_KEY"],
          "x-organization-id": os.environ["DCYCLE_ORG_ID"],
          "Content-Type": "application/json",
      },
      json={
          "event_type": "PROCESS_DOCUMENT",
          "detail": {
              "file_id": "11111111-1111-1111-1111-111111111111",
          },
      },
      timeout=30,
  )

  print(response.json())
  ```

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

  axios.post('https://api.dcycle.io/v1/files/send-event', {
    event_type: 'PROCESS_DOCUMENT',
    detail: {
      file_id: '11111111-1111-1111-1111-111111111111',
    },
  }, {
    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"}}
true
```

`true` means the processing event was accepted and queued.

## What Happens Next

After the event is accepted:

1. the processing pipeline runs asynchronously
2. a `file_reading` may be created or updated
3. clients can poll `GET /v1/files/readings?file_id=<file-id>`

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"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"}
```

### 422 Unprocessable Entity

**Cause:** Missing required fields (`event_type`, `detail.file_id`)

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

## Notes

* This endpoint does not return the `file_reading` directly.
* It only queues the processing event.
* If the file has not been classified yet, you may need classification first before processing succeeds.
* This endpoint can be safely treated as a retry operation for operational recovery.

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Upload Files" icon="upload" href="/api-reference/files/upload">
    Upload files via presigned S3 URLs
  </Card>

  <Card title="List File Readings" icon="file-lines" href="/api-reference/files/readings">
    Check processing results
  </Card>

  <Card title="Update Reading" icon="pencil" href="/api-reference/files/update-reading">
    Edit extracted content
  </Card>

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