Skip to main content

Go SDK

The official TurboDocx Deliverable SDK for Go applications. Generate documents from templates with dynamic variable injection, download source files and PDFs, and manage deliverables programmatically with idiomatic Go patterns, context support, and comprehensive error handling. Available as github.com/TurboDocx/SDK/packages/go-sdk.

Installation

go get github.com/TurboDocx/SDK/packages/go-sdk

Requirements

  • Go 1.21+

Configuration

package main

import (
"os"

sdk "github.com/TurboDocx/SDK/packages/go-sdk"
)

func main() {
// Option 1: Standalone deliverable client (no SenderEmail needed)
deliverable, err := sdk.NewDeliverableClientOnly(sdk.ClientConfig{
APIKey: os.Getenv("TURBODOCX_API_KEY"),
OrgID: os.Getenv("TURBODOCX_ORG_ID"),
})
if err != nil {
log.Fatal(err)
}

// Option 2: Full client (includes TurboSign + Deliverable)
client, err := sdk.NewClientWithConfig(sdk.ClientConfig{
APIKey: os.Getenv("TURBODOCX_API_KEY"),
OrgID: os.Getenv("TURBODOCX_ORG_ID"),
SenderEmail: "sender@example.com",
BaseURL: "https://api.turbodocx.com", // Optional custom base URL
})
if err != nil {
log.Fatal(err)
}
deliverable = client.Deliverable
}
No SenderEmail Required

Use NewDeliverableClientOnly() when you only need document generation — it skips the SenderEmail validation required by TurboSign.

Environment Variables

export TURBODOCX_API_KEY=your_api_key_here
export TURBODOCX_ORG_ID=your_org_id_here

Quick Start

Generate a document from a template

package main

import (
"context"
"encoding/json"
"fmt"
"log"
"os"

sdk "github.com/TurboDocx/SDK/packages/go-sdk"
)

func main() {
deliverable, err := sdk.NewDeliverableClientOnly(sdk.ClientConfig{
APIKey: os.Getenv("TURBODOCX_API_KEY"),
OrgID: os.Getenv("TURBODOCX_ORG_ID"),
})
if err != nil {
log.Fatal(err)
}

ctx := context.Background()

result, err := deliverable.GenerateDeliverable(ctx, &sdk.CreateDeliverableRequest{
Name: "Q1 Report",
TemplateID: "your-template-id",
Variables: []sdk.DeliverableVariable{
{Placeholder: "{CompanyName}", Text: "Acme Corporation", MimeType: "text"},
{Placeholder: "{Date}", Text: "2026-03-12", MimeType: "text"},
},
Description: "Quarterly business report",
Tags: []string{"reports", "quarterly"},
})
if err != nil {
log.Fatal(err)
}

b, _ := json.MarshalIndent(result, "", " "); fmt.Println("Result:", string(b))
}

Download and manage deliverables

package main

import (
"context"
"encoding/json"
"fmt"
"log"
"os"

sdk "github.com/TurboDocx/SDK/packages/go-sdk"
)

func main() {
deliverable, err := sdk.NewDeliverableClientOnly(sdk.ClientConfig{
APIKey: os.Getenv("TURBODOCX_API_KEY"),
OrgID: os.Getenv("TURBODOCX_ORG_ID"),
})
if err != nil {
log.Fatal(err)
}

ctx := context.Background()

// List deliverables with pagination
list, err := deliverable.ListDeliverables(ctx, &sdk.ListDeliverablesOptions{
Limit: 10,
ShowTags: true,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total: %d\n", list.TotalRecords)

// Get deliverable details
details, err := deliverable.GetDeliverableDetails(ctx, "deliverable-uuid", &sdk.GetDeliverableOptions{
ShowTags: true,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Name: %s\n", details.Name)

// Download source file (DOCX/PPTX)
sourceData, err := deliverable.DownloadSourceFile(ctx, "deliverable-uuid")
if err != nil {
log.Fatal(err)
}
os.WriteFile("report.docx", sourceData, 0644)

// Download PDF
pdfData, err := deliverable.DownloadPDF(ctx, "deliverable-uuid")
if err != nil {
log.Fatal(err)
}
os.WriteFile("report.pdf", pdfData, 0644)

// Update deliverable
updateResult, err := deliverable.UpdateDeliverableInfo(ctx, "deliverable-uuid", &sdk.UpdateDeliverableRequest{
Name: "Q1 Report - Final",
Description: "Final quarterly business report",
Tags: &[]string{"reports", "final"},
})
if err != nil {
log.Fatal(err)
}
b, _ := json.MarshalIndent(updateResult, "", " "); fmt.Println("Result:", string(b))

// Delete deliverable
deleteResult, err := deliverable.DeleteDeliverable(ctx, "deliverable-uuid")
if err != nil {
log.Fatal(err)
}
b, _ = json.MarshalIndent(deleteResult, "", " "); fmt.Println("Result:", string(b))
}

Variable Types

The Deliverable module supports four variable types for template injection:

1. Text Variables

Inject plain text values into template placeholders:

variables := []sdk.DeliverableVariable{
{Placeholder: "{CompanyName}", Text: "Acme Corporation", MimeType: "text"},
{Placeholder: "{Date}", Text: "2026-03-12", MimeType: "text"},
}

2. HTML Variables

Inject rich HTML content with formatting:

variables := []sdk.DeliverableVariable{
{
Placeholder: "{Summary}",
Text: "<p>This is a <strong>formatted</strong> summary with <em>rich text</em>.</p>",
MimeType: "html",
},
}

3. Image Variables

Inject images by providing a URL or base64-encoded content:

variables := []sdk.DeliverableVariable{
{
Placeholder: "{Logo}",
Text: "https://example.com/logo.png",
MimeType: "image",
},
}

4. Markdown Variables

Inject markdown content that gets converted to formatted text:

variables := []sdk.DeliverableVariable{
{
Placeholder: "{Notes}",
Text: "## Key Points\n- First item\n- Second item\n\n**Important:** Review before submission.",
MimeType: "markdown",
},
}
Variable Stack

For repeating content (e.g., table rows), use VariableStack instead of Text to provide multiple values for the same placeholder. See the Types section for details.


API Reference

Configure

Create a new TurboDocx Deliverable client.

// Standalone deliverable client (no SenderEmail needed)
deliverable, err := sdk.NewDeliverableClientOnly(sdk.ClientConfig{
APIKey: "your-api-key",
OrgID: "your-org-id",
})

// Full client (includes TurboSign + Deliverable)
client, err := sdk.NewClientWithConfig(sdk.ClientConfig{
APIKey: "your-api-key",
OrgID: "your-org-id",
SenderEmail: "sender@example.com",
BaseURL: "https://api.turbodocx.com", // Optional
})
deliverable := client.Deliverable
API Credentials Required

Both APIKey and OrgID parameters are required for all API requests. To get your credentials, follow the Get Your Credentials steps from the SDKs main page.

Generate deliverable

Generate a new document from a template with variable substitution.

result, err := deliverable.GenerateDeliverable(ctx, &sdk.CreateDeliverableRequest{
Name: "Q1 Report",
TemplateID: "your-template-id",
Variables: []sdk.DeliverableVariable{
{Placeholder: "{CompanyName}", Text: "Acme Corp", MimeType: "text"},
{Placeholder: "{Date}", Text: "2026-03-12", MimeType: "text"},
},
Description: "Quarterly business report",
Tags: []string{"reports", "quarterly"},
})
if err != nil {
log.Fatal(err)
}

b, _ := json.MarshalIndent(result, "", " "); fmt.Println("Result:", string(b))

List deliverables

List deliverables with pagination, search, and filtering.

list, err := deliverable.ListDeliverables(ctx, &sdk.ListDeliverablesOptions{
Limit: 10,
Offset: 0,
Query: "report",
ShowTags: true,
})
if err != nil {
log.Fatal(err)
}

b, _ := json.MarshalIndent(list, "", " "); fmt.Println("Result:", string(b))

Get deliverable details

Retrieve the full details of a single deliverable, including variables and fonts.

details, err := deliverable.GetDeliverableDetails(ctx, "deliverable-uuid", &sdk.GetDeliverableOptions{
ShowTags: true,
})
if err != nil {
log.Fatal(err)
}

b, _ := json.MarshalIndent(details, "", " "); fmt.Println("Result:", string(b))

Update deliverable info

Update a deliverable's name, description, or tags.

result, err := deliverable.UpdateDeliverableInfo(ctx, "deliverable-uuid", &sdk.UpdateDeliverableRequest{
Name: "Q1 Report - Final",
Description: "Final quarterly business report",
Tags: &[]string{"reports", "final"},
})
if err != nil {
log.Fatal(err)
}

b, _ := json.MarshalIndent(result, "", " "); fmt.Println("Result:", string(b))

Delete deliverable

Soft-delete a deliverable.

result, err := deliverable.DeleteDeliverable(ctx, "deliverable-uuid")
if err != nil {
log.Fatal(err)
}

b, _ := json.MarshalIndent(result, "", " "); fmt.Println("Result:", string(b))

Download source file

Download the original source file (DOCX or PPTX).

sourceData, err := deliverable.DownloadSourceFile(ctx, "deliverable-uuid")
if err != nil {
log.Fatal(err)
}

// Save to file
err = os.WriteFile("report.docx", sourceData, 0644)
if err != nil {
log.Fatal(err)
}

Download PDF

Download the PDF version of a deliverable.

pdfData, err := deliverable.DownloadPDF(ctx, "deliverable-uuid")
if err != nil {
log.Fatal(err)
}

// Save to file
err = os.WriteFile("report.pdf", pdfData, 0644)
if err != nil {
log.Fatal(err)
}

Error Handling

The SDK provides typed errors for different error scenarios:

Error Types

Error TypeStatus CodeDescription
TurboDocxErrorvariesBase error type for all API errors
AuthenticationError401Invalid or missing API key
ValidationError400Invalid request parameters
NotFoundError404Deliverable or template not found
RateLimitError429Too many requests
NetworkError-Network connectivity issues

Handling Errors

import (
"errors"

sdk "github.com/TurboDocx/SDK/packages/go-sdk"
)

result, err := deliverable.GenerateDeliverable(ctx, request)
if err != nil {
// Check for specific error types
var authErr *sdk.AuthenticationError
var validationErr *sdk.ValidationError
var notFoundErr *sdk.NotFoundError
var rateLimitErr *sdk.RateLimitError
var networkErr *sdk.NetworkError

switch {
case errors.As(err, &authErr):
log.Printf("Authentication failed: %s", authErr.Message)
case errors.As(err, &validationErr):
log.Printf("Validation error: %s", validationErr.Message)
case errors.As(err, &notFoundErr):
log.Printf("Not found: %s", notFoundErr.Message)
case errors.As(err, &rateLimitErr):
log.Printf("Rate limited: %s", rateLimitErr.Message)
case errors.As(err, &networkErr):
log.Printf("Network error: %s", networkErr.Message)
default:
// Base TurboDocxError or unexpected error
var turboErr *sdk.TurboDocxError
if errors.As(err, &turboErr) {
log.Printf("API error [%d]: %s", turboErr.StatusCode, turboErr.Message)
} else {
log.Fatal(err)
}
}
}

Error Properties

PropertyTypeDescription
MessagestringHuman-readable error message
StatusCodeintHTTP status code
CodestringError code (if available)

Types

DeliverableVariable

Variable configuration for template injection:

PropertyTypeRequiredDescription
PlaceholderstringYesTemplate placeholder (e.g., {CompanyName})
TextstringNo*Value to inject
MimeTypestringYes"text", "html", "image", or "markdown"
IsDisabledboolNoSkip this variable during generation
Subvariables[]DeliverableVariableNoNested sub-variables for HTML content
VariableStackinterface{}NoMultiple instances for repeating content
AIPromptstringNoAI prompt for content generation (max 16,000 chars)

*Required unless VariableStack is provided or IsDisabled is true.

CreateDeliverableRequest

Request configuration for GenerateDeliverable:

PropertyTypeRequiredDescription
NamestringYesDeliverable name (3-255 characters)
TemplateIDstringYesTemplate ID to generate from
Variables[]DeliverableVariableYesVariables for template substitution
DescriptionstringNoDescription (up to 65,535 characters)
Tags[]stringNoTag strings to associate

UpdateDeliverableRequest

Request configuration for UpdateDeliverableInfo:

PropertyTypeRequiredDescription
NamestringNoUpdated name (3-255 characters)
DescriptionstringNoUpdated description
Tags*[]stringNoReplace all tags (nil = no change, &[]string{} = remove all)

ListDeliverablesOptions

Options for ListDeliverables:

PropertyTypeRequiredDescription
LimitintNoResults per page (1-100, default 6)
OffsetintNoResults to skip (default 0)
QuerystringNoSearch query to filter by name
ShowTagsboolNoInclude tags in the response

DeliverableRecord

The deliverable object returned by ListDeliverables:

PropertyTypeDescription
IDstringUnique deliverable ID (UUID)
NamestringDeliverable name
DescriptionstringDescription text
TemplateIDstringSource template ID
CreatedBystringUser ID of the creator
EmailstringCreator's email address
FileSizeint64File size in bytes
FileTypestringMIME type of the generated file
DefaultFontstringDefault font used
Fonts[]FontFonts used in the document
IsActiveboolWhether the deliverable is active
CreatedOnstringISO 8601 creation timestamp
UpdatedOnstringISO 8601 last update timestamp
Tags[]TagAssociated tags (when ShowTags=true)

DeliverableDetailRecord

The deliverable object returned by GetDeliverableDetails. Includes all fields from DeliverableRecord except FileSize, plus:

PropertyTypeDescription
TemplateNamestringSource template name
TemplateNotDeleted*boolWhether the source template still exists
Variables[]DeliverableVariableParsed variable objects with values

Tag

Tag object included when ShowTags is enabled:

PropertyTypeDescription
IDstringTag unique identifier (UUID)
LabelstringTag display name
IsActiveboolWhether the tag is active
UpdatedOnstringISO 8601 last update timestamp
CreatedOnstringISO 8601 creation timestamp
CreatedBystringUser ID of the tag creator
OrgIDstringOrganization ID

Additional Documentation

For detailed information about advanced configuration and API concepts, see:

Core API References


Resources