> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formabledocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Go

> Install and use formable-go, the official Go SDK for the Formable API.

[`formable-go`](https://pkg.go.dev/github.com/FormableDocs/formable-go) is the official Go SDK for the Formable API (v1). It covers templates, signature requests, redlining, and billing.

* Typed request and response models
* Uses the Go standard library (`net/http`)
* Context on every method
* Zero runtime dependencies (Go 1.22+)

Source code is on [GitHub](https://github.com/FormableDocs/formable-go).

## Installation

```bash theme={null}
go get github.com/FormableDocs/formable-go
```

## Initialize the client

Pass your API key from [Settings](https://app.formabledocs.com/settings). It's sent as a bearer token on every request.

```go theme={null}
import (
    "context"
    "log"
    "os"

    "github.com/FormableDocs/formable-go"
)

ctx := context.Background()
client, err := formable.NewClient(os.Getenv("FORMABLE_API_KEY"))
if err != nil {
    log.Fatal(err)
}
```

## Templates

Upload a document to create a reusable template, then mint edit URLs to place fields in the embedded editor. See the [embedded templates walkthrough](/walkthroughs/embedded-templates).

```go theme={null}
created, err := client.Templates.CreateFromFile(
    ctx,
    "nda.docx",
    []formable.TemplateSignerRole{
        {Name: "Client", Order: 0},
        {Name: "Witness", Order: 1},
    },
)

templateID := created.TemplateID

// Mint a fresh edit URL later (expires after 1 day)
edit, err := client.Templates.CreateEditURL(ctx, templateID)
```

## Signature requests

Send a template for signing by email, or embed the signing experience in your product. See the [embedded signing walkthrough](/walkthroughs/embedded-signing).

```go theme={null}
// Formable emails each signer a signing link
request, err := client.SignatureRequests.Create(ctx, &formable.CreateSignatureRequest{
    TemplateID: templateID,
    Signers: []formable.Signer{
        {Email: "jane@example.com", Name: "Jane Doe", Role: "Client"},
        {Email: "bob@example.com", Name: "Bob Smith", Role: "Witness"},
    },
})

// Embedded flow: mint signing URLs to embed in an iframe yourself
embedded, err := client.SignatureRequests.CreateEmbedded(ctx, &formable.CreateSignatureRequest{
    TemplateID: templateID,
    Signers:    []formable.Signer{{Email: "jane@example.com", Name: "Jane Doe", Role: "Client"}},
    TestMode:   true,
})

signer := embedded.Signers[0]
signing, err := client.SignatureRequests.CreateSigningURL(ctx, signer.RecipientSignatureID)

// Track progress
current, err := client.SignatureRequests.Get(ctx, embedded.SignatureRequestID)
all, err := client.SignatureRequests.List(ctx, &formable.ListOptions{
    UpdatedSince: time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC),
})
events, err := client.SignatureRequests.GetEvents(ctx, embedded.SignatureRequestID)

// Download the signed document once completed
envelope, err := client.SignatureRequests.GetSignedEnvelope(ctx, embedded.SignatureRequestID)
```

<Note>
  `GetSignedEnvelope` returns a `409` until the document is complete. Wait for the [`document_completed`](/webhooks/events#document_completed) webhook, or poll `Get` until `Status` is `Completed`.
</Note>

## Redline requests

Run turn-based contract negotiation before signing. See the [redlining walkthrough](/walkthroughs/redlining).

```go theme={null}
created, err := client.RedlineRequests.Create(ctx, &formable.CreateRedlineRequest{
    TemplateID: templateID,
    Members: []formable.RedlineMember{
        {Email: "us@example.com", DisplayName: "John Doe", Role: formable.RedlineMemberRoleDisclosingParty},
        {Email: "them@example.com", DisplayName: "Jane Smith", Role: formable.RedlineMemberRoleReceivingParty},
    },
    Metadata: &formable.RedlineRequestMetadata{Subject: "Mutual NDA"},
})

redlineRequestID := created.RedlineRequestID

// Mint a redline URL for a member (embed in an iframe)
url, err := client.RedlineRequests.CreateURL(ctx, redlineRequestID, "them@example.com")

// Manage members and track progress
_, err = client.RedlineRequests.UpdateMembers(ctx, redlineRequestID, []formable.RedlineMember{
    {Email: "counsel@example.com", DisplayName: "Counsel", Role: formable.RedlineMemberRoleReceivingCounsel},
})
redline, err := client.RedlineRequests.Get(ctx, redlineRequestID)
events, err := client.RedlineRequests.GetEvents(ctx, redlineRequestID)
```

## Billing and health

```go theme={null}
billing, err := client.Billing(ctx)
health, err := client.Health(ctx)
```

## Error handling

All non-2xx responses return a `*formable.Error` with the server's error message, HTTP status, and parsed response body.

```go theme={null}
_, err := client.SignatureRequests.Get(ctx, "missing-id")
var apiErr *formable.Error
if errors.As(err, &apiErr) {
    fmt.Fprintf(os.Stderr, "%d %s\n", apiErr.Status, apiErr.Error())
}
```

## Configuration

Functional options take an API key, then optional base URL, timeout, and `*http.Client` values.

```go theme={null}
client, err := formable.NewClient(
    os.Getenv("FORMABLE_API_KEY"),
    formable.WithBaseURL("https://api.formabledocs.com/v1"),
    formable.WithTimeout(60*time.Second),
    formable.WithHTTPClient(httpClient),
)
```

| Option           | Description                                               | Default                           |
| ---------------- | --------------------------------------------------------- | --------------------------------- |
| (positional)     | Your Formable API key (sent as a bearer token). Required. | -                                 |
| `WithBaseURL`    | Override the API base URL.                                | `https://api.formabledocs.com/v1` |
| `WithTimeout`    | Per-request timeout.                                      | 60 seconds                        |
| `WithHTTPClient` | Custom `*http.Client`. Not closed by the SDK.             | Built-in client                   |

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Go from a plain document to a signed PDF in 4 calls.
  </Card>

  <Card title="API reference" icon="code" href="/api-reference/introduction">
    Every endpoint the SDK wraps, with a live playground.
  </Card>
</CardGroup>
