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

# Update an EUDR Batch | AgriBackup API Reference

> Partially update a registered EUDR batch — quantity, commodity description, HS code, or harvest date — before it is locked to a shipment or TRACES NT.

Partially updates the mutable fields of a registered EUDR batch. You can correct the commodity description, quantity, HS code, or harvest date at any point **before** the batch is cryptographically locked to a shipment on the Hedera ledger or submitted to TRACES NT. Once locked, the batch record is immutable and this endpoint will return `403 Forbidden`. Only the fields you include in the request body are updated; omitted fields retain their existing values.

## Request Headers

| Header      | Required | Description                            |
| ----------- | -------- | -------------------------------------- |
| `X-API-Key` | ✅        | Your live API key, e.g. `sk_live_...`. |

## Path Parameters

| Parameter | Type   | Required | Description                                       |
| --------- | ------ | -------- | ------------------------------------------------- |
| `batchId` | string | ✅        | The unique batch identifier (UUID) to be updated. |

## Request Body

All fields are optional. Include only the fields you wish to change.

| Field                  | Type          | Description                                                               |
| ---------------------- | ------------- | ------------------------------------------------------------------------- |
| `quantity`             | number        | Updated total commodity weight or volume.                                 |
| `commodityDescription` | string        | Updated human-readable commodity description, e.g. `Roasted Cocoa Beans`. |
| `hsCode`               | string        | Updated 6-digit HS code, e.g. `180100`.                                   |
| `harvestDate`          | string (date) | Updated harvest date in `YYYY-MM-DD` format, e.g. `2023-11-15`.           |

```json theme={null}
{
  "quantity": 5000,
  "commodityDescription": "Roasted Cocoa Beans",
  "hsCode": "180100",
  "harvestDate": "2023-11-15"
}
```

## Response — 200 OK

Returns an empty object `{}` on successful update.

## Error Responses

| Status | Meaning                                                                                  |
| ------ | ---------------------------------------------------------------------------------------- |
| `401`  | Missing or invalid `X-API-Key`.                                                          |
| `403`  | The batch is cryptographically linked to a shipment or TRACES NT and cannot be modified. |
| `404`  | No batch found with the given `batchId`.                                                 |

## 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:
          api_instance = agribackup.EnterpriseBatchesApi(api_client)

          update = agribackup.BatchUpdateRequest(
              quantity=5000,
              commodity_description='Roasted Cocoa Beans',
              hs_code='180100',
              harvest_date='2023-11-15'
          )

          api_instance.update_batch(
              batch_id='uuid-1234',
              batch_update_request=update
          )
          print("Batch updated successfully.")
      except ApiException as e:
          print("Error:", 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 updateBatch(batchId) {
    try {
      await client.batches.updateBatch({
        batchId,
        quantity: 5000,
        commodityDescription: 'Roasted Cocoa Beans',
        hsCode: '180100',
        harvestDate: '2023-11-15'
      });
      console.log('Batch updated successfully.');
    } catch (error) {
      console.error('Error:', error.message);
    }
  }

  updateBatch('uuid-1234');
  ```

  ```bash cURL theme={null}
  curl -X PATCH https://live.agribackup.com/api/v1/enterprise/eudr/batches/uuid-1234 \
    -H "X-API-Key: sk_live_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "quantity": 5000,
      "commodityDescription": "Roasted Cocoa Beans",
      "hsCode": "180100",
      "harvestDate": "2023-11-15"
    }'
  ```
</CodeGroup>


## OpenAPI

````yaml patch /api/v1/enterprise/eudr/batches/{batchId}
openapi: 3.0.1
info:
  title: AgriBackup Enterprise EUDR API
  description: >-
    # Introduction


    AgriBackup is the cryptographic compliance engine for EU-bound commodity
    imports. Built on Deterministic Logic, Immutable Evidence, and
    High-Throughput Ingestion, our API provides Tier-1 enterprise routing for EU
    Deforestation Regulation (EUDR).


    ## The Integration Vector

    To integrate this Digital Trust Layer into your ERP, you must execute the
    following sequence:

    1. **Authentication:** Generate your `X-API-Key` from the client dashboard.

    2. **Telemetry:** Register your webhook URLs via `POST /webhooks`.

    3. **Ingestion:** Push your GeoJSON polygons via `POST /polygons`.

    4. **Logistics:** Lock the batch to a shipment via `POST /shipments/link`.


    ## Asynchronous Architecture

    Because satellite deforestation screening and Hedera DLT anchoring take
    time, ingestion endpoints return a `202 Accepted`. You must listen for the
    corresponding Webhook to confirm cryptographic execution.


    ## Base URLs

    * **Production:** `https://live.agribackup.com`

    * **Sandbox:** `https://sandbox.agribackup.com`
  contact:
    name: AgriBackup Architecture Team
    url: https://agribackup.com
    email: contact@agribackup.com
  license:
    name: Proprietary
    url: https://agribackup.com/terms
  version: v1.0
servers:
  - url: https://live.agribackup.com
    description: Production (Mainnet)
  - url: https://sandbox.agribackup.com
    description: Sandbox (Testnet)
security: []
tags:
  - name: Enterprise Risk Management
  - name: Enterprise Clearance Webhooks
    description: Asynchronous status receivers for TRACES NT
  - name: Enterprise Jobs
    description: Query status and metrics of asynchronous compliance jobs
  - name: Enterprise Suppliers
  - name: Enterprise Diagnostics
    description: Monitor API health, consensus ledger, and satellite systems availability
  - name: Enterprise Suppliers
    description: Map internal ERP vendor IDs to EU Operator UUIDs
  - name: Enterprise Webhooks
    description: Register endpoints for asynchronous compliance events
  - name: Enterprise Archival
    description: Endpoints for bulk compliance archiving and auditor extensibility
  - name: Enterprise Logistics
    description: Smart contract linking of batches to logistics shipments
  - name: Enterprise Declarations
    description: DDS generation with legal land tenure proofs
  - name: Enterprise Batches
  - name: Enterprise API Keys
  - name: Enterprise Diagnostics
  - name: Enterprise Logistics
  - name: Enterprise Jobs
  - name: Enterprise Evidence
    description: Cryptographic evidence ledger anchored on Hedera Hashgraph
  - name: Enterprise Declarations
  - name: Enterprise Credentials
  - name: Enterprise Evidence
  - name: Enterprise Risk Management
    description: Pre-assessment of country risk and satellite deforestation probabilities
  - name: Enterprise Batches
    description: Programmatic batch ingestion and management
  - name: Enterprise Polygons
  - name: Introduction
  - name: Enterprise Polygons
    description: Programmatic polygon ingestion and verification
  - name: Enterprise Archival
  - name: Enterprise Credentials
    description: Programmatic ingestion of vault-secured enterprise secrets
  - name: Enterprise API Keys
    description: Endpoints for managing B2B API Keys (Requires standard JWT login)
  - name: Enterprise Webhooks
paths:
  /api/v1/enterprise/eudr/batches/{batchId}:
    patch:
      tags:
        - Enterprise Batches
      summary: Update an EUDR batch
      description: >-
        Updates batch details if it is not cryptographically linked to a
        shipment or TRACES NT.
      operationId: updateBatch
      parameters:
        - name: batchId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchUpdateRequest'
        required: true
      responses:
        '200':
          description: OK
          headers:
            X-RateLimit-Limit:
              description: >-
                The maximum number of requests you're permitted to make per
                hour.
              schema:
                type: integer
                format: int32
            X-RateLimit-Remaining:
              description: >-
                The number of requests remaining in the current rate limit
                window.
              schema:
                type: integer
                format: int32
            X-RateLimit-Reset:
              description: >-
                The time at which the current rate limit window resets in UTC
                epoch seconds.
              schema:
                type: integer
                format: int32
          content:
            '*/*':
              schema:
                type: object
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - lang: Python
          source: >-
            import agribackup

            from agribackup.rest import ApiException


            # Initialize Client

            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:
                    api_instance = agribackup.EnterpriseBatchesApi(api_client)
                    response = api_instance.update_batch()
                    print(response)
                except ApiException as e:
                    print("Exception when calling API: %s\n" % e)
        - lang: Node.js
          source: |-
            import { AgriBackupClient } from '@agribackup/sdk';

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

            async function execute() {
              try {
                const response = await client.batches.updateBatch();
                console.log(response);
              } catch (error) {
                console.error(error);
              }
            }
        - lang: Java
          source: |-
            import com.agribackup.client.*;
            import com.agribackup.client.api.*;
            import com.agribackup.client.model.*;

            public class Example {
                public static void main(String[] args) {
                    ApiClient defaultClient = Configuration.getDefaultApiClient();
                    defaultClient.setBasePath("https://live.agribackup.com/api/v1");
                    defaultClient.setApiKey("sk_live_YOUR_API_KEY");

                    EnterpriseBatchesApi apiInstance = new EnterpriseBatchesApi(defaultClient);
                    try {
                        Object result = apiInstance.updateBatch();
                        System.out.println(result);
                    } catch (ApiException e) {
                        System.err.println("Exception when calling API: " + e.getResponseBody());
                    }
                }
            }
        - lang: C#
          source: |-
            using System;
            using System.Threading.Tasks;
            using AgriBackup.SDK.Api;
            using AgriBackup.SDK.Client;
            using AgriBackup.SDK.Model;

            class Program {
                static async Task Main() {
                    Configuration config = new Configuration();
                    config.BasePath = "https://live.agribackup.com/api/v1";
                    config.AddApiKey("ApiKeyAuth", "sk_live_YOUR_API_KEY");

                    var apiInstance = new EnterpriseBatchesApi(config);
                    try {
                        var result = await apiInstance.UpdateBatchAsync();
                        Console.WriteLine(result);
                    } catch (ApiException e) {
                        Console.WriteLine("Exception when calling API: " + e.Message);
                    }
                }
            }
components:
  schemas:
    BatchUpdateRequest:
      type: object
      properties:
        quantity:
          type: number
          description: Updated total weight/volume
          example: 5000
        commodityDescription:
          type: string
          description: Updated commodity description
          example: Roasted Cocoa Beans
        hsCode:
          type: string
          description: Updated HS6 Code
          example: '180100'
        harvestDate:
          type: string
          description: Updated harvest date
          format: date
          example: '2023-11-15'
      description: Payload for updating a consolidated batch pre-consensus
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enterprise API Key provided via the AgriBackup developer console.
      name: X-API-Key
      in: header

````