API Reference

Complete API documentation for integrating Dafthunk workflows into your applications, with examples in multiple programming languages.

Base URL

All API requests should be made to:

https://api.dafthunk.com

Authentication

API requests are authenticated using API keys. You can generate and manage your API keys from the Dafthunk dashboard under Settings โ†’ API Keys. Once you create a new API key, give it a descriptive name and ensure you copy and store it securely, as it won't be shown again.

To authenticate your requests, include the API key in the Authorization header, using the Bearer scheme:

Authorization: Bearer YOUR_API_KEY

HTTP Trigger Execution

Execute Workflow

Trigger a workflow that has an HTTP trigger node. The workflow id is the handle, so the URL is derived directly from the workflow. The workflow must be enabled. A http-request trigger runs synchronously; a http-webhook trigger runs asynchronously and returns an execution id immediately.

Route: GET or POST /http/{workflowId}

Request Body

The full request โ€” method, headers, query parameters, and body โ€” is passed to the workflow and exposed through the HTTP Request (or HTTP Webhook) trigger node's outputs. The body can be any content type; the example below sends JSON.

{
  "parameter1": "value1",
  "parameter2": "value2",
  "file_url": "https://example.com/file.pdf"
}

Response

{
  "id": "exec_1234567890",
  "workflowId": "wf_123",
  "status": "submitted",
  "nodeExecutions": [
    {
      "nodeId": "node_1",
      "status": "executing"
    }
  ]
}

Code Examples

curl -X POST "https://api.dafthunk.com/http/my-workflow-id" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "key": "value" }'

Execution Status

Get Execution Status

Check execution status and retrieve results from completed workflows.

Route: GET /{orgId}/executions/{executionId}

Response

{
  "execution": {
    "id": "exec_1234567890",
    "workflowId": "wf_123",
    "workflowName": "My Workflow",
    "status": "completed",
    "nodeExecutions": [
      {
        "nodeId": "node_1",
        "status": "completed",
        "outputs": {
          "result": "Generated result data"
        }
      }
    ],
    "startedAt": "2024-01-15T10:30:00.000Z",
    "endedAt": "2024-01-15T10:31:23.000Z"
  }
}

Code Examples

curl -X GET "https://api.dafthunk.com/your-org/executions/YOUR_EXECUTION_ID" \
  -H "Authorization: Bearer YOUR_API_KEY"

Status Values

StatusDescription
idleExecution not yet started
submittedExecution has been submitted
executingCurrently executing
completedSuccessfully finished
errorExecution failed
cancelledExecution was cancelled
pausedExecution is paused

Object Retrieval

Get Object

Retrieve binary or structured data objects generated by workflow executions.

Route: GET /{orgId}/objects?id={objectId}&mimeType={mimeType}

Query Parameters

ParameterTypeDescription
idstringThe unique identifier of the object
mimeTypestringThe MIME type of the object (e.g., image/png, application/json)

Code Examples

curl -X GET "https://api.dafthunk.com/your-org/objects?id=YOUR_OBJECT_ID&mimeType=YOUR_OBJECT_MIME_TYPE" \
  -H "Authorization: Bearer YOUR_API_KEY"

Queue Publishing

Publish Message

Publish a message to a queue. Workflows with queue triggers connected to this queue will be executed with the message payload.

Route: POST /queues/{queueId}/publish

Request Body

{
  "payload": {
    "event": "order_created",
    "data": { "id": 123 }
  }
}

Response

{
  "success": true,
  "queueId": "queue_123",
  "timestamp": 1705312200000
}

Code Examples

curl -X POST "https://api.dafthunk.com/queues/my-queue/publish" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "payload": { "event": "order_created", "data": { "id": 123 } } }'

Database Query

Execute Query

Execute a SQL query against a database. Databases are created in the Dafthunk dashboard under Databases.

Route: POST /{orgId}/databases/{databaseId}/query

Request Body

FieldTypeRequiredDescription
sqlstringYesSQL query to execute
paramsarrayNoQuery parameters for prepared statements
{
  "sql": "SELECT * FROM users WHERE active = ?",
  "params": [true]
}

Code Examples

curl -X POST "https://api.dafthunk.com/your-org/databases/my-database/query" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "sql": "SELECT * FROM users WHERE active = ?", "params": [true] }'

Error Handling

The API uses conventional HTTP status codes:

CodeDescription
200Success
201Created (returned by execute and publish endpoints)
400Bad Request (invalid parameters)
401Unauthorized (invalid API key)
404Not Found (resource not found)
429Too Many Requests (rate limit exceeded)
500Internal Server Error