# Batch Methods

Batch methods are used to start the process of signing, upload files, which are meant to be signed, download signed files and delete the batch from the cache.&#x20;

A batch is a package that contains files for sign or validation. The package format is ZIP (without directories).

## Create new batch

<mark style="color:green;">`POST`</mark> `/api/CreateBatch/{processId}`

Method is used to create new batch with an assigned processId.

### Path Parameters

| Name      | Type    | Description |
| --------- | ------- | ----------- |
| processId | Integer | required    |

### Response

{% tabs %}
{% tab title="201: Created Batch created successfully" %}
{% code title="Example response:" %}

```json
{
    "id": “2123”,
    "providerSettingsId": “1”,
    "creationDate": "2023-01-01 12:00:00",
    "status": “1”
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request The {processID} value is not valid" %}

{% endtab %}

{% tab title="404: Not Found Not found" %}

{% endtab %}
{% endtabs %}

## Upload package (ZIP)

<mark style="color:green;">`POST`</mark> `/api/upload/{batchId}`

Method is used to upload a file to the batch. The Batch **Id** value generated and returned during the **CreateBatch** operation. The contents of the zip file should be sent as a binary octet stream (<https://www.iana.org/assignments/media-types/application/octet-stream>)

### Path Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| batchId | Integer | required    |

### Request Body

| Name                   | Type                   | Description |
| ---------------------- | ---------------------- | ----------- |
| \<binary-octet-stream> | \<binary-octet-stream> |             |

### Response

{% tabs %}
{% tab title="202: Accepted File was accepted" %}

<pre class="language-json" data-title="Example response:"><code class="lang-json">{
    "id": "1”,
    "counterpartyId": “1”,
    "name": "file_name.pdf",
    "signed": "false”,
    "hash": null,
    "signature": null,
    "batchId": 2123,
    "creationDate": "2023-01-01 00:00:00",
    "isZip": "true”,
<strong>    "tsaId": “1”
</strong>}
</code></pre>

{% endtab %}

{% tab title="204: No Content No content" %}

{% endtab %}

{% tab title="404: Not Found Not found" %}

{% endtab %}
{% endtabs %}

## Get batch status

<mark style="color:blue;">`GET`</mark> `/api/BatchStatus/{batchId}`

Use this method to get an information about the status of the batch. Possible statuses below.

### Path Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| batchId | Integer | required    |

### Response

{% tabs %}
{% tab title="200: OK Status is presented (OK)" %}
{% code title="Example response:" %}

```json
{
    "id":2123,
    "status": "READY",
    "creationDate": "2023-01-01 10:00:00",
    "documents": [
        {
            "id": "1”,
            "signed": "false”,
            "fileName": "test.pdf",
            "signingResult_Success": "false"
        }
    ]
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found Not found" %}

{% endtab %}

{% tab title="500: Internal Server Error Internal server error" %}

{% endtab %}
{% endtabs %}

### Possible statuses

<table><thead><tr><th width="88.33333333333331">Id</th><th width="271">Value</th><th>Description</th></tr></thead><tbody><tr><td>0</td><td>NEW</td><td>New batch successfully created</td></tr><tr><td>1</td><td>UPLOADED</td><td>Zip package successfully received</td></tr><tr><td>2</td><td>ACCEPTED</td><td>Batch successfully created</td></tr><tr><td>3</td><td>READY</td><td>For internal use (awaiting processing)</td></tr><tr><td>4</td><td>IN_PROGRESS</td><td>Signing/stamping process in progress</td></tr><tr><td>5</td><td>FINISHING</td><td>For internal use</td></tr><tr><td>6</td><td>CLOSED</td><td>Batch closed, ready for download</td></tr><tr><td>7</td><td>DELETED</td><td>Batch romoved from cache</td></tr></tbody></table>

## Accept batch

<mark style="color:green;">`POST`</mark> `/api/AcceptBatch`

This method accepts batch, starts the signature/validation process

### Path Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| batchId | Integer | required    |

{% tabs %}
{% tab title="202: Accepted Batch is accepted" %}
{% code title="Example response:" %}

```json
{
    "id": 2123,
    "providerSettingsId": “1”,
    "creationDate": "2023-01-01 10:00:00",
    "status": “0”
}
```

{% endcode %}
{% endtab %}

{% tab title="404: Not Found Not found. BatchId not found" %}

{% endtab %}
{% endtabs %}

## Download signed batch

<mark style="color:blue;">`GET`</mark> `/api/batchfile/{batchId}`

This method provides a signed package for download

### Path Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| batchId | Integer | required    |

{% tabs %}
{% tab title="200: OK File is available to download (OK)" %}
\<binary-octet-stream>
{% endtab %}

{% tab title="404: Not Found Not found" %}

{% endtab %}

{% tab title="500: Internal Server Error Internal server error" %}

{% endtab %}
{% endtabs %}

## Delete batch from the cache

<mark style="color:red;">`DELETE`</mark> `/api/BatchDeleteCache/{batchId}`

This method removes the batch from the cache on the server side

### Path Parameters

| Name    | Type    | Description |
| ------- | ------- | ----------- |
| batchId | Integer | required    |

{% tabs %}
{% tab title="200: OK Batch is deleted (OK)" %}

<pre class="language-json" data-title="Example response:"><code class="lang-json">{
    "id":2123,
    "status": "DELETED",
<strong>    "creationDate": "2023-01-01 10:00:00",
</strong>    "documents": [&#x3C;“array of documents”>]
}
</code></pre>

{% endtab %}

{% tab title="404: Not Found Not found" %}

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.signius.eu/api/seal-api/server-methods/batch-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
