Truebit Verify
  • Getting Started
    • 📄What is Truebit Verify?
      • How does Truebit work?
      • System Actors
    • ⏱️Get Started
    • ⚙️Architecture
      • Truebit Verify Hub
      • Truebit Verify Nodes
      • What is a transcript?
        • Transcript example
        • API Transcript example
    • Key Concepts
      • What is verification?
      • Determinism
      • WebAssembly
      • Task instrumentation
  • Developing Truebit Tasks
    • Introduction
    • Writing Function Tasks
      • Supported languages
        • Javascript
        • Python
        • Rust
    • Writing API Tasks
    • Task examples
      • Function Task examples
        • Fibonacci
        • Reverse Alphabet
        • Encrypt sha256 using bun.js
        • Encrypt sha256 using Deno
        • ECDSA signature verification
        • NumPy example
      • API Task examples
        • Pet Store CRUD
        • API-Auth examples
    • Namespace management
    • Task Authorization
    • Truebit CLI
      • secret.json
  • Executing Truebit tasks
    • Introduction
    • Task Execution API
      • Execute Function Tasks
      • Execute API Tasks
      • Get Task Status
    • Transcript API
      • Get Transcript
      • Get Invoice
  • Community
    • Truebit Unchained Protocol
    • Support
Powered by GitBook
On this page

Was this helpful?

  1. Executing Truebit tasks
  2. Task Execution API

Execute API Tasks

PreviousExecute Function TasksNextGet Task Status

Last updated 6 days ago

Was this helpful?

Overview

Execute an API Task and retrieve the result.

You can configure the endpoint for either a synchronous or asynchronous response. In sync mode, if the result is ready within 60 seconds, it will be returned immediately. If not, you'll receive an executionId, which you can use to check the result later by calling the status endpoint.

When executing an , your task input will need to specify the API endpoint path, HTTP method type, and API input parameters. These parameters must match the schema defined in the API Task manifest.

You have two options for using this endpoint: call it with the taskId or use a friendly name along with the namespace and task name.

Authorization

API KEY

The authorization methods are only available with Friendly name execution.

To get authorized using an API Key, include the registered API Key in the call's header. This allows the dispatcher service to validate access and identify who will cover the cost of the task execution (the address associated with the API Key).

Example

X-API-KEY: be0dc6ba-9a60-4777-b5b7-60ed2397e3ed
API Task
  • Overview
  • POSTExecute a API task by Id
  • Authorization
  • API KEY

Execute a API task by Id

post

Execute a API task using the provided task ID. Supports both synchronous and asynchronous execution.

Header parameters
x-api-keystringRequired

API key for authentication.

Body
namespacestringRequired

The namespace of the task.

taskNamestringRequired

The name of the task to be executed.

labelstringOptional

Label of the task.

versioninteger · uint32Optional

Version number of the task.

asyncbooleanRequired

If true, the endpoint will retrieve the executionId; otherwise, it will try to return the execution result only if it completes within 60 seconds.

inputobjectRequired

Input data required for task execution.

executionTimeoutinteger · uint32Required

Timeout for task execution in seconds.

Responses
200
Successful execution
application/json
Responseone of
or
400
Bad request, invalid input.
application/json
500
Internal server error.
application/json
post
POST /task/api/execute-by-name HTTP/1.1
Host: run.truebit.network
x-api-key: text
Content-Type: application/json
Accept: */*
Content-Length: 95

{
  "namespace": "namespace",
  "taskName": "taskapi",
  "input": {},
  "executionTimeout": 10000,
  "async": true
}
{
  "executionId": "eced5793-8634-4489-a589-2f1978367496",
  "clearTextSolution": {
    "output": {},
    "status": "succeed",
    "senderAddress": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
  },
  "status": "Success",
  "totalTransferredBytes": {
    "request": 194,
    "response": 438
  }
}