API endpoints for document storage using AWS Lambda and S3.
The following API endpoints are references on how you would implement such microservices for your own business requirements. They are NOT to be relied on, for any of your production related needs. We reserve the right to change or shutdown the API anytime.
There is a limit of
6mbon maximum request body size. Revising your OpenAttestation document file size might help if you encounter 413Payload Too Largeerrors.
- Node.js 22.x or higher
- AWS Account
- AWS SAM CLI (for deployment)
Endpoint: https://<your-api-gateway-url>/storage
POST
/storageuploads an encrypted OpenAttestation document/storage/:iduploads an encrypted OpenAttestation document with decrypt key from/storage/queue
// POST data example
{
"document": {
"version": "https://schema.openattestation.com/2.0/schema.json",
"network: {
"chain": "9a09ae01-f16a-466d-ad66-b42e6b07e225:string:ETH",
"chainId": "19ca73ed-e2cf-43ac-b104-3c43d2fc0680:string:5"
},
...rest
}
}
Document storage endpoint requires
network.chainIdfield in OA document.
The uploaded encrypted OpenAttestation documents will not be stored long term. They will be auto deleted after 30 days.
GET
/storage/:idreturns an encrypted OpenAttestation document/storage/queuereturns id and generated decrypt key
- Install dependencies:
npm install- Start local development server with S3:
npm run startThis will start:
- Local S3 server (s3rver) on port 4568
- Lambda function locally
Required environment variables:
API_KEY: API key for authenticationSESSION_SECRET: Secret for express-sessionTT_AWS_BUCKET_NAME: S3 bucket name for document storageTT_STORAGE_AWS_ACCESS_KEY_ID: AWS access key ID for S3TT_STORAGE_AWS_SECRET_ACCESS_KEY: AWS secret access key for S3
For local development, the dummy value in API_KEY should work.
-
Install AWS SAM CLI: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html
-
Build the application:
sam build- Deploy the application:
sam deploy --guidedDuring the guided deployment, you'll be prompted for:
- Stack name
- AWS Region
- API Key (for authentication)
- Session Secret
- After deployment, SAM will output the API Gateway endpoint URL.
Alternatively, you can deploy using AWS Lambda and API Gateway manually:
- Build the TypeScript code
- Package the
netlify/functions/storagedirectory withnode_modules - Create a Lambda function with Node.js 22.x runtime
- Set up API Gateway with proxy integration
- Configure environment variables
- Create an S3 bucket with 30-day lifecycle policy
Run tests:
npm testRun tests with CI (includes local S3 and function server):
npm run test:ci