---
title: Base64 Persist File Upload API
slug: api-marketplace/base64-persist-file-upload-api
createdAt: 2024-02-12T06:03:54.319Z
---

## Introduction

This API empowers you to seamlessly convert images/pdf in Base64 format into image/pdf files hosted on the cloud, providing you with a Persist URL for convenient access. This URL can be used in the request packet of other Signzy APIs to process ID cards, documents, or any other image data. Thus, it simplifies the conversion process, offering flexibility and reliability.

**Key Features:**

- **Base64 to Image Conversion:**

  &#x20;Easily transform Base64-encoded images into standard image files.

- **Cloud Hosting:**

  &#x20;Your converted images are securely hosted on the cloud, ensuring accessibility and reliability.

- **Temporary URL Generation:**

  &#x20;Instantly receive a URL for your converted image, valid for a specified duration.

- **Customizable Expiry:**

  &#x20;Control the expiration time of the URL by specifying the Time-To-Live (TTL) parameter.

***

## API details

### Endpoint

:::CodeblockTabs
Production Endpoint

```text
POST https://api.signzy.app/api/v3/persist/base64
```
:::

:::CodeblockTabs
UAT Endpoint

```text
POST https://api-preproduction.signzy.app/api/base64
```
:::

***

### Request body parameters

| **Parameter** | **Data Type** | **Description**                                                                                                                                                                                                                        | **Required** |
| ------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
| base64String  | String        | base64 string that needs to be converted                                                                                                                                                                                               | Mandatory    |
| mimetype      | String        | 'image/jpeg', 'image/png', 'image/jpg', 'application/pdf', 'image/tiff'                                                                                                                                                                | Mandatory    |
| ttl           | String        | \*\*Time to live\*\* for your file. The default value is 30 secs in its NA/Invalid.<br />Sample input format: 2 mins, 13 mins, 38 mins, 2 hrs, 12 hrs, 24 hrs, 7 days, 66 days, 1 month, 3 months, 6 months, 1 year, 3 years, infinity | Optional     |



```json
{
    "base64String":"",
    "mimetype":"",
    "ttl":""
}
```

***

### Request Headers

| **Name&#x20;** | **Value**        | **Required** | **Description**                                                                                            |
| -------------- | ---------------- | ------------ | ---------------------------------------------------------------------------------------------------------- |
| Content-type   | application/json | Mandatory    | The type of content that the request body contains.                                                        |
| Authorization  | XXXXXXXXXXXXXXX  | Mandatory    | An authentication token to authorize the request. Reach out to the Signzy support team to get one created. |

***

### Code Samples

:::CodeblockTabs
Curl

```json
curl --location 'https://api.signzy.app/api/v3/persist/base64' \
--header 'Content-Type: application/json' \
--header 'Authorization: xxxxxxxxxxxxxxxxxxxxxxx' \
--data '{"base64String":"","mimetype":"","ttl":""}'
```

Node.js

```nodejs
const axios = require('axios');

const requestData = {
    base64String: "",
    mimetype: "",
    ttl: ""
};

const headers = {
    'Content-Type': 'application/json',
    'Authorization': 'xxxxxxxxxxxxxxxxxxxxxxx'
};

axios.post('https://api.signzy.app/api/v3/persist/base64', requestData, { headers })
    .then(response => {
        console.log(response.data);
    })
    .catch(error => {
        console.error(error);
    });


```

Python

```python
import requests

url = 'https://api.signzy.app/api/v3/persist/base64'
headers = {
    'Content-Type': 'application/json',
    'Authorization': 'xxxxxxxxxxxxxxxxxxxxxxx'
}
data = {
    'base64String': '',
    'mimetype': '',
    'ttl': ''
}

response = requests.post(url, json=data, headers=headers)
print(response.json())

```

GO

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    url := "https://api.signzy.app/api/v3/persist/base64"
    data := map[string]string{
        "base64String": "",
        "mimetype":     "",
        "ttl":          "",
    }
    jsonData, _ := json.Marshal(data)
    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    if err != nil {
        fmt.Println("Error creating request:", err)
        return
    }
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "xxxxxxxxxxxxxxxxxxxxxxx")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error making request:", err)
        return
    }
    defer resp.Body.Close()

    // Print response body
    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result)
}

```
:::

***

### Response body parameters

| **Parameter** | **Data Type** | **Description**                                                     |
| ------------- | ------------- | ------------------------------------------------------------------- |
| file          | Object        | The root object contains the result of the operation.               |
| id            | String        | ID of the file.                                                     |
| fileType      | String        | mimetype                                                            |
| size          | String        | Size of the file. (It should be less than 10 Mb in base64String)    |
| directURL     | String        | Persist link to the image which will be used in other API requests. |

:::CodeblockTabs
200

```json
{
      "file": {
        "id": "...id...",
        "filetype": "...mimeType...",
        "size": size,
        "directURL": "https://persist.signzy.tech/api/base64strings/...id.../download/...name...",
      }
}
```

400

```json
//For No Authorization passed
{
    "message": "No API key found in request"
}

//If base64String is empty

{
    "error": {
        "statusCode": 400,
        "status": "Bad Request",
        "message": "base64 string is required"
    }
}

//If mime type is empty

{
    "error": {
        "statusCode": 400,
        "status": "Bad Request",
        "message": "mime type is required"
    }
}

//if mime type is wrong
{
    "error": {
        "statusCode": 400,
        "status": "400",
        "message": "Invalid MimeType or base64 string"
    }
}
```

413

```json
//If image greater then 10 mb

{
    "statusCode": 413,
    "code": "FST_ERR_CTP_BODY_TOO_LARGE",
    "error": "Payload Too Large",
    "message": "Request body is too large"
}

```
:::

***

**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!
