Comprehensive organization management including settings, members, teams, webhooks, and organization-level resources.
The OrganizationsService provides 119 methods for organization management.
type OrganizationsService struct{}// Get fetches an organization by name
func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organization, *Response, error)
// GetByID fetches an organization by ID
func (s *OrganizationsService) GetByID(ctx context.Context, id int64) (*Organization, *Response, error)
// List organizations for a user
func (s *OrganizationsService) List(ctx context.Context, user string, opts *ListOptions) ([]*Organization, *Response, error)
// ListAll lists all organizations (admin only)
func (s *OrganizationsService) ListAll(ctx context.Context, opts *OrganizationsListOptions) ([]*Organization, *Response, error)// Edit an organization
func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error)
type Organization struct {
Login *string `json:"login,omitempty"`
ID *int64 `json:"id,omitempty"`
NodeID *string `json:"node_id,omitempty"`
AvatarURL *string `json:"avatar_url,omitempty"`
HTMLURL *string `json:"html_url,omitempty"`
Name *string `json:"name,omitempty"`
Company *string `json:"company,omitempty"`
Blog *string `json:"blog,omitempty"`
Location *string `json:"location,omitempty"`
Email *string `json:"email,omitempty"`
TwitterUsername *string `json:"twitter_username,omitempty"`
Description *string `json:"description,omitempty"`
PublicRepos *int `json:"public_repos,omitempty"`
PublicGists *int `json:"public_gists,omitempty"`
Followers *int `json:"followers,omitempty"`
Following *int `json:"following,omitempty"`
CreatedAt *Timestamp `json:"created_at,omitempty"`
UpdatedAt *Timestamp `json:"updated_at,omitempty"`
TotalPrivateRepos *int64 `json:"total_private_repos,omitempty"`
OwnedPrivateRepos *int64 `json:"owned_private_repos,omitempty"`
PrivateGists *int `json:"private_gists,omitempty"`
DiskUsage *int `json:"disk_usage,omitempty"`
Collaborators *int `json:"collaborators,omitempty"`
BillingEmail *string `json:"billing_email,omitempty"`
Type *string `json:"type,omitempty"`
Plan *Plan `json:"plan,omitempty"`
TwoFactorRequirementEnabled *bool `json:"two_factor_requirement_enabled,omitempty"`
IsVerified *bool `json:"is_verified,omitempty"`
HasOrganizationProjects *bool `json:"has_organization_projects,omitempty"`
HasRepositoryProjects *bool `json:"has_repository_projects,omitempty"`
// DefaultRepoPermission can be one of: "read", "write", "admin", or "none" (Default: "read")
// Only used in OrganizationsService.Edit
DefaultRepoPermission *string `json:"default_repository_permission,omitempty"`
// DefaultRepoSettings can be one of: "read", "write", "admin", or "none" (Default: "read")
// Only used in OrganizationsService.Get
DefaultRepoSettings *string `json:"default_repository_settings,omitempty"`
// MembersCanCreateRepos default value is true, only used in Organizations.Edit
MembersCanCreateRepos *bool `json:"members_can_create_repositories,omitempty"`
MembersCanCreatePublicRepos *bool `json:"members_can_create_public_repositories,omitempty"`
MembersCanCreatePrivateRepos *bool `json:"members_can_create_private_repositories,omitempty"`
MembersCanCreateInternalRepos *bool `json:"members_can_create_internal_repositories,omitempty"`
// MembersCanForkPrivateRepos toggles whether organization members can fork private repositories
MembersCanForkPrivateRepos *bool `json:"members_can_fork_private_repositories,omitempty"`
// MembersAllowedRepositoryCreationType: Possible values are "all", "private", or "none"
// Deprecated: Use MembersCanCreatePublicRepos, MembersCanCreatePrivateRepos, MembersCanCreateInternalRepos
MembersAllowedRepositoryCreationType *string `json:"members_allowed_repository_creation_type,omitempty"`
MembersCanCreatePages *bool `json:"members_can_create_pages,omitempty"`
MembersCanCreatePublicPages *bool `json:"members_can_create_public_pages,omitempty"`
MembersCanCreatePrivatePages *bool `json:"members_can_create_private_pages,omitempty"`
WebCommitSignoffRequired *bool `json:"web_commit_signoff_required,omitempty"`
// Security and dependency settings for new repositories
AdvancedSecurityEnabledForNewRepos *bool `json:"advanced_security_enabled_for_new_repositories,omitempty"`
DependabotAlertsEnabledForNewRepos *bool `json:"dependabot_alerts_enabled_for_new_repositories,omitempty"`
DependabotSecurityUpdatesEnabledForNewRepos *bool `json:"dependabot_security_updates_enabled_for_new_repositories,omitempty"`
DependencyGraphEnabledForNewRepos *bool `json:"dependency_graph_enabled_for_new_repositories,omitempty"`
SecretScanningEnabledForNewRepos *bool `json:"secret_scanning_enabled_for_new_repositories,omitempty"`
SecretScanningPushProtectionEnabledForNewRepos *bool `json:"secret_scanning_push_protection_enabled_for_new_repositories,omitempty"`
SecretScanningValidityChecksEnabled *bool `json:"secret_scanning_validity_checks_enabled,omitempty"`
// Member permissions
MembersCanDeleteRepositories *bool `json:"members_can_delete_repositories,omitempty"`
MembersCanChangeRepoVisibility *bool `json:"members_can_change_repo_visibility,omitempty"`
MembersCanInviteOutsideCollaborators *bool `json:"members_can_invite_outside_collaborators,omitempty"`
MembersCanDeleteIssues *bool `json:"members_can_delete_issues,omitempty"`
DisplayCommenterFullNameSettingEnabled *bool `json:"display_commenter_full_name_setting_enabled,omitempty"`
ReadersCanCreateDiscussions *bool `json:"readers_can_create_discussions,omitempty"`
MembersCanCreateTeams *bool `json:"members_can_create_teams,omitempty"`
MembersCanViewDependencyInsights *bool `json:"members_can_view_dependency_insights,omitempty"`
DefaultRepositoryBranch *string `json:"default_repository_branch,omitempty"`
// API URLs
URL *string `json:"url,omitempty"`
EventsURL *string `json:"events_url,omitempty"`
HooksURL *string `json:"hooks_url,omitempty"`
IssuesURL *string `json:"issues_url,omitempty"`
MembersURL *string `json:"members_url,omitempty"`
PublicMembersURL *string `json:"public_members_url,omitempty"`
ReposURL *string `json:"repos_url,omitempty"`
}// ListMembers lists members of an organization
func (s *OrganizationsService) ListMembers(ctx context.Context, org string, opts *ListMembersOptions) ([]*User, *Response, error)
// IsMember checks if a user is a member of an organization
func (s *OrganizationsService) IsMember(ctx context.Context, org, user string) (bool, *Response, error)
// IsPublicMember checks if a user is a public member of an organization
func (s *OrganizationsService) IsPublicMember(ctx context.Context, org, user string) (bool, *Response, error)
// GetOrgMembership gets organization membership for a user
func (s *OrganizationsService) GetOrgMembership(ctx context.Context, user, org string) (*Membership, *Response, error)
// ListOrgMemberships lists organization memberships for the authenticated user
func (s *OrganizationsService) ListOrgMemberships(ctx context.Context, opts *ListOrgMembershipsOptions) ([]*Membership, *Response, error)
type ListMembersOptions struct {
PublicOnly bool
Filter string // "2fa_disabled", "all"
Role string // "all", "admin", "member"
ListOptions
}// RemoveMember removes a user from the organization
func (s *OrganizationsService) RemoveMember(ctx context.Context, org, user string) (*Response, error)
// PublicizeMembership publicizes a user's membership in an organization
func (s *OrganizationsService) PublicizeMembership(ctx context.Context, org, user string) (*Response, error)
// ConcealMembership conceals a user's membership in an organization
func (s *OrganizationsService) ConcealMembership(ctx context.Context, org, user string) (*Response, error)
// EditOrgMembership edits the membership for a user in an organization
func (s *OrganizationsService) EditOrgMembership(ctx context.Context, user, org string, membership *Membership) (*Membership, *Response, error)
// RemoveOrgMembership removes a user's membership from an organization
func (s *OrganizationsService) RemoveOrgMembership(ctx context.Context, user, org string) (*Response, error)
type Membership struct {
URL *string
State *string // "active", "pending"
Role *string // "admin", "member"
OrganizationURL *string
Organization *Organization
User *User
}// ListPendingOrgInvitations lists pending organization invitations
func (s *OrganizationsService) ListPendingOrgInvitations(ctx context.Context, org string, opts *ListOptions) ([]*Invitation, *Response, error)
// ListFailedOrgInvitations lists failed organization invitation attempts
func (s *OrganizationsService) ListFailedOrgInvitations(ctx context.Context, org string, opts *ListOptions) ([]*Invitation, *Response, error)
// CreateOrgInvitation creates an invitation to join an organization
func (s *OrganizationsService) CreateOrgInvitation(ctx context.Context, org string, opts *CreateOrgInvitationOptions) (*Invitation, *Response, error)
// CancelOrgInvitation cancels an organization invitation
func (s *OrganizationsService) CancelOrgInvitation(ctx context.Context, org string, invitationID int64) (*Response, error)// ListHooks lists hooks for an organization
func (s *OrganizationsService) ListHooks(ctx context.Context, org string, opts *ListOptions) ([]*Hook, *Response, error)
// GetHook gets a single organization hook
func (s *OrganizationsService) GetHook(ctx context.Context, org string, id int64) (*Hook, *Response, error)
// CreateHook creates a hook for the specified organization
func (s *OrganizationsService) CreateHook(ctx context.Context, org string, hook *Hook) (*Hook, *Response, error)
// EditHook updates an organization hook
func (s *OrganizationsService) EditHook(ctx context.Context, org string, id int64, hook *Hook) (*Hook, *Response, error)
// DeleteHook deletes an organization hook
func (s *OrganizationsService) DeleteHook(ctx context.Context, org string, id int64) (*Response, error)
// PingHook triggers a 'ping' event to be sent to the hook
func (s *OrganizationsService) PingHook(ctx context.Context, org string, id int64) (*Response, error)// ListProjects lists projects for an organization
func (s *OrganizationsService) ListProjects(ctx context.Context, org string, opts *ProjectListOptions) ([]*Project, *Response, error)
// CreateProject creates an organization project
func (s *OrganizationsService) CreateProject(ctx context.Context, org string, opts *ProjectOptions) (*Project, *Response, error)// GetActionsPublicKey gets a public key for organization secrets encryption
func (s *OrganizationsService) GetActionsPublicKey(ctx context.Context, org string) (*PublicKey, *Response, error)
// ListActionsSecrets lists all organization secrets
func (s *OrganizationsService) ListActionsSecrets(ctx context.Context, org string, opts *ListOptions) (*Secrets, *Response, error)
// GetActionsSecret gets an organization secret
func (s *OrganizationsService) GetActionsSecret(ctx context.Context, org, name string) (*Secret, *Response, error)
// CreateOrUpdateActionsSecret creates or updates an organization secret
func (s *OrganizationsService) CreateOrUpdateActionsSecret(ctx context.Context, org string, eSecret *EncryptedSecret) (*Response, error)
// DeleteActionsSecret deletes an organization secret
func (s *OrganizationsService) DeleteActionsSecret(ctx context.Context, org, name string) (*Response, error)// ListOutsideCollaborators lists outside collaborators of an organization
func (s *OrganizationsService) ListOutsideCollaborators(ctx context.Context, org string, opts *ListOutsideCollaboratorsOptions) ([]*User, *Response, error)
// RemoveOutsideCollaborator removes a user as an outside collaborator
func (s *OrganizationsService) RemoveOutsideCollaborator(ctx context.Context, org, user string) (*Response, error)
// ConvertMemberToOutsideCollaborator converts an organization member to an outside collaborator
func (s *OrganizationsService) ConvertMemberToOutsideCollaborator(ctx context.Context, org, user string) (*Response, error)// GetAuditLog gets the audit log for an organization
func (s *OrganizationsService) GetAuditLog(ctx context.Context, org string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error)
// GetCredentialAuthorizations lists credential authorizations for an organization
func (s *OrganizationsService) GetCredentialAuthorizations(ctx context.Context, org string, opts *ListOptions) ([]*CredentialAuthorization, *Response, error)
// RevokeCredentialAuthorization revokes a credential authorization
func (s *OrganizationsService) RevokeCredentialAuthorization(ctx context.Context, org string, credentialID int64) (*Response, error)// ListBlockedUsers lists users blocked by the organization
func (s *OrganizationsService) ListBlockedUsers(ctx context.Context, org string, opts *ListOptions) ([]*User, *Response, error)
// IsBlocked checks if a user is blocked by the organization
func (s *OrganizationsService) IsBlocked(ctx context.Context, org, user string) (bool, *Response, error)
// BlockUser blocks a user from the organization
func (s *OrganizationsService) BlockUser(ctx context.Context, org, user string) (*Response, error)
// UnblockUser unblocks a user from the organization
func (s *OrganizationsService) UnblockUser(ctx context.Context, org, user string) (*Response, error)// ListCustomRepoRoles lists all custom repository roles available in the organization
func (s *OrganizationsService) ListCustomRepoRoles(ctx context.Context, org string) (*OrganizationCustomRepoRoles, *Response, error)
// CreateCustomRepoRole creates a custom repository role in the organization
func (s *OrganizationsService) CreateCustomRepoRole(ctx context.Context, org string, opts *CreateOrUpdateCustomRepoRoleOptions) (*CustomRepoRoles, *Response, error)
// UpdateCustomRepoRole updates a custom repository role in the organization
func (s *OrganizationsService) UpdateCustomRepoRole(ctx context.Context, org string, roleID int64, opts *CreateOrUpdateCustomRepoRoleOptions) (*CustomRepoRoles, *Response, error)
// DeleteCustomRepoRole deletes a custom repository role in the organization
func (s *OrganizationsService) DeleteCustomRepoRole(ctx context.Context, org string, roleID int64) (*Response, error)// GetDefaultWorkflowPermissions gets the default workflow permissions
func (s *OrganizationsService) GetDefaultWorkflowPermissions(ctx context.Context, org string) (*DefaultWorkflowPermissionOrganization, *Response, error)
// EditDefaultWorkflowPermissions edits the default workflow permissions
func (s *OrganizationsService) EditDefaultWorkflowPermissions(ctx context.Context, org string, permissions DefaultWorkflowPermissionOrganization) (*DefaultWorkflowPermissionOrganization, *Response, error)
// GetPackageVersion gets a package version for an organization
func (s *OrganizationsService) GetPackageVersion(ctx context.Context, org, packageType, packageName string, packageVersionID int64) (*PackageVersion, *Response, error)