Runtime API Reference
The Runtime API provides the core functionality for deploying TERE applications and executing functions within Trusted Execution Environments. This API allows you to run your code in a secure environment with hardware-backed confidentiality and integrity guarantees.
Getting Started
To use the Runtime API, first install the TERE SDK:
Initialize the client with your API key:
Developer Workflow
Here's the typical developer workflow for working with the Runtime API:
- 1
Develop Your Application
Write your application in JavaScript or TypeScript using the TERE SDK.
typescript - 2
Package Your Application
Use the TERE SDK to package your application for deployment to a TEE.
typescriptOr using the CLI:
bash - 3
Deploy to TEE
Deploy your packaged application to a Trusted Execution Environment.
typescriptOr using the CLI:
bash - 4
Execute Functions
Execute functions in your deployed application securely.
typescriptOr using the CLI:
bash - 5
Verify Attestation
Verify that the execution took place in a genuine TEE.
typescript
Core API Methods
Deploys a TERE script to a Trusted Execution Environment.
Parameters
options
: DeployOptionsRequiredDeployment options including the script name and binary
Returns
Response containing the script ID and instance information
Examples
Basic deployment
With custom configuration
Executes a function in a deployed TERE script.
Parameters
options
: ExecuteOptionsRequiredExecution options including script ID, function name, and arguments
Returns
Response containing the execution result and attestation
Examples
Execute a function
Asynchronous execution
Retrieves the status of an asynchronous execution job.
Parameters
jobId
: stringRequiredThe ID of the job to check
Returns
Response containing the job status and result if completed
Examples
Check job status
Lists all deployed TERE scripts.
Returns
Array of script information objects
Examples
List all scripts
Gets detailed information about a specific deployed script.
Parameters
scriptId
: stringRequiredID of the script to retrieve
Returns
Detailed information about the script
Examples
Get script details
Instance Management
These methods help you manage the lifecycle of your deployed TEE instances:
Starts a stopped TEE instance.
Parameters
scriptId
: stringRequiredID of the script to start
Returns
No return value on success
Examples
Start a stopped instance
Stops a running TEE instance.
Parameters
scriptId
: stringRequiredID of the script to stop
Returns
No return value on success
Examples
Stop a running instance
Permanently deletes a deployed script and its associated TEE instance.
Parameters
scriptId
: stringRequiredID of the script to delete
options
: DeleteOptionsOptions for deletion, such as whether to preserve state data
Returns
No return value on success
Examples
Delete a script
Delete with options
Using the CLI
The TERE CLI provides command-line access to the same Runtime API functionality:
Best Practices
- Use Asynchronous Execution for Long Tasks
For operations that may take longer than a few seconds, use asynchronous execution (set
waitForResult: false
) and poll for results usinggetJobStatus
. - Always Verify Attestation
When receiving results from a TEE execution, always verify the attestation to ensure it was processed in a genuine TEE with the expected security properties.
javascript - Optimize Script Size
Keep your application code as small as possible to improve loading time and reduce memory usage. Remove unnecessary dependencies and comments.
- Manage TEE Instances Efficiently
Stop TEE instances when not in use to save costs, and start them again when needed. Use appropriate resource limits for your workload.
Error Handling
The TERE SDK provides detailed error information:
SDK Interfaces
Here are the TypeScript interfaces for the key objects in the TERE SDK: