TERE API Reference

Updated May 17, 20257 min read

The TERE API lets you work with Trusted Execution Environments securely and easily through our SDK and CLI tools. This reference covers the key functionality you'll use to deploy, manage, and execute code in secure TEEs.

Getting Started

Quick Setup

The fastest way to get started with TERE is through our SDK and CLI:

SDK Installation

bash
1npm install @praecise/tere

CLI Installation

bash
1npm install -g @tere/cli

Authentication

Authenticate with your API key:

javascript
1import { TereClient } from '@praecise/tere';
2
3// Initialize with your API key
4const client = new TereClient({
5 endpoint: 'https://api.tere.praecise.com',
6 apiKey: 'your-api-key'
7});

Or using the CLI:

bash
1# Login with your API key
2tere login --api-key your-api-key

Complete Workflow Example

Here's a complete example of using TERE to deploy and execute a secure application:

javascript
1import { TereClient, TerePackager } from '@praecise/tere';
2import fs from 'fs';
3
4// Initialize client
5const client = new TereClient({
6 endpoint: 'https://api.tere.praecise.com',
7 apiKey: 'your-api-key'
8});
9
10async function deployAndRunSecureApp() {
11 // 1. Read your application code
12 const appCode = fs.readFileSync('./secure-processor.js', 'utf-8');
13
14 // 2. Package as a TERE script
15 const tereScript = TerePackager.createScript({
16 code: appCode,
17 name: 'Secure Processor',
18 version: '1.0.0',
19 description: 'Processes sensitive data securely'
20 });
21
22 // 3. Deploy to a Trusted Execution Environment
23 const deployment = await client.deploy({
24 name: 'secure-processor',
25 tereBinary: tereScript,
26 description: 'Secure data processing application',
27 config: {
28 teeType: 'confidential_vm',
29 securitySettings: {
30 confidentialComputeType: 'SEV_SNP'
31 }
32 }
33 });
34
35 console.log('Deployed to TEE:', deployment.scriptId);
36
37 // 4. Execute a function in the secure environment
38 const result = await client.execute({
39 scriptId: deployment.scriptId,
40 function: 'processData',
41 arguments: ['sensitive data to process']
42 });
43
44 // 5. Verify the result came from a genuine TEE
45 const verification = await client.verifyAttestation({
46 attestation: result.attestation
47 });
48
49 if (verification.valid) {
50 console.log('Secure result:', result.result);
51 } else {
52 console.error('Could not verify TEE attestation');
53 }
54}
55
56deployAndRunSecureApp();

The same workflow using the CLI:

bash
1# Package application as TERE
2tere package --input ./secure-processor.js --output app.tere
3
4# Deploy to a TEE
5tere deploy --name "secure-processor" --file app.tere
6# > Deployed script ID: script_abc123
7
8# Execute a function
9tere execute script_abc123 processData "sensitive data"
10# > Result: Processed data
11# > Attestation: Verified

API Components

The TERE API is divided into several key components, all accessible through the SDK and CLI:

Common API Methods

These are the most commonly used SDK methods for working with TERE:

MethodDescription
client.deploy()Deploys a TERE script to a Trusted Execution Environment
client.execute()Executes a function in a deployed TERE script
client.verifyAttestation()Verifies an attestation to ensure it came from a genuine TEE
client.listScripts()Lists all deployed TERE scripts
client.getScript()Gets detailed information about a specific deployed script
client.getJobStatus()Retrieves the status of an asynchronous execution job
TerePackager.createScript()Creates a TERE script from code and metadata

Error Handling

The TERE SDK provides structured error handling:

javascript
1try {
2 const result = await client.execute({
3 scriptId: 'script_abc123',
4 function: 'processData',
5 arguments: ['data']
6 });
7} catch (error) {
8 if (error instanceof TereError) {
9 console.error('TERE API error:', error.message);
10 console.error('Error code:', error.code);
11 console.error('Request ID:', error.requestId);
12 } else {
13 console.error('Unexpected error:', error);
14 }
15}

Common TERE error codes include:

Error CodeDescription
auth_errorAuthentication failed or token expired
invalid_scriptInvalid TERE script format
script_not_foundThe specified script ID was not found
function_not_foundThe specified function was not found in the script
execution_errorAn error occurred during function execution
attestation_errorAttestation verification failed

SDK vs CLI

SDK

Programmatic integration for applications and services. Use the SDK when you need to:

  • Integrate TERE into your application
  • Automate TERE operations
  • Build custom workflows
  • Implement complex logic around TEE operations

CLI

Command-line tool for development and operations. Use the CLI when you need to:

  • Quickly test and debug TERE operations
  • Use in CI/CD pipelines
  • Run one-off operations
  • Explore TERE features interactively

Next Steps