> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agribackup.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate a Due Diligence Statement (DDS)

> Compile a TRACES NT-compliant Due Diligence Statement from a verified batch, embedding cryptographic land tenure proofs and batch provenance into the output XML.

When a batch clears satellite deforestation screening and its polygons are confirmed compliant, you can generate a Due Diligence Statement (DDS) — the formal XML declaration required by EU Regulation 2023/1115 before a shipment can legally enter the EU market. This endpoint accepts your batch ID and the SHA-256 hashes of your uploaded land tenure documents, then asynchronously compiles the cryptographic evidence into a TRACES NT-ready XML payload. Because generation involves Hedera DLT anchoring, the endpoint returns a `202 Accepted` with a `jobId`. Use the Jobs API to track progress, then retrieve the finalized payload once processing completes.

## Endpoint

`POST /api/v1/enterprise/eudr/declarations/dds`

## Request Parameters

<ParamField body="batchId" type="string" required>
  The unique identifier of the verified and risk-assessed batch for which you are generating the DDS. The batch must have a `COMPLIANT` status before this call will succeed.
</ParamField>

<ParamField body="legalDocumentHashes" type="array" required>
  An array of SHA-256 hashes representing the land tenure and legality documents associated with this batch. Each hash should correspond to a document previously uploaded via the Upload Legal Land Tenure Document endpoint. These hashes are anchored to the Hedera ledger as cryptographic proof of land rights at the time of DDS generation.
</ParamField>

## Response Fields

<ResponseField name="jobId" type="string">
  The unique identifier of the asynchronous DDS generation job. Use this ID to monitor progress via the Jobs API. Once the job reaches `COMPLETED` status, call `GET /api/v1/enterprise/eudr/declarations/dds/{referenceId}` to retrieve the finalized XML payload.
</ResponseField>

<ResponseField name="status" type="string">
  The initial status of the job. Always `PENDING` immediately after acceptance.
</ResponseField>

<ResponseField name="estimatedDurationSec" type="integer">
  An advisory estimate of how many seconds the generation job is expected to take before completing.
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO 8601 timestamp indicating when the DDS generation job was accepted and enqueued.
</ResponseField>

## Code Examples

<CodeGroup>
  ```python Python theme={null}
  import agribackup
  from agribackup.rest import ApiException

  configuration = agribackup.Configuration(host="https://live.agribackup.com/api/v1")
  configuration.api_key['ApiKeyAuth'] = 'sk_live_YOUR_API_KEY'

  with agribackup.ApiClient(configuration) as api_client:
      try:
          declarations_api = agribackup.EnterpriseDeclarationsApi(api_client)

          request = agribackup.DdsGenerationRequest(
              batch_id="batch_a1b2c3d4e5",
              legal_document_hashes=[
                  "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
                  "a3f1b2c4d5e6f7089abcdef0123456789abcdef0123456789abcdef012345678"
              ]
          )

          response = declarations_api.generate_dds(dds_generation_request=request)

          print("Job ID:", response.job_id)
          print("Status:", response.status)
          print("Estimated duration:", response.estimated_duration_sec, "seconds")

      except ApiException as e:
          print("Exception when calling EnterpriseDeclarationsApi: %s\n" % e)
  ```

  ```javascript Node.js theme={null}
  import { AgriBackupClient } from '@agribackup/sdk';

  const client = new AgriBackupClient({
    apiKey: 'sk_live_YOUR_API_KEY',
    baseUrl: 'https://live.agribackup.com/api/v1'
  });

  async function generateDds() {
    try {
      const response = await client.declarations.generateDds({
        batchId: 'batch_a1b2c3d4e5',
        legalDocumentHashes: [
          'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855',
          'a3f1b2c4d5e6f7089abcdef0123456789abcdef0123456789abcdef012345678'
        ]
      });

      console.log('Job ID:', response.jobId);
      console.log('Status:', response.status);
      console.log('Estimated duration:', response.estimatedDurationSec, 'seconds');
    } catch (error) {
      console.error('Error generating DDS:', error.message);
    }
  }

  generateDds();
  ```

  ```bash cURL theme={null}
  curl --request POST \
    --url https://live.agribackup.com/api/v1/enterprise/eudr/declarations/dds \
    --header 'X-API-Key: sk_live_YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "batchId": "batch_a1b2c3d4e5",
      "legalDocumentHashes": [
        "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
        "a3f1b2c4d5e6f7089abcdef0123456789abcdef0123456789abcdef012345678"
      ]
    }'
  ```
</CodeGroup>

## Example Response

```json theme={null}
{
  "jobId": "job_998877",
  "status": "PENDING",
  "estimatedDurationSec": 3,
  "createdAt": "2026-07-15T09:42:00Z"
}
```

<Note>
  DDS generation is asynchronous. After receiving a `202 Accepted`, poll `GET /api/v1/enterprise/eudr/jobs/{jobId}` to track the job phase. Once it reaches `COMPLETED`, retrieve the finalized XML payload using `GET /api/v1/enterprise/eudr/declarations/dds/{referenceId}`. The `referenceId` is returned in the job's result metadata.
</Note>

<Note>
  The batch referenced by `batchId` must have completed satellite deforestation screening and hold a `COMPLIANT` risk status before a DDS can be generated. Attempting to generate a DDS for a `PENDING` or `HIGH_RISK` batch will return a `422 Unprocessable Entity` error.
</Note>
