Pre-Signed URL API

Overview

Upload catalog files to CleverTap managed storage using a secure, scalable mechanism. The process involves generating pre-signed URLs, uploading the file (single or multipart), and completing the upload when required.

This flow is designed for efficient bulk ingestion of catalog data, such as CSV or XML files. You must reference an existing catalog by its ID or name.

Follow these steps to upload a catalog file:

  1. Generate upload URLs using the Get Signed URL API
  2. Upload the file using the returned pre-signed URLs
  3. Complete the upload using the Complete Multipart API

Method

GET

Base URL

https://in1.api.clevertap.com

Region

Refer Region for more details.

Headers

These headers must be included with every API request to ensure authentication and authorization.

HeaderDescriptionRequired
Content-TypeContent type of the request. Must be application/json.Yes
X-Account-IdCleverTap account ID associated with the catalog.Yes
X-CleverTap-TokenAPI token used to authenticate the request.Yes

Generate Upload URLs using the Get Signed URL API

Generate pre-signed upload URLs for your catalog file.

Endpoint

GET /v2/catalogs/signedurl

Upload Type

Choose from the upload methods based on the size of the file you want to upload:

Use this API for files smaller than 100 MB.

Query Parameters

ParameterTypeRequiredDescription
catalogIdlongYesUnique identifier of the catalog where the product file will be uploaded.
fileNamestringYesName of the file to upload. Maximum length is 500 characters.
contentTypestringYesMIME type of the file being uploaded. Use text/csv for FILE_BASED_UPLOAD and CLOUD_BUCKET integrations, and text/xml or application/xml for GOOGLE_MERCHANT integrations.
multiPartbooleanYesIndicates whether the upload will use a multipart upload. Set to true to generate multiple upload URLs, or false for a single file upload.
totalPartsintegerConditionalTotal number of parts for multipart upload. Required when multiPart is set to true. The minimum value is 1, and the maximum value is 10000.
createdBystringYesIdentifier of the user or system requesting the signed URL. Maximum length is 100 characters. The identifier must be an email ID.

Example Request

GET /v2/catalogs/signedurl?catalogId=123&fileName=products.csv&contentType=text/csv&multiPart=false&[email protected]

Example Response

{
  "requestId": "550e8400-e29b-41d4-a716-446655440000",
  "catalogId": 123,
  "fileName": "products.csv",
  "multipartUpload": false,
  "uploadId": null,
  "presignedUrls": [
    "https://s3.amazonaws.com/..."
  ],
  "expiresAt": "2023-11-10T18:30:00Z",
  "instructions": "Upload the file using PUT request to the provided URL",
  "createdAt": "2023-11-10T17:30:00Z"
}

Response Parameters

ParameterTypeDescription
requestIdstringUnique identifier for this signed URL request. Can be used for tracking or support purposes.
catalogIdintegerUnique identifier of the catalog where the file will be uploaded.
fileNamestringName of the file to be uploaded.
multipartUploadbooleanIndicates whether the upload is configured as multipart.
uploadIdstringUpload identifier for multipart uploads. This value is null for single-file uploads.
presignedUrlsarrayList of pre-signed URLs that can be used to upload the file. For multipart uploads, one URL is returned per part.
expiresAtstringDate and time when the signed URL expires. After this time, the URL can no longer be used.
instructionsstringShort message explaining how to use the provided URL to upload the file.
createdAtstringDate and time when the signed URL request was generated.

Upload File using the Returned Pre-signed URLs

Use the returned pre-signed URLs to upload the file directly to storage.

  • Use HTTP PUT requests on each pre-signed URL

  • Do not add authentication headers to these requests

  • For multipart uploads:

    • Upload each part separately
    • Capture the ETag from each upload response
    • Store partNumber and corresponding ETag
📘

File Upload Guidelines

  • Single file uploads are recommended for files under 100 MB
  • Multipart uploads should be used for files larger than 100 MB
  • Each presigned URL expires after 60 minutes by default
  • The generated URLs must be used to upload the file using PUT requests

Complete Multipart Upload using the Complete Multipart API

Complete a multipart upload by submitting the ETags for all uploaded parts. This endpoint finalizes the upload and initiates processing of the file.

Steps for Multipart Upload

Follow these steps to upload a file using the multipart upload process:

  1. Call GET /v2/catalogs/signedurl with multiPart=true and totalParts=N to get N presigned URLs
  2. Upload each file part using a PUT request to the corresponding presigned URL
  3. Collect the ETag from the response header of each part upload
  4. Call POST /v2/catalogs/complete-multipart with the requestId and all part ETags
  5. The system will finalize the upload and begin processing the file

Endpoint

POST /v2/catalogs/complete-multipart

Query Parameters

The following is the list of query parameters:

ParameterTypeRequiredDescription
requestIdstringYesUnique identifier received when generating the signed URLs. Used to complete the multipart upload.
updatedBystringYesEmail address of the user or system completing the upload.
partsarrayYesList of uploaded parts that need to be combined to complete the file upload.
parts.partNumberintegerYesPart number of the uploaded file segment. Must match the part number used during upload.
parts.etagstringYesETag value returned by the storage service after uploading each part. Used to verify and finalize the upload.

Example Request

The following is the sample request:

{
  "requestId": "550e8400-e29b-41d4-a716-446655440001",
  "updatedBy": "[email protected]",
  "parts": [
    {
      "partNumber": 1,
      "etag": "\"33a64df551425fcc55e4d42a148795d9f25f89d4\""
    },
    {
      "partNumber": 2,
      "etag": "\"6821e4a7e3e3d5b4f3e9c8d7b6a5f4e3d2c1b0a9\""
    },
    {
      "partNumber": 3,
      "etag": "\"a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8\""
    },
    {
      "partNumber": 4,
      "etag": "\"b8a7f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9\""
    },
    {
      "partNumber": 5,
      "etag": "\"c9d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0\""
    }
  ]
}

Example Response

The following is the sample response:

{
  "requestId": "550e8400-e29b-41d4-a716-446655440001",
  "catalogId": 123,
  "fileName": "large_products.csv",
  "multipartUpload": true,
  "uploadId": "exampleUploadId123",
  "presignedUrls": [],
  "expiresAt": "2023-11-10T18:30:00Z",
  "instructions": "Upload completed successfully. File will be processed shortly.",
  "createdAt": "2023-11-10T17:30:00Z"
}

Response Parameters

The following parameters are returned when the upload completion request is accepted successfully:

ParameterTypeDescription
requestIdstringUnique identifier for the upload request.
catalogIdintegerUnique identifier of the catalog where the file was uploaded.
fileNamestringName of the uploaded file.
multipartUploadbooleanIndicates whether the upload was completed as a multipart upload.
uploadIdstringIdentifier of the multipart upload process.
presignedUrlsarrayList of presigned URLs. This will typically be empty once the upload is completed.
expiresAtstringDate and time when the upload session was set to expire.
instructionsstringMessage confirming that the upload is complete and that file processing will begin shortly.
createdAtstringDate and time when the upload request was created.
📘

Guidelines for Complete Multipart Upload

  • Parts must be provided in order by partNumber
  • ETags are returned by S3 in the response headers after uploading each part
  • The upload must be completed within the expiry time of the presigned URLs

Error Handling

This section lists the errors returned by both the Get Signed URL and Complete Multipart Upload APIs.

Get Signed URL Errors

The following error codes may be returned by this API:

Error CodeDescription
CATALOG_NOT_FOUNDThe specified catalog does not exist.
CATALOG_INVALID_REQUESTBoth catalogId and catalogName were provided, or neither was provided.
AUTHENTICATION_FAILEDAuthentication failed due to an invalid or missing token.
AUTHORIZATION_FAILEDThe caller does not have permission to access this catalog.
INTERNAL_ERRORAn unexpected server-side error occurred.

Complete Multipart Upload Errors

The following error codes may be returned by this API:

Error CodeDescription
INVALID_REQUESTThe request is invalid or missing required parameters. For example, catalogId, attributeName, filterable, or updatedBy is missing or has an invalid value.
NOT_FOUNDThe specified catalog or attribute does not exist.
UPDATE_NOT_ALLOWEDThe attribute cannot be updated due to a business rule. For example, the catalog is inactive or locked.
UNAUTHORIZEDThe user is not authorized to perform this update.
FORBIDDENThe user does not have permission to modify this catalog.
INTERNAL_ERRORAn unexpected error occurred on the server. Try again later.

CleverTap Ask AI Widget (CSP-Safe)