# Get Pre-signed URL

You can generate pre-signed URL using this API.&#x20;

### Request Method

GET

### Request URL

```
{{BASE_URL}}/ingestion/integration/v1/{templateType}/generatePreSign?fileName={filename}
```

### Request Headers

| Parameter             | Data Type          | Field Validations | Description                |
| --------------------- | ------------------ | ----------------- | -------------------------- |
| x-cleartax-auth-token | String             | NA                | Mandatory. User Auth token |
| tan                   | String             | NA                | Mandatory. TAN of deductor |
| fileContentType       | ENUM(XLS/XLSX/CSV) | File type         | Mandatory.                 |

### Request Path Params

| Parameter    | Data Type | Field Validations | Description                |
| ------------ | --------- | ----------------- | -------------------------- |
| templateType | String    | Enum: tds         | This will always be “tds”. |

### Request Query Params

| Paramter | Data Type | Field Validations | Description                                         |
| -------- | --------- | ----------------- | --------------------------------------------------- |
| fileName | String    | NA                | Name of the file to be uploaded (eg. filename.xlsx) |

### Request Body

There will be no request body for this API.&#x20;

### Response Status Codes

| HTTP Status Code | Description                                                                  |
| ---------------- | ---------------------------------------------------------------------------- |
| 200              | For a successfully processed request (may be a success or validation error). |
| 401              | If the user is not authenticated for the operation.                          |
| 403              | If the user is not authorized for the operation.                             |
| 500              | If there are any unhandled exceptions on Clear side.                         |

### Response Schema

| Paramter       | Data Type | Field Validations                            | Description                                                                                                                                       |
| -------------- | --------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| status         | String    | <p>Enum:</p><p>CREATED,<br>FAILED</p><p></p> | <p>Status of generate pre-signed URL action.</p><p><br>CREATED - Pre-signed URL is generated.</p><p>FAILED - Pre-signed URL is not generated.</p> |
| preSignedS3Url | String    | MaxLength: 2048                              | The pre-signed URL string. This URL is valid only for 10 minutes from the time of generation.                                                     |
| errors         | Array     | NA                                           | <p>Array of Error Objects.</p><p>If there are no errors, this will be an empty array.</p>                                                         |

#### Error Object

| Parameter    | DataType | Field Validation                                           | Description                                                                                                             |
| ------------ | -------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| errorCode    | String   | <p>enum:</p><p>AUTHORIZATION\_FAILED, LICENSE\_EXPIRED</p> | <p>AUTHORIZATION\_FAILED- Invalid Auth Token passed, LICENSE\_EXPIRED- Account License has expired</p><p>Error code</p> |
| errorField   | String   | NA                                                         | Error field. If there is no error field, then this will be null.                                                        |
| errorValues  | String   | NA                                                         | Array of strings. Error values. If there are no error values, then this will be null.                                   |
| errorMessage | String   | NA                                                         | Error message                                                                                                           |

####

### Sample Response&#x20;

Success - HTTP Status Code - 200

```json
{
    "status": "CREATED",
    "preSignedStorageUrl": "https://storage.clear.in/v1/ap-south-1/ingestionv2-staging/307a6331-df8b-4bdd-a05a-d18812da0340/TDS/2023/SEPTEMBER/8afacad8f7284cc583d0b56fbf4c38b0/OriginalFileName/8afacad8f7284cc583d0b56fbf4c38b0__1695374119555.TDS-TEST?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEBkaCmFwLXNvdXRoLTEiRzBFAiEAygdXFleTIJmj6qMGwiw8I%2FpMYNPYSIJvW9dLNuJ%2BXngCIDygAe6yPt0vEEnyOdLBcsVPgJ%2F2rAl7BjyW38uAKmJcKoIFCBIQBRoMMjE5MzQxOTA3OTgzIgw4ilzSw44LEkp5T5gq3wQtCOlueA%2BQ4PpnD4Ojn%2FhIAN%2Fa%2BQWFOI6ow8mtQFv0c0iwA%2BdujGLgz7rODcmnWvMDZmKbSlrRIcqoz3SR%2BtnL%2FCLtWl7f5D2qeNyHUXYj%2FlC9QBrcnRcfh37jy1skVgGEFiH1XewLeDmVbgo66gQhGqmOiZIRycvQRV%2Fo6ogkI1oJNFMkVf3lC4mgTy7Zm57ClgkdNnVPkCoSH1r7XF0ko8MDzJBp7NCkCauyfaU9zloRTzjdGYlGJFOOtTqYuTov8JPz4JORz10Ncn6pQ44jJVUJcvZN21owhAg6aalYGNzBW732Kn9SklEw1wPvuj7vPl8XsvKhYy7bMeaJIT3I6uSd2Bl4jVcD3a0XE070dRVIcPjknzxss5jrzKUEGiWPv%2FyCkYBRkesWFZfeu3F9LA%2B%2BZuQ6AvNEv1y20QNoHUNbCOyxZJbhmMKFXCTQHJbbirecaYqAXBx2ZUOZ2TaQq7H4Z89b2ZyHRRGYGZHLod3yo6iYhxdjR0HwAQgf9K%2FhXhm1I8Hwn2Y401e6DQqMCHi16sqbJFTUEWmXgQLghjm%2F8xCcII0GpajR4a1DJ64q3u2sZo%2B1g%2Fcu8xmmE%2FvdKlqnlI4slX%2BAENeMmDGrNCHnB9CU2MOPbNnIt%2BwPSm3IWCMEpDmXXBbOIkRwLwm0aW6cC3SlmwF%2FXg%2BibLA7W4LGlcmnRmIGDlCteQxpBsVLnNUApMClMTcQyu%2BkAGiCNg7Vf4wBBtTTlIFLjalxogFg3C9fL%2BZG7gf9ecibCVYZq%2BCPbozL1E1W2XDU0HZXAkmVQvsSCyhoETwJ5T10MJy2tagGOpoB7%2BGz%2BiK6MUA9VkKcIdwQ9n4cJJ%2FugbufUI4igaBijZNnFMcTPCCNp4mI87RCHm6a%2FQhmOLFy45erACpUYTBI7ebY7uw51oruVJ6FZXsQVHWJjrfKxFULMc5%2BITNpA072gcLn%2FGO3SGONz3azijP4eG1MtujldWxsvMj39cltXsNboIuDfl4pe9z59tgWPuZFUEcwg17nkBO8Fg%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230922T091519Z&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Expires=36000&X-Amz-Credential=ASIATGEOL5AHVAIH3VM2%2F20230922%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=334d9f97198a81baacb2c2ffe39595e026240c8b0aa55f4223f285b34d3506ef",
    "errors": []
}
```

Error - HTTP Status Code - 401

```json
{
    "status": null,
    "preSignedStorageUrl": null,
    "errors": [
        {
            "errorMessage": "Invalid Auth Token",
            "errorField": null,
            "errorValues": null,
            "errorCode": "AUTHENTICATION_FAILED"
        }
    ]
}
```

### API Validations

1. Filename cannot be empty.
2. Template type should be valid.

### API Constraints&#x20;

The user should have invoice creation permission.
