Contract management API rejects large document attachments with timeout errors

We’re uploading contract PDFs via the REST API and files larger than 25MB consistently fail with 504 Gateway Timeout errors. Standard contracts (5-15MB) upload fine but our legal agreements with extensive annexes fail.

Our current implementation uses single POST request:


POST /crmRestApi/resources/11.13.18.05/contracts/{id}/attachments
Content-Type: multipart/form-data
file: [binary data 35MB]

The API documentation mentions 50MB limit but we can’t get anything over 25MB to work. We’ve tried increasing client timeout to 300 seconds with no improvement. The request times out after exactly 60 seconds regardless of client settings.

Is there a file size configuration in the API gateway or do we need to use chunked transfer encoding for large files? We need to support contracts up to 50MB.

Your timeout issue requires implementing the chunked upload pattern. Here’s the complete solution addressing all aspects:

Multipart Upload Implementation: Use the three-phase chunked upload API instead of single POST. First, initiate an upload session:


POST /crmRestApi/resources/11.13.18.05/contracts/{id}/attachments/initiate
{"fileName":"contract.pdf","fileSize":35000000,"chunkSize":5242880}
Response: {"uploadSessionId":"SESSION-123","totalChunks":7}

This creates a server-side session and calculates chunk count. Use 5MB chunks (5242880 bytes) to stay safely under the 25MB gateway limit.

File Size Limits: The 50MB documentation refers to total file size, not request size. The API gateway enforces a 25MB per-request limit which is why your single upload fails. By chunking to 5MB pieces, you can upload files up to 100MB if needed. Don’t increase the gateway limit - it’s set at 25MB for security and performance reasons. Chunked upload is the intended pattern for large files.

API Gateway Configuration: The timeout is enforced at multiple layers. The API gateway has a 60-second request timeout that cannot be overridden via client settings. This protects backend services from long-running requests. Chunked upload solves this because each individual chunk request completes in 5-10 seconds. The total upload might take several minutes, but no single request exceeds the timeout.

Chunked Transfer Process: After initiating, upload chunks sequentially:


POST /crmRestApi/resources/11.13.18.05/attachments/upload
Headers: Upload-Session-Id: SESSION-123, Chunk-Number: 1
Content-Type: application/octet-stream
Body: [5MB binary chunk]

Repeat for each chunk, incrementing Chunk-Number. The API validates chunk order and size. Finally, finalize the upload:


POST /crmRestApi/resources/11.13.18.05/attachments/finalize
{"uploadSessionId":"SESSION-123"}

This triggers server-side reassembly and creates the final attachment record.

Error Handling and Retry Logic: Implement robust error handling for each phase. If chunk upload fails, retry that specific chunk up to 3 times with exponential backoff. If initiation or finalization fails, restart the entire upload. Store the upload session ID and track completed chunks so you can resume interrupted uploads. The session remains valid for 24 hours.

Performance Optimization: Upload chunks sequentially rather than parallel to avoid overwhelming the API gateway. However, you can optimize by preparing the next chunk while the current one uploads. Use streaming to avoid loading the entire file into memory - read and upload 5MB at a time. For very large contracts, consider background processing with status updates to the user rather than blocking their workflow.

Implementation tip: Create a reusable upload service class that handles chunking logic, retry mechanism, and progress tracking. This makes it easy to use chunked upload throughout your application wherever large file uploads are needed.


This draft is based on general Oracle CX Cloud knowledge. It has not been verified against your specific version and environment. Practitioners: verify the steps and share your experience below.

The 60 second timeout is coming from Oracle’s API gateway, not your client. We had the same issue. You need to use chunked upload for files over 20MB. The API supports multipart upload where you split the file into chunks and upload sequentially, then finalize the attachment.

Check the API gateway configuration in your Oracle CX Cloud instance. There’s a maximum request size setting under Administration > API Management. Default is often 25MB which explains your cutoff. You might be able to increase it to 50MB, but chunked upload is still the better approach for reliability.

Confirmed this resolves our issue — initiating the upload session with 5MB chunks via /crmRestApi/resources/11.13.18.05/contracts/{id}/attachments/initiate eliminated all gateway timeouts for 30MB+ PDF attachments.

Thanks, I found the API gateway settings. The request size limit is indeed 25MB. I can increase it but our admin is hesitant due to security concerns. How does the chunked upload work? Is there specific API documentation for multipart upload to contract attachments?

The chunked upload uses a three-step process: initiate upload to get an upload session ID, upload chunks sequentially with the session ID, then finalize to complete the attachment. Each chunk can be 5-10MB which stays well under gateway limits. The API handles reassembling chunks on the server side.

One thing to watch with chunked uploads - if a chunk fails, you need proper retry logic. We implemented exponential backoff and chunk verification. Also consider uploading chunks in parallel if the API supports it - this can speed up large file uploads significantly. Make sure to handle the case where finalization fails after all chunks upload successfully.

The 60 second timeout is coming from Oracle’s API gateway, not your client.