Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.paubox.com/llms.txt

Use this file to discover all available pages before exploring further.

The Forms client does not require API credentials. Forms are identified by a UUID that you obtain from the Paubox dashboard.

Creating a client

fc, err := paubox.NewFormsClient()
if err != nil {
    log.Fatal(err)
}
Optional configuration is available via FormsOption values:
OptionDescription
paubox.WithFormsBaseURL(url)Override the Forms API base URL
paubox.WithFormsHTTPClient(c)Supply a custom *http.Client
paubox.WithFormsTimeout(d)Set a per-request timeout
paubox.WithFormsRetry(cfg)Configure retry behavior
paubox.WithFormsUserAgent(s)Append to the User-Agent header

Get a form

Retrieve a form’s metadata, field schema, and rendered HTML/CSS:
ctx := context.Background()

form, err := fc.GetForm(ctx, "your-form-uuid")
if err != nil {
    log.Fatal(err)
}

fmt.Println("Form:", form.Title)

for _, field := range form.FormJSON.Body {
    fmt.Printf("  [%s] id=%s label=%s\n", field.Type, field.ID, field.Label)
}
The Form struct includes:
FieldDescription
TitleDisplay name of the form
FormJSONParsed field schema (FormJSON.Body is []FormField)
HTMLRendered HTML for embedding
CSSAssociated stylesheet

Submit a form

_, err = fc.SubmitForm(ctx, "your-form-uuid", paubox.FormSubmission{
    FormData: map[string]any{
        "name":  "Jane Smith",
        "email": "jane@example.com",
        "dob":   "1990-01-15",
    },
})
if err != nil {
    log.Fatal(err)
}

Submitting with file attachments

Attach files by base64-encoding their content:
import (
    "encoding/base64"
    "os"
)

fileBytes, err := os.ReadFile("consent.pdf")
if err != nil {
    log.Fatal(err)
}

_, err = fc.SubmitForm(ctx, "your-form-uuid", paubox.FormSubmission{
    FormData: map[string]any{
        "name": "Jane Smith",
    },
    Attachments: []paubox.FormAttachment{
        {
            Name:    "consent.pdf",
            Content: base64.StdEncoding.EncodeToString(fileBytes),
        },
    },
})
The FormAttachment struct:
FieldTypeDescription
NamestringFile name including extension
ContentstringBase64-encoded file content