---
title: Persist API specifications
slug: api-marketplace/persist-api-specifications
description: Learn how to use Signzy's file hosting service called Persist to upload and obtain direct URLs for files. Discover how to leverage Signzy's powerful APIs for document processing, including OCR, face match, PDF conversions, and document signing. Explore th
createdAt: 2023-04-25T17:11:12.000Z
---

## Introduction

Signzy's file hosting service called Persist allows clients to upload files and obtain a direct URL to the file. Clients can use this URL as input to Signzy's APIs that work on documents and files to perform tasks such as OCR, Face Match, PDF Conversions, and Document Templators and Document Signing.

By incorporating the Persist API into your application , you can ensure seamless integration with Signzy's API Stack , providing a reliable and secure data storage solution.&#x20;

### API Details :

:::CodeblockTabs
UAT/Testing Environment

```curl
https://preproduction-persist.signzy.tech/api/files/upload
```
:::

:::CodeblockTabs
Production

```curl
https://persist.signzy.tech/api/files/upload
```
:::

**Production Environment**

### Request Body Parameters

| Parameter | Type              | Description                                                                                                                                                                                                                                                                                                                                                                      |
| --------- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| file      | File (required)   | The file to be uploaded should be included in the request as part of the multipart/form-data format. This format allows for the transmission of files and data as binary objects in the same HTTP request. The file parameter should be included in the request with the key `file` and the value set to the file to be uploaded. The file should be of type File and not empty. |
| ttl       | String (optional) | The time to live for the file. Accepts units such as sec(s), min(s), hr(s), day(s), month(s), year(s), and infinity.<br />Default : 30 Seconds                                                                                                                                                                                                                                   |

### Request Headers:

| Name         | Value               | Required | Description                                         |
| ------------ | ------------------- | -------- | --------------------------------------------------- |
| Content-Type | multipart/form-data | Yes      | The type of content that the request body contains. |

### Code Samples:

:::CodeblockTabs
```curl
curl --location --request POST 'https://persist.signzy.tech/api/files/upload' \
--form 'ttl="10 mins"' \
--form 'file=@"/path/to/file"'
```

```nodejs
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');

async function uploadFile(filePath) {
    // Create an instance of FormData
    const formData = new FormData();

    // Append the TTL (Time To Live) for the file
    formData.append('ttl', '10 mins');

    // Append the file to be uploaded
    // Note: Replace '/path/to/file' with the actual file path
    formData.append('file', fs.createReadStream(filePath));

    try {
        // Make the POST request to the upload endpoint
        const response = await axios.post('https://persist.signzy.tech/api/files/upload', formData, {
            headers: {
                // Include the form boundary in the headers
                ...formData.getHeaders(),
            },
        });

        // Log the response from the server
        console.log('File uploaded successfully:', response.data);
    } catch (error) {
        // Handle any errors during the upload
        console.error('Error uploading file:', error);
    }
}

// Usage example
uploadFile('/path/to/file'); // Replace with the actual file path

```

```python
import requests

def upload_file(file_path):
    url = 'https://persist.signzy.tech/api/files/upload'

    # Multipart form data
    payload = {
        'ttl': ('', '10 mins'),  # Additional form field
    }
    files = {
        'file': open(file_path, 'rb')  # File to be uploaded
    }

    response = requests.post(url, files=files, data=payload)

    if response.status_code == 200:
        print("File uploaded successfully")
        print(response.json())
    else:
        print("Failed to upload the file")
        print(response.text)

    # Close the file
    files['file'].close()

# Example usage
upload_file('/path/to/file')  # Replace with your file path

```

```go
package main

import (
    "bytes"
    "io"
    "mime/multipart"
    "net/http"
    "os"
)

func uploadFile(filePath string) {
    // URL to which the request is made
    url := "https://persist.signzy.tech/api/files/upload"

    // Open the file
    file, err := os.Open(filePath)
    if err != nil {
        panic(err)
    }
    defer file.Close()

    // Create a new buffer and a multipart writer
    var requestBody bytes.Buffer
    writer := multipart.NewWriter(&requestBody)

    // Add the TTL field
    err = writer.WriteField("ttl", "10 mins")
    if err != nil {
        panic(err)
    }

    // Create a form-data header for the file and add the file
    part, err := writer.CreateFormFile("file", file.Name())
    if err != nil {
        panic(err)
    }
    _, err = io.Copy(part, file)
    if err != nil {
        panic(err)
    }

    // Close the writer to finalize the multipart message
    writer.Close()

    // Create and send the request
    request, err := http.NewRequest("POST", url, &requestBody)
    if err != nil {
        panic(err)
    }
    request.Header.Set("Content-Type", writer.FormDataContentType())

    // Send the request
    client := &http.Client{}
    response, err := client.Do(request)
    if err != nil {
        panic(err)
    }
    defer response.Body.Close()

    // Handle the response
    if response.StatusCode == http.StatusOK {
        println("File uploaded successfully")
    } else {
        println("Failed to upload file")
    }
}

func main() {
    // Example usage
    uploadFile("/path/to/file") // Replace with the actual file path
}

```
:::

Request Data:

- Method: POST
- Content-Type: multipart/form-data
- Parameters:

Note: If multiple parameters with the same name are passed/uploaded, the first ones are considered.

### File parameter

**The file parameter is mandatory and must be included in the API call. The ttl, optimize, and key parameters are optional.**

The **file parameter** is a required parameter in the Signzy API for uploading files to Signzy's Persist file system. The file to be uploaded should be included in the request as part of the **multipart/form-data** format.

The **file parameter** should be included in the request with the key **file** and the value set to the file to be uploaded. The file should be of type **File** and not empty. The maximum file size limit for the upload is **100MB**.

Note that if multiple parameters with the same name are passed or uploaded, the first ones are considered. Therefore, it is important to ensure that the **file parameter** is included as the first parameter in the request.

When the file is uploaded successfully, the API will return a JSON response containing information about the uploaded file, including the unique identifier of the file (**id**), the MIME type of the file (**filetype**), the size of the file in bytes (**size**), the URL to access the file (**directURL**), and whether the file is password protected (**protected**).

### TTL parameter

The ttl parameter sets the time to live for the file. **By default, the URL to the file expires in 30&#x20;**&#x73;econds. The ttl parameter accepts units such as seconds, minutes, hours, days, months, years, and infinity. If a value is provided for ttl without any units, e.g., 45, the file expiry time will be set to 45 seconds.

The **ttl parameter** in Signzy's file system is used to specify the time to live for the uploaded file. It determines the expiration time for the **directURL** provided in the response.

The **ttl parameter** accepts time units such as seconds, minutes, hours, days, months, years, and infinity. The units are represented as **sec(s), min(s), hr(s), day(s), month(s), year(s)**, respectively.

Some examples of **ttl** are:

- **10 mins**: The file URL will expire after 10 minutes.
- **1 day**s The file URL will expire after 1 day.
- **44 secs**: The file URL will expire after 44 seconds.
- **15**: The file URL will expire after 15 seconds.
- **infinity**: The file URL will not expire.

By default, the **ttl** is set to 30 seconds if not explicitly specified in the request. If the **ttl** parameter is specified without any units, e.g., **45**, the file expiry time will be set to 45 seconds.

In summary, the **ttl parameter** provides flexibility to control the expiration time of the file URL and helps to ensure the security of the uploaded file.

### Success scenario

When a user sends a multipart/form-data request to upload a file to Signzy's Persist file system and the request is processed successfully, the API responds with the following success message:

```json
{
	"file": {
		"id": 547935735,
		"filetype": "image/png",
		"size": 176998,
		"directURL": "https://persist.signzy.tech/api/files/111000111/download/XXXX3da1340a0ab98a34ab4eaf34dd46XXXX9.png",
		"protected": false
	}
}
```

This success message indicates that the file upload was successful. The **id** field in the response represents the unique identifier of the uploaded file, while the **filetype** field represents the MIME type of the file. The **size** field represents the size of the uploaded file in bytes.

The **directURL** field represents the URL that can be used to access the uploaded file. This URL can be used as input to Signzy's APIs for tasks such as OCR, face match, PDF conversions, and document signing. The **protected** field indicates whether the file is password protected or not.

Note that the **directURL** expires in 30 seconds by default, unless explicitly specified in the inbound request using the **ttl** parameter. If the **ttl** parameter is specified without any units, e.g., 45, the file expiry time will be set to 45 seconds. The file size limit is 100MB.

To access the uploaded file, the user can simply follow the **directURL** provided in the response.

### Error Scenario (\`file\` parameter missing)

When a user sends a multipart/form-data request to upload a file to Signzy's Persist file system without providing the file parameter, the API responds with the following error:

```json
{
	"message": "You haven't sent any file string. Please create a formdata/multipart encoded request. Please refer docs.",
	"status": "422",
	"type": "Error",
	"statusCode": "422",
	"code": "FILE_REQUIRED"
}
```

This error message indicates that the user has **not included a file** to be uploaded in their request. The status field in the error response is set to **422**, indicating that the request was well-formed but could not be processed due to invalid parameters. The type field is set to **"Error"** to indicate that an error has occurred.

The statusCode field is also set to **422** to indicate the HTTP status code of the error response. The code field is set to **"FILE\_REQUIRED"** to indicate that the error occurred due to the file parameter being missing in the request. The message field provides a user-friendly explanation of the error and advises the user to consult the documentation and create a properly formatted request.

To troubleshoot this error, the user should check their multipart/form-data request and ensure that the file parameter is included and contains the file to be uploaded. The file parameter should be of type File and not empty.

If the file parameter is present in the request but the error still persists, the user should check the file size and ensure that it does not exceed the **100MB** limit imposed by Signzy's Persist file system. Additionally, the user can check the documentation for additional troubleshooting steps or contact Signzy's support team for further assistance.



### Allowed file formats

Signzy's Persist file system supports a wide range of file formats for uploading files. The supported file formats include:

- **Images:** JPEG, PNG, BMP, GIF
- **Documents:** PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, TXT
- **Audio:** MP3, WAV, FLAC
- **Video:** MP4, AVI, MOV, FLV
- **Other document formats:** HTML, XML, CSV, JSON

Note that while these file formats are supported, certain Signzy APIs may only be compatible with specific file formats. It's important to ensure that the file format being uploaded is compatible with the intended use case before uploading the file.

Additionally, the maximum file size limit for the upload is 100MB, regardless of the file format. If a file exceeds this limit, the API will return an error indicating that the file is too large to be uploaded.

### API Performance :

| Latency      | Defines the time it takes for a request to travel from one place to another and get a response back. | P99 : 0.543s<br />P95: 0.256s<br />P90: 0.191s<br />P75: 0.127s<br />P50: 0.086s |
| ------------ | ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| Success rate | Defines how often the API performs its intended function without any errors or problems.             | 99.9%(Uploading of Files within the file size limit)                             |

**Contact Us for Any Assistance**

If you have any questions or need assistance, please reach out to our customer support team. You can contact us via email at <font color="#2166ae">**help\@signzy.com**</font>. We strive to provide prompt and reliable assistance, ensuring your queries are addressed effectively.

We value your feedback and are committed to making your experience smooth and enjoyable. Our team is dedicated to assisting you with any needs you may have. Thank you for choosing our services. We look forward to helping you!
