client

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client provides a wrapper for interacting with the DocuSign API.

API Endpoints Used

This client interacts with the following DocuSign eSignature REST API v2.1 endpoints:

Users: DOCUMENTATION: https://developers.docusign.com/docs/esign-rest-api/reference/users/users/

  • GET /restapi/v2.1/accounts/{accountId}/users - List account users (supports pagination)
  • GET /restapi/v2.1/accounts/{accountId}/users/{userId} - Get user details
  • POST /restapi/v2.1/accounts/{accountId}/users - Create new users
  • PUT /restapi/v2.1/accounts/{accountId}/users/{userId}/profile - Update user profile
  • DELETE /restapi/v2.1/accounts/{accountId}/users - Delete users

Groups: DOCUMENTATION: https://developers.docusign.com/docs/esign-rest-api/reference/usergroups/groups/ DOCUMENTATION: https://developers.docusign.com/docs/esign-rest-api/reference/usergroups/groupusers/

  • GET /restapi/v2.1/accounts/{accountId}/groups - List account groups (supports pagination)
  • GET /restapi/v2.1/accounts/{accountId}/groups/{groupId}/users - List users in a group (supports pagination)
  • PUT /restapi/v2.1/accounts/{accountId}/groups/{groupId}/users - Add users to a group
  • DELETE /restapi/v2.1/accounts/{accountId}/groups/{groupId}/users - Remove users from a group

Signing Groups: DOCUMENTATION: https://developers.docusign.com/docs/esign-rest-api/reference/signinggroups/

  • GET /restapi/v2.1/accounts/{accountId}/signing_groups - List signing groups (supports pagination)
  • GET /restapi/v2.1/accounts/{accountId}/signing_groups/{groupId}/users - List signing group users (supports pagination)
  • PUT /restapi/v2.1/accounts/{accountId}/signing_groups/{groupId} - Update signing group membership
  • DELETE /restapi/v2.1/accounts/{accountId}/signing_groups/{groupId}/users - Remove users from signing group

Permission Profiles: DOCUMENTATION: https://developers.docusign.com/docs/esign-rest-api/reference/accounts/accountpermissionprofiles/ DOCUMENTATION: https://developers.docusign.com/docs/esign-rest-api/reference/users/userprofiles/

  • GET /restapi/v2.1/accounts/{accountId}/permission_profiles - List permission profiles (no pagination)
  • PUT /restapi/v2.1/accounts/{accountId}/users/{userId}/profile - Update user profile

OAuth:

API Documentation

Complete API documentation: https://developers.docusign.com/docs/esign-rest-api/reference/

Pagination Strategy

DocuSign API uses cursor-based pagination with the following parameters:

  • count: Number of results per page (1-100, default: 100)
  • start_position: Starting position (0-based index)

The API returns:

  • endPosition: Last item position in current page
  • totalSetSize: Total number of items available

Rate Limiting:

  • API rate limits are enforced by DocuSign
  • The SDK automatically handles rate limit errors via uhttp

Index

Constants

View Source
const DefaultPageSize = 100

Variables

This section is empty.

Functions

func ApplyQueryParam added in v0.0.3

func ApplyQueryParam(reqURL *url.URL, key string, value string)

Types

type AccountInfo added in v0.0.6

type AccountInfo struct {
	AccountId      string `json:"account_id"`
	IsDefault      bool   `json:"is_default"`
	AccountName    string `json:"account_name"`
	BaseURI        string `json:"base_uri"`
	OrganizationId string `json:"organization_id"`
}

AccountInfo represents account information from the User Info response.

type AccountManagement

type AccountManagement struct {
	CanManageUsers                   string `json:"canManageUsers"`
	CanManageAdmins                  string `json:"canManageAdmins"`
	CanManageAccountSettings         string `json:"canManageAccountSettings"`
	CanManageReporting               string `json:"canManageReporting"`
	CanManageAccountSecuritySettings string `json:"canManageAccountSecuritySettings"`
}

type Client

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

Client wraps HTTP interactions with the DocuSign API.

func New

func New(ctx context.Context, isDemo bool, clientID, clientSecret, redirectURI, refreshToken, configAccountId string) (*Client, error)

New constructs a Client with OAuth2 flow, now using dynamic base URI resolution. If configAccountId is non-empty, the client will select that specific account instead of the default.

func NewClient

func NewClient(ctx context.Context, isDemo bool, tokenSource oauth2.TokenSource, configAccountId string, httpClient ...*uhttp.BaseHttpClient) *Client

NewClient initializes a Client with a fixed token and optional HTTP wrapper. If configAccountId is non-empty, the client will select that specific account instead of the default.

func (*Client) CreateUsers

CreateUsers sends a bulk create request for new users in the account.

func (*Client) DeleteGroupUsers added in v0.1.1

func (c *Client) DeleteGroupUsers(ctx context.Context, groupID string, request GroupUsersRequest) (*GroupUsersResponse, annotations.Annotations, error)

DeleteGroupUsers removes users from a group using the DocuSign API. Based on API: DELETE /restapi/v2.1/accounts/{accountId}/groups/{groupId}/users.

func (*Client) DeleteSigningGroupUsers added in v0.1.1

func (c *Client) DeleteSigningGroupUsers(ctx context.Context, signingGroupID string, request SigningGroupUsersRequest) (*SigningGroupUsersResponse, annotations.Annotations, error)

DeleteSigningGroupUsers removes users from a signing group using the DocuSign API. Based on API: DELETE /restapi/v2.1/accounts/{accountId}/signing_groups/{signingGroupId}/users.

func (*Client) DeleteUsers added in v0.1.1

DeleteUsers sends a bulk delete request to remove users from the account.

func (*Client) GetGroupUsers

func (c *Client) GetGroupUsers(ctx context.Context, groupId string, options PageOptions) ([]User, string, annotations.Annotations, error)

GetGroupUsers fetches a page of users that belong to a specific group.

Pagination: This endpoint supports cursor-based pagination using start_position and count parameters. The API returns up to 100 users per page (controlled by PageOptions.PageSize). To fetch the next page, use the returned nextToken as PageOptions.PageToken.

Returns: users list, next page token (empty if last page), annotations, error.

func (*Client) GetGroups

func (c *Client) GetGroups(ctx context.Context, options PageOptions) ([]Group, string, annotations.Annotations, error)

GetGroups fetches a page of groups from the DocuSign account.

Pagination: This endpoint supports cursor-based pagination using start_position and count parameters. The API returns up to 100 groups per page (controlled by PageOptions.PageSize). To fetch the next page, use the returned nextToken as PageOptions.PageToken.

Returns: groups list, next page token (empty if last page), annotations, error.

func (*Client) GetPermissionProfiles added in v0.0.3

func (c *Client) GetPermissionProfiles(ctx context.Context) ([]PermissionProfile, annotations.Annotations, error)

GetPermissionProfiles fetches all permission profiles from the DocuSign account.

Pagination: This endpoint does NOT support pagination. It returns all permission profiles in a single request. Typically, DocuSign accounts have a limited number of permission profiles (< 50), so this is acceptable.

Returns: all permission profiles, annotations, error.

func (*Client) GetSigningGroupUsers added in v0.0.3

func (c *Client) GetSigningGroupUsers(ctx context.Context, groupId string, options PageOptions) ([]User, string, annotations.Annotations, error)

GetSigningGroupUsers fetches a page of users that belong to a specific signing group.

Pagination: This endpoint supports cursor-based pagination using start_position and count parameters. The API returns up to 100 users per page (controlled by PageOptions.PageSize). To fetch the next page, use the returned nextToken as PageOptions.PageToken.

Returns: users list, next page token (empty if last page), annotations, error.

func (*Client) GetSigningGroups added in v0.0.3

func (c *Client) GetSigningGroups(ctx context.Context, options PageOptions) ([]SigningGroup, string, annotations.Annotations, error)

GetSigningGroups fetches a page of signing groups from the DocuSign account.

Pagination: This endpoint supports cursor-based pagination using start_position and count parameters. The API returns up to 100 signing groups per page (controlled by PageOptions.PageSize). To fetch the next page, use the returned nextToken as PageOptions.PageToken.

Returns: signing groups list, next page token (empty if last page), annotations, error.

func (*Client) GetUserByEmail added in v0.0.3

func (c *Client) GetUserByEmail(ctx context.Context, userEmail string) (*User, annotations.Annotations, error)

GetUserByEmail retrieves a user filtering by the email and the user status 'Active' or 'Activation Sent'.

func (*Client) GetUserDetails

func (c *Client) GetUserDetails(ctx context.Context, userID string) (*UserDetail, annotations.Annotations, error)

GetUserDetails fetches detailed information for a specific user, including permissions.

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, options PageOptions) ([]User, string, annotations.Annotations, error)

GetUsers fetches a page of users from the DocuSign account.

Pagination: This endpoint supports cursor-based pagination using start_position and count parameters. The API returns up to 100 users per page (controlled by PageOptions.PageSize). To fetch the next page, use the returned nextToken as PageOptions.PageToken.

Returns: users list, next page token (empty if last page), annotations, error.

func (*Client) RequestRefreshToken added in v0.1.2

func (c *Client) RequestRefreshToken(ctx context.Context, clientID, clientSecret, redirectURI, code string) (string, error)

RequestRefreshToken exchanges an authorization code for a refresh token. DocuSign requires Basic Auth (base64(clientID:clientSecret)) and redirect_uri in the request.

func (*Client) UpdateGroupUsers added in v0.1.1

func (c *Client) UpdateGroupUsers(ctx context.Context, groupID string, request GroupUsersRequest) (*GroupUsersResponse, annotations.Annotations, error)

UpdateGroupUsers adds users to a group using the DocuSign API. Based on API: PUT /restapi/v2.1/accounts/{accountId}/groups/{groupId}/users.

func (*Client) UpdateSigningGroup added in v0.1.1

func (c *Client) UpdateSigningGroup(ctx context.Context, signingGroupID string, request SigningGroupUsersRequest) (*SigningGroupUsersResponse, annotations.Annotations, error)

UpdateSigningGroup updates a signing group by adding users to it. Based on API: PUT /restapi/v2.1/accounts/{accountId}/signing_groups/{signingGroupId}.

func (*Client) UpdateUserProfile added in v0.1.1

func (c *Client) UpdateUserProfile(ctx context.Context, userID string, request UpdateUserProfileRequest) (annotations.Annotations, error)

UpdateUserProfile updates a user's permission profile. Based on API: PUT /restapi/v2.1/accounts/{accountId}/users/{userId}/profile.

type CreateUsersRequest

type CreateUsersRequest struct {
	NewUsers []NewUser `json:"newUsers"`
}

type DeleteUsersRequest added in v0.1.1

type DeleteUsersRequest struct {
	Users []UserIdentifier `json:"users"`
}

DeleteUsersRequest represents a request to delete users from an account.

type DeleteUsersResponse added in v0.1.1

type DeleteUsersResponse struct {
	Users []struct {
		UserId       string `json:"userId"`
		UserName     string `json:"userName"`
		Email        string `json:"email"`
		UserStatus   string `json:"userStatus"`
		Success      string `json:"success"`
		ErrorDetails *struct {
			ErrorCode string `json:"errorCode"`
			Message   string `json:"message"`
		} `json:"errorDetails,omitempty"`
	} `json:"users"`
}

DeleteUsersResponse represents the response from a user deletion request.

type EmailNotifications

type EmailNotifications struct {
	EnvelopeActivation string `json:"envelopeActivation"`
	EnvelopeComplete   string `json:"envelopeComplete"`
	EnvelopeDeclined   string `json:"envelopeDeclined"`
}

type ErrorResponse added in v0.0.5

type ErrorResponse struct {
	ErrorCode    string `json:"errorCode"`
	ErrorMessage string `json:"message"`
}

func (*ErrorResponse) Message added in v0.0.5

func (e *ErrorResponse) Message() string

type Group

type Group struct {
	GroupId    string `json:"groupId"`
	GroupName  string `json:"groupName"`
	GroupType  string `json:"groupType"`
	UsersCount string `json:"usersCount"`
}

type GroupUserIdentifier added in v0.1.1

type GroupUserIdentifier struct {
	UserId string `json:"userId"`
}

GroupUserIdentifier represents a user identifier for group operations.

type GroupUsersRequest added in v0.1.1

type GroupUsersRequest struct {
	Users []GroupUserIdentifier `json:"users"`
}

GroupUsersRequest represents a request to modify group membership (add or remove users).

type GroupUsersResponse added in v0.1.1

type GroupUsersResponse struct {
	Users []struct {
		UserName   string `json:"userName"`
		UserId     string `json:"userId"`
		UserType   string `json:"userType"`
		UserStatus string `json:"userStatus"`
		URI        string `json:"uri"`
	} `json:"users"`
}

GroupUsersResponse represents the response from modifying group membership.

type GroupsResponse

type GroupsResponse struct {
	Page
	Groups []Group `json:"groups"`
}

type NewUser

type NewUser struct {
	UserName     string        `json:"userName"`
	Email        string        `json:"email"`
	UserSettings *UserSettings `json:"userSettings,omitempty"`
}

type OAuth2Docusign

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

OAuth2Docusign manages the OAuth2 configuration and token lifecycle for DocuSign.

func NewOAuth2Docusign

func NewOAuth2Docusign(isDemo bool, clientID, clientSecret, redirectURI string) *OAuth2Docusign

NewOAuth2Docusign initializes a new OAuth2Docusign helper with client credentials.

func (*OAuth2Docusign) Authorize added in v0.1.2

func (o *OAuth2Docusign) Authorize(ctx context.Context) (string, error)

Authorize initiates the OAuth2 authorization code flow and prompts the user to enter the authorization code.

func (*OAuth2Docusign) ExchangeCodeForToken added in v0.1.2

func (o *OAuth2Docusign) ExchangeCodeForToken(ctx context.Context, code string) (*oauth2.Token, error)

ExchangeCodeForToken exchanges an authorization code for an access token and refresh token.

type Page

type Page struct {
	ResultSetSize int `json:"resultSetSize,string"`
	TotalSetSize  int `json:"totalSetSize,string"`
	StartPosition int `json:"startPosition,string"`
	EndPosition   int `json:"endPosition,string"`
}

type PageOptions

type PageOptions struct {
	PageSize  int
	PageToken string
}

type PermissionProfile added in v0.0.3

type PermissionProfile struct {
	PermissionProfileId   string    `json:"permissionProfileId"`
	PermissionProfileName string    `json:"permissionProfileName"`
	ModifiedDateTime      time.Time `json:"modifiedDateTime"`
	ModifiedByUserName    string    `json:"modifiedByUsername"`
}

type PermissionProfilesResponse added in v0.0.3

type PermissionProfilesResponse struct {
	Page
	PermissionProfiles []PermissionProfile `json:"permissionProfiles"`
}

type SigningGroup added in v0.0.3

type SigningGroup struct {
	SigningGroupId string             `json:"signingGroupId"`
	GroupName      string             `json:"groupName"`
	GroupType      string             `json:"groupType"`
	GroupEmail     string             `json:"groupEmail"`
	Created        string             `json:"created"`
	CreatedBy      string             `json:"createdBy"`
	Modified       string             `json:"modified"`
	ModifiedBy     string             `json:"modifiedBy"`
	Users          []SigningGroupUser `json:"users"`
}

type SigningGroupResponse added in v0.0.3

type SigningGroupResponse struct {
	Page
	SigningGroups []SigningGroup `json:"groups"`
}

type SigningGroupUser added in v0.0.3

type SigningGroupUser struct {
	UserID   string `json:"userId,omitempty"`
	UserName string `json:"userName,omitempty"`
	Email    string `json:"email,omitempty"`
}

SigningGroupUser represents a user member of a SigningGroup.

type SigningGroupUserIdentifier added in v0.1.1

type SigningGroupUserIdentifier struct {
	UserName string `json:"userName"`
	Email    string `json:"email"`
}

SigningGroupUserIdentifier represents a user identifier for signing group operations.

type SigningGroupUsersRequest added in v0.1.1

type SigningGroupUsersRequest struct {
	Users []SigningGroupUserIdentifier `json:"users"`
}

SigningGroupUsersRequest represents a request to modify signing group membership (add or remove users).

type SigningGroupUsersResponse added in v0.1.1

type SigningGroupUsersResponse struct {
	SigningGroupId string `json:"signingGroupId"`
	GroupName      string `json:"groupName"`
	GroupType      string `json:"groupType"`
	Created        string `json:"created"`
	CreatedBy      string `json:"createdBy"`
	Modified       string `json:"modified"`
	ModifiedBy     string `json:"modifiedBy"`
	Users          []struct {
		UserName string `json:"userName"`
		Email    string `json:"email"`
	} `json:"users"`
}

SigningGroupUsersResponse represents the response from modifying signing group membership.

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

type UpdateUserProfileRequest added in v0.1.1

type UpdateUserProfileRequest struct {
	UserDetails struct {
		PermissionProfileId string `json:"permissionProfileId"`
	} `json:"userDetails"`
}

UpdateUserProfileRequest represents a request to update a user's permission profile.

type User

type User struct {
	UserId     string `json:"userId"`
	UserName   string `json:"userName"`
	Email      string `json:"email"`
	UserStatus string `json:"userStatus"`
	IsAdmin    string `json:"isAdmin"`
	Permission string `json:"permissionProfileName"`
}

type UserCreationResponse

type UserCreationResponse struct {
	NewUsers []struct {
		UserId          string `json:"userId"`
		URI             string `json:"uri"`
		Email           string `json:"email"`
		UserName        string `json:"userName"`
		UserStatus      string `json:"userStatus"`
		CreatedDateTime string `json:"createdDateTime"`
		MembershipId    string `json:"membershipId"`
		ErrorDetails    *struct {
			ErrorCode string `json:"errorCode"`
			Message   string `json:"message"`
		} `json:"errorDetails,omitempty"`
	} `json:"newUsers"`
}

type UserDetail

type UserDetail struct {
	UserID                string       `json:"userId"`
	UserName              string       `json:"userName"`
	Email                 string       `json:"email"`
	IsAdmin               string       `json:"isAdmin"`
	UserStatus            string       `json:"userStatus"`
	PermissionProfileName string       `json:"permissionProfileName"`
	PermissionProfileID   string       `json:"permissionProfileId"`
	UserSettings          UserSettings `json:"userSettings"`
	GroupList             []Group      `json:"groupList"`
}

type UserIdentifier added in v0.1.1

type UserIdentifier struct {
	UserId string `json:"userId"`
}

UserIdentifier represents a user identifier for deletion operations.

type UserInfoResponse added in v0.0.6

type UserInfoResponse struct {
	Sub      string        `json:"sub"`
	Name     string        `json:"name"`
	Email    string        `json:"email"`
	Accounts []AccountInfo `json:"accounts"`
}

UserInfoResponse represents the response from DocuSign's OAuth User Info endpoint.

type UserSettings

type UserSettings struct {
	CanManageAccount          string             `json:"canManageAccount"`
	AccountManagementGranular AccountManagement  `json:"accountManagementGranular"`
	CanSendEnvelope           string             `json:"canSendEnvelope"`
	CanSignEnvelope           string             `json:"canSignEnvelope"`
	AllowSendOnBehalfOf       string             `json:"allowSendOnBehalfOf"`
	BulkSend                  string             `json:"bulkSend"`
	CanSendAPIRequests        string             `json:"canSendAPIRequests"`
	EnableSequentialSigningUI string             `json:"enableSequentialSigningUI"`
	EnableDSPro               string             `json:"enableDSPro"`
	CanUseScratchpad          string             `json:"canUseScratchpad"`
	CanCreateWorkspaces       string             `json:"canCreateWorkspaces"`
	EnableTransactionPoint    string             `json:"enableTransactionPoint"`
	PowerFormMode             string             `json:"powerFormMode"`
	APICanExportAC            string             `json:"apiCanExportAC"`
	EnableVaulting            string             `json:"enableVaulting"`
	CanManageTemplates        string             `json:"canManageTemplates"`
	CanEditSharedAddressbook  string             `json:"canEditSharedAddressbook"`
	AdminOnly                 string             `json:"adminOnly"`
	CanManageDistributor      string             `json:"canManageDistributor"`
	CanManageOrganization     string             `json:"canManageOrganization"`
	CanUseSmartContracts      string             `json:"canUseSmartContracts"`
	SignerEmailNotifications  EmailNotifications `json:"signerEmailNotifications"`
	SenderEmailNotifications  EmailNotifications `json:"senderEmailNotifications"`
}

type UsersResponse

type UsersResponse struct {
	Page
	Users []User `json:"users"`
}

Jump to

Keyboard shortcuts

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