# Get Pre-signed URL

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

### Request Method

GET

### Request URL

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

### Request Headers

| Parameter             | Data Type | Field Validations                        | Description                                           |
| --------------------- | --------- | ---------------------------------------- | ----------------------------------------------------- |
| x-cleartax-auth-token | String    | NA                                       | <p>Mandatory.</p><p>User auth token.</p>              |
| fileContentType       | String    | <p>Enum:</p><p>XLSX, XLS, CSV</p><p></p> | <p>Mandatory. </p><p>Type of file being uploaded.</p> |

### Request Path Params

| Parameter    | Data Type | Field Validations                         | Description                                                                                |
| ------------ | --------- | ----------------------------------------- | ------------------------------------------------------------------------------------------ |
| templateType | String    | <p>Enum: </p><p>sales,</p><p>purchase</p> | <p>Type of document. sales - Sales document.</p><p>purchase- Purchase document.</p><p></p> |

### Request Query Params

| Paramter | Data Type | Field Validations | Description                                         |
| -------- | --------- | ----------------- | --------------------------------------------------- |
| fileName | String    | MaxLength: 1500   | 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.                                                                                                                                                                                                                                                                               |
| errorCode      | String    | <p>enum:</p><p>AUTHORIZATION\_FAILED, LICENSE\_EXPIRED, API\_QUOTA\_EXCEEDED, PERMISSION\_DENIED, </p><p>INTERNAL\_ERROR</p> | <p>API Error Code. </p><p>AUTHORIZATION\_FAILED- Invalid Auth Token passed, LICENSE\_EXPIRED- Account License has expired, API\_QUOTA\_EXCEEDED- API access quota has exceeded, PERMISSION\_DENIED- Don't have permission. Contact admin for access, INTERNAL\_ERROR- Internal Error in Clear. Contact support. </p><p></p><p>If there is no error, this will be null. </p> |
| errorMessage   | String    | NA                                                                                                                           | <p>API Error Message.</p><p>If there is no error, this will be null.</p>                                                                                                                                                                                                                                                                                                    |

### Sample Response&#x20;

Success - HTTP Status Code - 200

```json
{
    "status": "CREATED",
    "preSignedS3Url": "https://storage.clear.in/v1/ap-south-1/ingestionv2-staging/307a6331-df8b-4bdd-a05a-d18812da0340/GSTSALES/2023/JANUARY/608996448b37488db5ef8a0db5c4f534/OriginalFileName/608996448b37488db5ef8a0db5c4f534__1674056071858.SalesInvoicesAndCreditOrDebitNotes?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEPj%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCmFwLXNvdXRoLTEiSDBGAiEA1Zo2sN7uBeqwBqsQaLQJobMwTxhFFDWpBaCEi2KPFw8CIQCGcHAeDwJxfhbNQeAsWCPOygSiHtBKgEFNPHRgwCogHyr%2FBAhhEAUaDDIxOTM0MTkwNzk4MyIMIYaj1Gcfnc2IEjP2KtwEaK3WhAgAgRQQrEDfGrPE9NPtxKNCcJRz0Q%2FZsP6froj5mWzbDT67MkA867Xzq8Z8oul6zaH2R4qTjlCz0qi2N9ebg7Rqw2jcDlgjdgRa5fVQOGShFPQM%2FB%2Bk0woVvdihwTLbzcZPU%2BNfxviBr40pGVraGG4mpwRTN9ZQfVMJPc2iT3iG3tCA4dRkFoHv8VAlC3mEBVDE%2FbNVSz4flB9T8E8arXhmtcP9HLuJWpFxXwtl%2BFkZM3POtWhJFIjSEUruVWNo6aIq1wuP49PIgwWEF6g5jiG%2Fc484qYflzVUgWWsqjTSOpVJFFhAggLoWNsKgWEyk9n38Gzp%2Fw%2FoNc%2BJKC1b7uXNJGf22jcLa4hNpBKcYVXr7DUhGssXIL5o%2BogVdvfJbrCXApWyb5IO%2BxhgJoVcpUq88gsNZdUKWAoGzINeZaWO8fXowYQrq1JE4k3XVavoBGb6f2sd1A%2F2xBypR96vqvqRiYTazEw6GZCl4jY0ODmfP%2F6RUcs%2Bok6A64juXfm3O1WCAq3j%2FdSeLH6wCcD0VAAN%2B%2FeYd5KT6Era3ThVjS5p9SkAs3vKzQ%2BCPCXbuhYiun7NvlkG0iRLKLT37oAY7Iwh1cWc0dC%2F2EYjmNAHaIm4zOaoZg05UweFrBbESKj1LcCznIcGe539wmWVL2bTTFYnl0%2BWxmfBLdCrgUNKjmQnoTJkdkRVAL93DnWAmvhQDqU3cqRo1dPy4sVfwvegcaAseGvLzloHT4h2TmnEjj2qJvkEdkwrU7RYfa5O3p1znF2swSaTpwF0%2FEVWh%2B3ZkzBnHxGEJmllq9DCHo6CeBjqZARZ%2BWnyAzRtRrX6b5rQ6fwSFBSEhGyT37gCxKc10gbokCdvifp7tylNxmezHMCv5Y1CY39Tng7LWWaLXTMN4a9qDaHNYc3rhWQxjkZcoz4%2BgUVnEwN5n%2FNabHHGg1PdOdIXGXZqzdY1U2O9E%2B76OfrxQ5rF5g2iMg7u%2BqVb6lpNFeBywAY4fgQ0k08LJcomUKUHl1NcDMRlnKw%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230118T153431Z&X-Amz-SignedHeaders=content-type%3Bhost&X-Amz-Expires=35999&X-Amz-Credential=ASIATGEOL5AH7CXDG5RM%2F20230118%2Fap-south-1%2Fs3%2Faws4_request&X-Amz-Signature=77c29e7e2a0b419a4355175ff7eaa598d600285f5015004d270f18780ee24b69",
    "errorCode": null,
    "errorMessage": null
}
```

Error - HTTP Status Code - 401

```json
{
    "status": null,
    "preSignedS3Url": null,
    "errorCode": "AUTHORIZATION_FAILED",
    "errorMessage": "Invalid Auth Token"
}
```

Error - HTTP Status Code - 500

```json
[
    {
        "errorCode": "INTERNAL_ERROR",
        "errorMessage": "Required request header 'fileContentType' for method parameter type FileContentType is not present",
        "errorField": null,
        "errorValues": null,
        "errorResolution": null
    }
]
```

### API Validations

1. Filename cannot be empty.
2. Content type and template type should be valid.

### API Constraints&#x20;

The user should have invoice creation permission.
