contractsign

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 9 Imported by: 0

README

contractsign-go

Go SDK for the ContractSign API. Create contracts, send them for digital signing, manage templates, and track signing status — all from Go.

Install

go get github.com/happenings-dk/contractsign-go

Quick start

package main

import (
	"context"
	"fmt"
	"log"

	cs "github.com/happenings-dk/contractsign-go"
)

func main() {
	client := cs.New("cs_...")
	ctx := context.Background()

	contract, err := client.Contracts.Create(ctx, cs.CreateContractInput{
		Title:   "Consulting Agreement",
		Content: "<h1>Consulting Agreement</h1><p>...</p>",
	})
	if err != nil {
		log.Fatal(err)
	}

	signing, err := client.Signing.Create(ctx, cs.CreateSigningInput{
		ContractID: contract.ID,
		Signers: []cs.SignerInput{
			{
				Name:          "Jane Doe",
				Email:         "jane@example.com",
				Role:          cs.RoleSigner,
				SigningMethod: cs.MethodSMSOTP,
				Order:         1,
			},
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println("Signing request created:", signing.ID)
}

How it works

How it works

Contract lifecycle

Contract lifecycle

Signing flow

Signing flow

Resources

Contracts
// List contracts
contracts, err := client.Contracts.List(ctx, &cs.ListContractsParams{
    Status: cs.Ptr(cs.StatusDraft),
    Search: cs.Ptr("NDA"),
    Limit:  cs.Ptr(25),
})

// Get a single contract
contract, err := client.Contracts.Get(ctx, "contract-id")

// Create
contract, err := client.Contracts.Create(ctx, cs.CreateContractInput{
    Title:   "NDA",
    Content: "<h1>Non-Disclosure Agreement</h1>...",
})

// Update (draft contracts only for title/content changes)
contract, err := client.Contracts.Update(ctx, "contract-id", cs.UpdateContractInput{
    Title: cs.Ptr("Updated NDA"),
})

// Duplicate
copy, err := client.Contracts.Duplicate(ctx, "contract-id")

// Delete
err := client.Contracts.Delete(ctx, "contract-id")

// Download signed PDF (caller must close body)
resp, err := client.Contracts.PDF(ctx, "contract-id")
defer resp.Body.Close()
Parties
party, err := client.Contracts.CreateParty(ctx, "contract-id", cs.CreatePartyInput{
    Type:               cs.PartyCompany,
    Name:               "Acme Corp",
    Country:            "DK",
    RegistrationNumber: cs.Ptr("12345678"),
})

parties, err := client.Contracts.ListParties(ctx, "contract-id")
client.Contracts.UpdateParty(ctx, "contract-id", "party-id", cs.UpdatePartyInput{Name: cs.Ptr("Acme Inc")})
client.Contracts.DeleteParty(ctx, "contract-id", "party-id")
Signing
signing, err := client.Signing.Create(ctx, cs.CreateSigningInput{
    ContractID:   "contract-id",
    SigningOrder: cs.Ptr(cs.SigningOrderSequential),
    Message:      cs.Ptr("Please review and sign"),
    ExpiresAt:    cs.Ptr("2025-12-31T23:59:59Z"),
    Signers: []cs.SignerInput{
        {Name: "Alice", Email: "alice@example.com", Role: cs.RoleSigner, SigningMethod: cs.MethodSMSOTP, Order: 1},
        {Name: "Bob", Email: "bob@example.com", Role: cs.RoleSigner, SigningMethod: cs.MethodSMSOTP, Order: 2},
    },
})

// Check status
status, err := client.Signing.Get(ctx, "signing-request-id")
for _, s := range status.Signers {
    fmt.Printf("%s: %s\n", s.Name, s.Status)
}

// Get direct signing links
links, err := client.Signing.GetLinks(ctx, "signing-request-id")

// Send reminder
client.Signing.Remind(ctx, "signing-request-id", nil)

// Cancel
client.Signing.Cancel(ctx, "signing-request-id")
Custom email delivery

Use SuppressEmails to skip ContractSign's built-in emails and send them yourself:

signing, err := client.Signing.Create(ctx, cs.CreateSigningInput{
    ContractID:     "contract-id",
    SuppressEmails: cs.Ptr(true),
    Signers: []cs.SignerInput{
        {Name: "Jane", Email: "jane@example.com", Role: cs.RoleSigner, SigningMethod: cs.MethodSMSOTP, Order: 1},
    },
})

// signing.Emails contains the rendered HTML, subject, and signing URL
for _, email := range signing.Emails {
    sendEmail(email.To, email.Subject, email.HTML)
}

Custom email delivery flow

Templates
templates, err := client.Templates.List(ctx, nil)
template, err := client.Templates.Get(ctx, "template-id")

template, err := client.Templates.Create(ctx, cs.CreateTemplateInput{
    Name:    "Standard NDA",
    Content: "<h1>NDA</h1><p>Between {{company_name}} and {{counterparty}}...</p>",
    Fields: []cs.TemplateFieldInput{
        {Key: "company_name", Label: "Company Name", Type: cs.FieldVariable, Category: cs.CategoryTemplateVariable, Required: true, Position: 0},
    },
})

client.Templates.Update(ctx, "template-id", cs.UpdateTemplateInput{Name: cs.Ptr("Updated NDA")})
client.Templates.Delete(ctx, "template-id")
Folders
folders, err := client.Folders.List(ctx)
folder, err := client.Folders.Get(ctx, "folder-id")
folder, err := client.Folders.Create(ctx, cs.CreateFolderInput{Name: "Q1 Contracts", Color: cs.Ptr("#3B82F6")})
client.Folders.Update(ctx, "folder-id", cs.UpdateFolderInput{Name: cs.Ptr("Q2 Contracts")})
client.Folders.Delete(ctx, "folder-id")
Tags
tags, err := client.Tags.List(ctx)
tag, err := client.Tags.Create(ctx, cs.CreateTagInput{Name: "Urgent", Color: cs.Ptr("#EF4444")})
client.Tags.Update(ctx, "tag-id", cs.UpdateTagInput{Name: cs.Ptr("High Priority")})
client.Tags.Delete(ctx, "tag-id")
Account
me, err := client.Account.Me(ctx)
fmt.Println(me.User.Name, me.Organization.Name)

org, err := client.Account.GetOrganization(ctx)
client.Account.UpdateOrganization(ctx, cs.UpdateOrganizationInput{Name: cs.Ptr("New Org Name")})

keys, err := client.Account.ListAPIKeys(ctx)
newKey, err := client.Account.CreateAPIKey(ctx, cs.CreateAPIKeyInput{Name: "CI/CD"})
fmt.Println(newKey.Key) // only shown once
client.Account.DeleteAPIKey(ctx, "key-id")

SDK architecture

SDK architecture

Configuration

// Override base URL (for self-hosted instances)
client := cs.New("cs_...", cs.WithBaseURL("https://self-hosted.example.com"))

// Use a custom HTTP client (timeouts, proxies, etc.)
client := cs.New("cs_...", cs.WithHTTPClient(&http.Client{
    Timeout: 30 * time.Second,
}))

Error handling

API errors are returned as *contractsign.APIError with full request context:

contract, err := client.Contracts.Get(ctx, "nonexistent-id")
if err != nil {
    fmt.Println(err) // contractsign: GET /contracts/nonexistent-id: 404 Contract not found
}

Common status codes map to sentinel errors for clean matching with errors.Is:

contract, err := client.Contracts.Get(ctx, id)
if errors.Is(err, cs.ErrNotFound) {
    // handle 404
}
if errors.Is(err, cs.ErrUnauthorized) {
    // handle 401 — bad or expired API key
}

For full details, use errors.As:

var apiErr *cs.APIError
if errors.As(err, &apiErr) {
    fmt.Println(apiErr.StatusCode) // 429
    fmt.Println(apiErr.Method)     // "POST"
    fmt.Println(apiErr.Path)       // "/signing"
    fmt.Println(apiErr.Message)    // "Rate limit exceeded"
}
Sentinel HTTP Status
ErrNotFound 404
ErrUnauthorized 401
ErrForbidden 403
ErrRateLimited 429

Signing methods

Method Description
MethodSMSOTP Signer verifies identity via SMS one-time password
MethodMitID Danish MitID / eID verification

Signer roles

Role Description
RoleSigner Must sign the document
RoleViewer Can view but not sign
RoleApprover Must approve before signers can sign

License

MIT

Documentation

Overview

Package contractsign provides a Go client for the ContractSign API.

Create contracts, send them for digital signing, manage templates, and track signing status — all from Go.

client := contractsign.New("cs_...")

contract, err := client.Contracts.Create(ctx, contractsign.CreateContractInput{
    Title:   "Consulting Agreement",
    Content: "<h1>Consulting Agreement</h1><p>...</p>",
})

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("not found")
	ErrUnauthorized = errors.New("unauthorized")
	ErrForbidden    = errors.New("forbidden")
	ErrRateLimited  = errors.New("rate limited")
)

Sentinel errors for common API failure modes. Use errors.Is to match these in caller code.

Functions

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to v. Useful for setting optional fields in input structs.

Types

type APIError

type APIError struct {
	// StatusCode is the HTTP status code returned by the API.
	StatusCode int
	// Method is the HTTP method of the failed request (e.g. "GET").
	Method string
	// Path is the API path of the failed request (e.g. "/contracts/abc").
	Path string
	// Body is the raw response body.
	Body json.RawMessage
	// Message is the parsed error message, if available.
	Message string
	// contains filtered or unexported fields
}

APIError is returned when the API responds with a non-2xx status code. It wraps a sentinel error for common status codes so that callers can use errors.Is(err, contractsign.ErrNotFound) instead of inspecting StatusCode.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap returns the sentinel error for this status code, enabling errors.Is matching.

type APIKey

type APIKey struct {
	ID         string  `json:"id"`
	Name       string  `json:"name"`
	KeyPrefix  string  `json:"keyPrefix"`
	LastUsedAt *string `json:"lastUsedAt"`
	ExpiresAt  *string `json:"expiresAt"`
	CreatedAt  string  `json:"createdAt"`
	User       UserRef `json:"user"`
}

APIKey represents an API key for the organization.

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

AccountService handles account, organization, and API key operations.

func (*AccountService) CreateAPIKey

CreateAPIKey creates a new API key. The full key is only returned once.

func (*AccountService) DeleteAPIKey

func (s *AccountService) DeleteAPIKey(ctx context.Context, id string) error

DeleteAPIKey deletes an API key.

func (*AccountService) GetOrganization

func (s *AccountService) GetOrganization(ctx context.Context) (*Organization, error)

GetOrganization retrieves the current organization.

func (*AccountService) ListAPIKeys

func (s *AccountService) ListAPIKeys(ctx context.Context) ([]APIKey, error)

ListAPIKeys returns all API keys for the organization.

func (*AccountService) Me

func (s *AccountService) Me(ctx context.Context) (*Me, error)

Me returns the authenticated user and their organization.

func (*AccountService) UpdateOrganization

func (s *AccountService) UpdateOrganization(ctx context.Context, input UpdateOrganizationInput) (*Organization, error)

UpdateOrganization updates the current organization.

type AuditLog

type AuditLog struct {
	ID        string `json:"id"`
	Action    string `json:"action"`
	Metadata  any    `json:"metadata"`
	CreatedAt string `json:"createdAt"`
}

AuditLog is a single audit trail entry.

type Client

type Client struct {
	Contracts *ContractsService
	Signing   *SigningService
	Templates *TemplatesService
	Folders   *FoldersService
	Tags      *TagsService
	Account   *AccountService
}

Client is the top-level ContractSign API client.

func New

func New(apiKey string, opts ...Option) *Client

New creates a new ContractSign API client.

type Contract

type Contract struct {
	ID                string             `json:"id"`
	Title             string             `json:"title"`
	Content           string             `json:"content"`
	Status            ContractStatus     `json:"status"`
	CreatedAt         string             `json:"createdAt"`
	UpdatedAt         string             `json:"updatedAt"`
	TemplateID        *string            `json:"templateId"`
	FolderID          *string            `json:"folderId"`
	Tags              []TagRef           `json:"tags"`
	Template          *NameRef           `json:"template"`
	Folder            *NameRef           `json:"folder"`
	CreatedBy         UserRef            `json:"createdBy"`
	SigningRequest    *SigningRequest    `json:"signingRequest"`
	Parties           []Party            `json:"parties"`
	FieldValues       []FieldValue       `json:"fieldValues"`
	SignerFieldValues []SignerFieldValue `json:"signerFieldValues"`
	AuditLogs         []AuditLog         `json:"auditLogs"`
}

Contract is the full representation of a contract with all relations.

type ContractListItem

type ContractListItem struct {
	ID             string         `json:"id"`
	Title          string         `json:"title"`
	Status         ContractStatus `json:"status"`
	UpdatedAt      string         `json:"updatedAt"`
	Tags           []TagRef       `json:"tags"`
	Template       *NameRef       `json:"template"`
	Folder         *NameRef       `json:"folder"`
	CreatedBy      UserRef        `json:"createdBy"`
	SigningRequest *struct {
		ID     string `json:"id"`
		Status string `json:"status"`
	} `json:"signingRequest"`
}

ContractListItem is a lightweight contract representation for list endpoints.

type ContractStatus

type ContractStatus string
const (
	StatusDraft     ContractStatus = "draft"
	StatusPending   ContractStatus = "pending"
	StatusSigning   ContractStatus = "signing"
	StatusCompleted ContractStatus = "completed"
	StatusCancelled ContractStatus = "cancelled"
	StatusExpired   ContractStatus = "expired"
)

ContractStatus values.

type ContractsService

type ContractsService struct {
	// contains filtered or unexported fields
}

ContractsService handles contract CRUD and party management.

func (*ContractsService) Create

Create creates a new contract.

func (*ContractsService) CreateParty

func (s *ContractsService) CreateParty(ctx context.Context, contractID string, input CreatePartyInput) (*Party, error)

CreateParty adds a party to a contract.

func (*ContractsService) Delete

func (s *ContractsService) Delete(ctx context.Context, id string) error

Delete deletes a contract.

func (*ContractsService) DeleteParty

func (s *ContractsService) DeleteParty(ctx context.Context, contractID, partyID string) error

DeleteParty removes a party from a contract.

func (*ContractsService) Duplicate

func (s *ContractsService) Duplicate(ctx context.Context, id string) (*Contract, error)

Duplicate creates a copy of an existing contract.

func (*ContractsService) Get

func (s *ContractsService) Get(ctx context.Context, id string) (*Contract, error)

Get retrieves a single contract by ID.

func (*ContractsService) List

List returns a paginated list of contracts.

func (*ContractsService) ListParties

func (s *ContractsService) ListParties(ctx context.Context, contractID string) ([]Party, error)

ListParties returns all parties on a contract.

func (*ContractsService) PDF

PDF downloads the signed PDF for a completed contract. The caller must close the response body.

func (*ContractsService) Update

Update updates an existing contract.

func (*ContractsService) UpdateParty

func (s *ContractsService) UpdateParty(ctx context.Context, contractID, partyID string, input UpdatePartyInput) (*Party, error)

UpdateParty updates a party on a contract.

type CreateAPIKeyInput

type CreateAPIKeyInput struct {
	Name      string  `json:"name"`
	ExpiresAt *string `json:"expiresAt,omitempty"`
}

CreateAPIKeyInput is the payload for creating an API key.

type CreateAPIKeyResponse

type CreateAPIKeyResponse struct {
	Key    string `json:"key"`
	Prefix string `json:"prefix"`
	Name   string `json:"name"`
	APIKey APIKey `json:"apiKey"`
}

CreateAPIKeyResponse is returned when creating an API key. The Key field contains the full API key and is only available at creation time.

type CreateContractInput

type CreateContractInput struct {
	Title       string            `json:"title"`
	Content     string            `json:"content"`
	TemplateID  *string           `json:"templateId,omitempty"`
	FolderID    *string           `json:"folderId,omitempty"`
	TagIDs      []string          `json:"tagIds,omitempty"`
	FieldValues []FieldValueInput `json:"fieldValues,omitempty"`
}

CreateContractInput is the payload for creating a contract.

type CreateFolderInput

type CreateFolderInput struct {
	Name     string  `json:"name"`
	ParentID *string `json:"parentId,omitempty"`
	Color    *string `json:"color,omitempty"`
	Position *int    `json:"position,omitempty"`
}

CreateFolderInput is the payload for creating a folder.

type CreatePartyInput

type CreatePartyInput struct {
	Type               PartyType    `json:"type"`
	Name               string       `json:"name"`
	Address            *string      `json:"address,omitempty"`
	City               *string      `json:"city,omitempty"`
	Zip                *string      `json:"zip,omitempty"`
	Country            string       `json:"country"`
	RegistrationNumber *string      `json:"registrationNumber,omitempty"`
	ReferredAs         *string      `json:"referredAs,omitempty"`
	SignerHints        []SignerHint `json:"signerHints,omitempty"`
	Order              *int         `json:"order,omitempty"`
}

CreatePartyInput is the payload for adding a party to a contract.

type CreateSigningInput

type CreateSigningInput struct {
	ContractID     string        `json:"contractId"`
	Message        *string       `json:"message,omitempty"`
	SigningOrder   *SigningOrder `json:"signingOrder,omitempty"`
	ExpiresAt      *string       `json:"expiresAt,omitempty"`
	SuppressEmails *bool         `json:"suppressEmails,omitempty"`
	Signers        []SignerInput `json:"signers"`
}

CreateSigningInput is the payload for creating a signing request.

type CreateSigningResponse

type CreateSigningResponse struct {
	SigningRequest
	Emails []RenderedEmail `json:"emails,omitempty"`
}

CreateSigningResponse is the response from creating a signing request. When SuppressEmails was set to true, Emails contains the rendered email payloads.

type CreateTagInput

type CreateTagInput struct {
	Name  string  `json:"name"`
	Color *string `json:"color,omitempty"`
}

CreateTagInput is the payload for creating a tag.

type CreateTemplateInput

type CreateTemplateInput struct {
	Name           string               `json:"name"`
	Description    *string              `json:"description,omitempty"`
	Content        string               `json:"content"`
	Fields         []TemplateFieldInput `json:"fields,omitempty"`
	DefaultSigners []DefaultSigner      `json:"defaultSigners,omitempty"`
}

CreateTemplateInput is the payload for creating a template.

type DefaultSigner

type DefaultSigner struct {
	Name          string        `json:"name"`
	Email         string        `json:"email"`
	Phone         *string       `json:"phone,omitempty"`
	Role          SignerRole    `json:"role"`
	SigningMethod SigningMethod `json:"signingMethod"`
	PartyName     *string       `json:"partyName,omitempty"`
}

DefaultSigner is a pre-configured signer on a template.

type FieldCategory

type FieldCategory string
const (
	CategoryTemplateVariable FieldCategory = "template_variable"
	CategoryInteractive      FieldCategory = "interactive"
)

FieldCategory values.

type FieldOption

type FieldOption struct {
	Value string `json:"value"`
	Label string `json:"label"`
}

FieldOption is a selectable option for a template field.

type FieldType

type FieldType string
const (
	FieldVariable  FieldType = "variable"
	FieldSignature FieldType = "signature"
	FieldDate      FieldType = "date"
	FieldCheckbox  FieldType = "checkbox"
	FieldTextInput FieldType = "text_input"
)

FieldType values.

type FieldValue

type FieldValue struct {
	ID            string        `json:"id"`
	Value         *string       `json:"value"`
	SignatureData *string       `json:"signatureData"`
	FilledAt      *string       `json:"filledAt"`
	TemplateField TemplateField `json:"templateField"`
}

FieldValue is a filled value for a template field on a contract.

type FieldValueInput

type FieldValueInput struct {
	TemplateFieldID string  `json:"templateFieldId"`
	Value           *string `json:"value,omitempty"`
	SignatureData   *string `json:"signatureData,omitempty"`
}

FieldValueInput is used when setting field values on a contract.

type Folder

type Folder struct {
	ID        string  `json:"id"`
	Name      string  `json:"name"`
	Color     *string `json:"color"`
	Position  int     `json:"position"`
	ParentID  *string `json:"parentId"`
	CreatedAt string  `json:"createdAt"`
	UpdatedAt string  `json:"updatedAt"`
	Count     struct {
		Contracts int `json:"contracts"`
		Children  int `json:"children"`
	} `json:"_count"`
}

Folder represents a contract folder.

type FoldersService

type FoldersService struct {
	// contains filtered or unexported fields
}

FoldersService handles folder CRUD operations.

func (*FoldersService) Create

func (s *FoldersService) Create(ctx context.Context, input CreateFolderInput) (*Folder, error)

Create creates a new folder.

func (*FoldersService) Delete

func (s *FoldersService) Delete(ctx context.Context, id string) error

Delete deletes a folder.

func (*FoldersService) Get

func (s *FoldersService) Get(ctx context.Context, id string) (*Folder, error)

Get retrieves a single folder by ID.

func (*FoldersService) List

func (s *FoldersService) List(ctx context.Context) ([]Folder, error)

List returns all folders.

func (*FoldersService) Update

func (s *FoldersService) Update(ctx context.Context, id string, input UpdateFolderInput) (*Folder, error)

Update updates an existing folder.

type GetSigningResponse

type GetSigningResponse struct {
	SigningRequest
	Contract struct {
		ID     string `json:"id"`
		Title  string `json:"title"`
		Status string `json:"status"`
	} `json:"contract"`
}

GetSigningResponse includes the signing request and its associated contract.

type ListContractsParams

type ListContractsParams struct {
	Limit    *int            `json:"limit,omitempty"`
	Offset   *int            `json:"offset,omitempty"`
	Status   *ContractStatus `json:"status,omitempty"`
	FolderID *string         `json:"folderId,omitempty"`
	TagIDs   *string         `json:"tagIds,omitempty"`
	Search   *string         `json:"search,omitempty"`
}

ListContractsParams configures contract listing.

type ListTemplatesParams

type ListTemplatesParams struct {
	Limit  *int
	Offset *int
}

ListTemplatesParams configures template listing.

type Me

type Me struct {
	User         UserRef `json:"user"`
	Organization struct {
		ID   string `json:"id"`
		Name string `json:"name"`
		Slug string `json:"slug"`
	} `json:"organization"`
	Role string `json:"role"`
}

Me is the authenticated user and their organization.

type NameRef

type NameRef struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

NameRef is a minimal reference with ID and name.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures the Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL overrides the default API base URL (https://contractsign.net).

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient overrides the default HTTP client used for API requests.

type Organization

type Organization struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Slug      string `json:"slug"`
	CreatedAt string `json:"createdAt"`
	Count     struct {
		Memberships int `json:"memberships"`
		Contracts   int `json:"contracts"`
	} `json:"_count"`
}

Organization represents an organization account.

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Data    []T  `json:"data"`
	Total   int  `json:"total"`
	HasMore bool `json:"hasMore"`
}

PaginatedResponse wraps a list endpoint response with pagination metadata.

type Party

type Party struct {
	ID                 string       `json:"id"`
	Type               PartyType    `json:"type"`
	Name               string       `json:"name"`
	Address            *string      `json:"address"`
	City               *string      `json:"city"`
	Zip                *string      `json:"zip"`
	Country            string       `json:"country"`
	RegistrationNumber *string      `json:"registrationNumber"`
	ReferredAs         *string      `json:"referredAs"`
	SignerHints        []SignerHint `json:"signerHints"`
	Order              int          `json:"order"`
}

Party represents a signatory party on a contract.

type PartyType

type PartyType string
const (
	PartyCompany PartyType = "company"
	PartyPerson  PartyType = "person"
)

PartyType values.

type RemindOptions

type RemindOptions struct {
	// SuppressEmails prevents sending emails and instead returns rendered payloads.
	SuppressEmails bool
}

RemindOptions configures the SigningService.Remind call.

type RemindResponse

type RemindResponse struct {
	Reminded int             `json:"reminded"`
	Signers  []Signer        `json:"signers"`
	Emails   []RenderedEmail `json:"emails,omitempty"`
}

RemindResponse is the response from sending reminders.

type RenderedEmail

type RenderedEmail struct {
	To         string `json:"to"`
	Subject    string `json:"subject"`
	HTML       string `json:"html"`
	SigningURL string `json:"signingUrl"`
}

RenderedEmail contains a pre-rendered email returned when suppressEmails is true.

type Signer

type Signer struct {
	ID            string        `json:"id"`
	Name          string        `json:"name"`
	Email         string        `json:"email"`
	Role          SignerRole    `json:"role"`
	SigningMethod SigningMethod `json:"signingMethod"`
	Status        SignerStatus  `json:"status"`
	Order         int           `json:"order"`
	Token         string        `json:"token"`
	SignedAt      *string       `json:"signedAt"`
	DeclinedAt    *string       `json:"declinedAt"`
	DeclineReason *string       `json:"declineReason"`
	FirstOpenedAt *string       `json:"firstOpenedAt"`
	LastOpenedAt  *string       `json:"lastOpenedAt"`
	OpenedCount   int           `json:"openedCount"`
	IPAddress     *string       `json:"ipAddress"`
	UserAgent     *string       `json:"userAgent"`
}

Signer represents an individual signer on a signing request.

type SignerFieldValue

type SignerFieldValue struct {
	ID            string  `json:"id"`
	SignerID      string  `json:"signerId"`
	FieldKey      string  `json:"fieldKey"`
	FieldLabel    string  `json:"fieldLabel"`
	FieldType     string  `json:"fieldType"`
	AssignedTo    string  `json:"assignedTo"`
	Value         *string `json:"value"`
	SignatureData *string `json:"signatureData"`
	FilledAt      *string `json:"filledAt"`
}

SignerFieldValue is a signer-specific field value.

type SignerHint

type SignerHint struct {
	Name  string  `json:"name"`
	Email *string `json:"email,omitempty"`
	Title *string `json:"title,omitempty"`
}

SignerHint is a suggested signer associated with a party.

type SignerInput

type SignerInput struct {
	Name          string        `json:"name"`
	Email         string        `json:"email"`
	Phone         *string       `json:"phone,omitempty"`
	Role          SignerRole    `json:"role"`
	SigningMethod SigningMethod `json:"signingMethod"`
	Order         int           `json:"order"`
}

SignerInput defines a signer when creating a signing request.

type SignerRole

type SignerRole string
const (
	RoleSigner   SignerRole = "signer"
	RoleViewer   SignerRole = "viewer"
	RoleApprover SignerRole = "approver"
)

SignerRole values.

type SignerStatus

type SignerStatus string
const (
	SignerPending  SignerStatus = "pending"
	SignerNotified SignerStatus = "notified"
	SignerOpened   SignerStatus = "opened"
	SignerSigned   SignerStatus = "signed"
	SignerDeclined SignerStatus = "declined"
)

SignerStatus values.

type SigningLink struct {
	Name   string `json:"name"`
	Email  string `json:"email"`
	Status string `json:"status"`
	URL    string `json:"url"`
}

SigningLink is a direct signing URL for a signer.

type SigningMethod

type SigningMethod string
const (
	MethodSMSOTP SigningMethod = "sms_otp"
	MethodMitID  SigningMethod = "mitid"
)

SigningMethod values.

type SigningOrder

type SigningOrder string
const (
	SigningOrderParallel   SigningOrder = "parallel"
	SigningOrderSequential SigningOrder = "sequential"
)

SigningOrder values.

type SigningRequest

type SigningRequest struct {
	ID           string       `json:"id"`
	Status       string       `json:"status"`
	SigningOrder SigningOrder `json:"signingOrder"`
	Message      *string      `json:"message"`
	CreatedAt    string       `json:"createdAt"`
	CompletedAt  *string      `json:"completedAt"`
	Signers      []Signer     `json:"signers"`
}

SigningRequest represents a signing campaign for a contract.

type SigningService

type SigningService struct {
	// contains filtered or unexported fields
}

SigningService handles signing request operations.

func (*SigningService) Cancel

func (s *SigningService) Cancel(ctx context.Context, id string) error

Cancel cancels a signing request.

func (*SigningService) Create

Create creates a new signing request. When input.SuppressEmails is true, emails are not sent — instead the rendered email payloads are returned in CreateSigningResponse.Emails.

func (*SigningService) Get

Get retrieves a signing request by ID.

func (s *SigningService) GetLinks(ctx context.Context, id string) ([]SigningLink, error)

GetLinks returns direct signing URLs for each signer on a signing request. Useful when email delivery fails and links need to be shared manually.

func (*SigningService) Remind

func (s *SigningService) Remind(ctx context.Context, id string, opts *RemindOptions) (*RemindResponse, error)

Remind sends reminder emails to pending signers. When opts.SuppressEmails is true, emails are not sent — instead the rendered email payloads are returned in RemindResponse.Emails.

type Tag

type Tag struct {
	ID    string  `json:"id"`
	Name  string  `json:"name"`
	Color *string `json:"color"`
}

Tag represents a contract tag.

type TagRef

type TagRef struct {
	Tag Tag `json:"tag"`
}

TagRef wraps a Tag in a join-table structure.

type TagWithCount

type TagWithCount struct {
	Tag
	Count struct {
		Contracts int `json:"contracts"`
	} `json:"_count"`
}

TagWithCount is a Tag with an associated contract count.

type TagsService

type TagsService struct {
	// contains filtered or unexported fields
}

TagsService handles tag CRUD operations.

func (*TagsService) Create

func (s *TagsService) Create(ctx context.Context, input CreateTagInput) (*Tag, error)

Create creates a new tag.

func (*TagsService) Delete

func (s *TagsService) Delete(ctx context.Context, id string) error

Delete deletes a tag.

func (*TagsService) List

func (s *TagsService) List(ctx context.Context) ([]TagWithCount, error)

List returns all tags with contract counts.

func (*TagsService) Update

func (s *TagsService) Update(ctx context.Context, id string, input UpdateTagInput) (*Tag, error)

Update updates an existing tag.

type Template

type Template struct {
	ID             string          `json:"id"`
	Name           string          `json:"name"`
	Description    *string         `json:"description"`
	Content        string          `json:"content"`
	Version        int             `json:"version"`
	IsActive       bool            `json:"isActive"`
	CreatedAt      string          `json:"createdAt"`
	UpdatedAt      string          `json:"updatedAt"`
	Fields         []TemplateField `json:"fields"`
	DefaultSigners []DefaultSigner `json:"defaultSigners"`
}

Template is the full representation of a contract template.

type TemplateField

type TemplateField struct {
	ID           string        `json:"id"`
	Key          string        `json:"key"`
	Label        string        `json:"label"`
	Type         FieldType     `json:"type"`
	Category     FieldCategory `json:"category"`
	Required     bool          `json:"required"`
	DefaultValue *string       `json:"defaultValue"`
	Placeholder  *string       `json:"placeholder"`
	Position     int           `json:"position"`
	Options      []FieldOption `json:"options"`
}

TemplateField defines a fillable field in a template.

type TemplateFieldInput

type TemplateFieldInput struct {
	Key          string        `json:"key"`
	Label        string        `json:"label"`
	Type         FieldType     `json:"type"`
	Category     FieldCategory `json:"category"`
	Required     bool          `json:"required"`
	DefaultValue *string       `json:"defaultValue,omitempty"`
	Placeholder  *string       `json:"placeholder,omitempty"`
	Position     int           `json:"position"`
	Options      []FieldOption `json:"options,omitempty"`
}

TemplateFieldInput defines a field when creating or updating a template.

type TemplateListItem

type TemplateListItem struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description *string `json:"description"`
	Version     int     `json:"version"`
	UpdatedAt   string  `json:"updatedAt"`
	CreatedBy   UserRef `json:"createdBy"`
	Count       struct {
		Contracts int `json:"contracts"`
		Fields    int `json:"fields"`
	} `json:"_count"`
}

TemplateListItem is a lightweight template for list endpoints.

type TemplatesService

type TemplatesService struct {
	// contains filtered or unexported fields
}

TemplatesService handles template CRUD operations.

func (*TemplatesService) Create

Create creates a new template.

func (*TemplatesService) Delete

func (s *TemplatesService) Delete(ctx context.Context, id string) error

Delete deletes a template.

func (*TemplatesService) Get

func (s *TemplatesService) Get(ctx context.Context, id string) (*Template, error)

Get retrieves a single template by ID.

func (*TemplatesService) List

List returns a paginated list of templates.

func (*TemplatesService) Update

Update updates an existing template.

type UpdateContractInput

type UpdateContractInput struct {
	Title       *string           `json:"title,omitempty"`
	Content     *string           `json:"content,omitempty"`
	Status      *ContractStatus   `json:"status,omitempty"`
	FolderID    *string           `json:"folderId,omitempty"`
	TagIDs      []string          `json:"tagIds,omitempty"`
	FieldValues []FieldValueInput `json:"fieldValues,omitempty"`
}

UpdateContractInput is the payload for updating a contract.

type UpdateFolderInput

type UpdateFolderInput struct {
	Name     *string `json:"name,omitempty"`
	ParentID *string `json:"parentId,omitempty"`
	Color    *string `json:"color,omitempty"`
	Position *int    `json:"position,omitempty"`
}

UpdateFolderInput is the payload for updating a folder.

type UpdateOrganizationInput

type UpdateOrganizationInput struct {
	Name *string `json:"name,omitempty"`
	Slug *string `json:"slug,omitempty"`
}

UpdateOrganizationInput is the payload for updating an organization.

type UpdatePartyInput

type UpdatePartyInput struct {
	Type               *PartyType   `json:"type,omitempty"`
	Name               *string      `json:"name,omitempty"`
	Address            *string      `json:"address,omitempty"`
	City               *string      `json:"city,omitempty"`
	Zip                *string      `json:"zip,omitempty"`
	Country            *string      `json:"country,omitempty"`
	RegistrationNumber *string      `json:"registrationNumber,omitempty"`
	ReferredAs         *string      `json:"referredAs,omitempty"`
	SignerHints        []SignerHint `json:"signerHints,omitempty"`
	Order              *int         `json:"order,omitempty"`
}

UpdatePartyInput is the payload for updating a party.

type UpdateTagInput

type UpdateTagInput struct {
	Name  *string `json:"name,omitempty"`
	Color *string `json:"color,omitempty"`
}

UpdateTagInput is the payload for updating a tag.

type UpdateTemplateInput

type UpdateTemplateInput struct {
	Name           *string              `json:"name,omitempty"`
	Description    *string              `json:"description,omitempty"`
	Content        *string              `json:"content,omitempty"`
	Fields         []TemplateFieldInput `json:"fields,omitempty"`
	DefaultSigners []DefaultSigner      `json:"defaultSigners,omitempty"`
}

UpdateTemplateInput is the payload for updating a template.

type UserRef

type UserRef struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

UserRef is a minimal user reference.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL