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

# Upload a Legal Land Tenure Document

> Upload a legal land tenure document as multipart/form-data to generate a SHA-256 hash stored in the compliance vault and referenceable in DDS generation.

EUDR due diligence obligations require operators to demonstrate that agricultural commodities originate from land held under legitimate legal tenure. This endpoint accepts a land tenure document — such as a title deed, government land certificate, or concession agreement — as a multipart file upload. Upon successful ingestion, the document is hashed, stored securely in the compliance vault, and a reference URL is generated for use during TRACES NT submission. The returned `documentId` and `hash` can be referenced when generating a DDS to embed certified land rights evidence into the declaration payload.

## Endpoint

`POST /api/v1/enterprise/eudr/declarations/documents/upload`

## Request

This endpoint accepts `multipart/form-data` encoding. Do not send a JSON body.

<ParamField body="file" type="file" required>
  The land tenure document file to upload. Accepted formats are `application/pdf`, `image/jpeg`, and `image/png`. Maximum file size is 20 MB.
</ParamField>

<ParamField body="documentType" type="string" required>
  The category of land tenure document being uploaded. Accepted values are:

  * `TITLE_DEED` — Official property title or land ownership certificate.
  * `GOVERNMENT_CERTIFICATE` — A government-issued land use or occupancy certificate.
  * `CONCESSION_AGREEMENT` — A formal concession or lease agreement from a government authority.
  * `CUSTOMARY_RIGHTS` — Documentation of customary or community land rights.
</ParamField>

<ParamField body="batchId" type="string">
  The batch ID to associate this document with. If provided, the document is automatically linked to the specified batch record. Optional if you intend to link the document manually at DDS generation time.
</ParamField>

<ParamField body="issuingAuthority" type="string">
  The name of the government body, registry, or authority that issued the document. Used for audit trail completeness.
</ParamField>

<ParamField body="issueDate" type="string">
  The date the document was officially issued, in `YYYY-MM-DD` format.
</ParamField>

## Response Fields

<ResponseField name="documentId" type="string">
  The unique identifier assigned to the uploaded document within the AgriBackup compliance vault. Use this ID to reference the document when generating a DDS.
</ResponseField>

<ResponseField name="hash" type="string">
  The SHA-256 cryptographic hash of the uploaded file, computed at ingestion time. Pass this hash value in the `legalDocumentHashes` array when calling the Generate DDS endpoint. You can also verify document integrity at any time by hashing your local copy and comparing it against this value.
</ResponseField>

<ResponseField name="referenceUrl" type="string">
  The internal URL used to retrieve the document during TRACES NT submission. This URL is used internally by AgriBackup and does not need to be stored by your application.
</ResponseField>

<ResponseField name="status" type="string">
  The storage status of the uploaded document. Will be `SECURED` once the file has been successfully hashed and vaulted.
</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)

          with open("land_title_certificate.pdf", "rb") as doc_file:
              response = declarations_api.upload_land_tenure_document(
                  file=doc_file,
                  document_type="TITLE_DEED",
                  batch_id="batch_a1b2c3d4e5",
                  issuing_authority="Kenya National Land Commission",
                  issue_date="2024-03-15"
              )

          print("Document ID:", response.document_id)
          print("SHA-256 Hash:", response.hash)
          print("Status:", response.status)

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

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

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

  async function uploadDocument() {
    try {
      const fileStream = fs.createReadStream('./land_title_certificate.pdf');

      const response = await client.declarations.uploadLandTenureDocument({
        file: fileStream,
        documentType: 'TITLE_DEED',
        batchId: 'batch_a1b2c3d4e5',
        issuingAuthority: 'Kenya National Land Commission',
        issueDate: '2024-03-15'
      });

      console.log('Document ID:', response.documentId);
      console.log('SHA-256 Hash:', response.hash);
      console.log('Status:', response.status);
    } catch (error) {
      console.error('Error uploading document:', error.message);
    }
  }

  uploadDocument();
  ```

  ```bash cURL theme={null}
  curl --request POST \
    --url https://live.agribackup.com/api/v1/enterprise/eudr/declarations/documents/upload \
    --header 'X-API-Key: sk_live_YOUR_API_KEY' \
    --form 'file=@land_title_certificate.pdf;type=application/pdf' \
    --form 'documentType=TITLE_DEED' \
    --form 'batchId=batch_a1b2c3d4e5' \
    --form 'issuingAuthority=Kenya National Land Commission' \
    --form 'issueDate=2024-03-15'
  ```
</CodeGroup>

## Example Response

```json theme={null}
{
  "documentId": "doc_123456789abc",
  "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  "referenceUrl": "https://live.agribackup.com/api/v1/enterprise/eudr/documents/doc_123456789abc/download",
  "status": "SECURED"
}
```

<Note>
  Store the `hash` value returned by this endpoint and pass it in the `legalDocumentHashes` array when generating a DDS. This cryptographically links your land tenure documents to the declaration without transmitting the raw document to TRACES NT.
</Note>
