# Organizations ## List Organizations `client.User.Organizations.List(ctx, query) (*V4PagePaginationArray[Organization], error)` **get** `/user/organizations` Lists organizations the user is associated with. ### Parameters - `query OrganizationListParams` - `Direction param.Field[OrganizationListParamsDirection]` Direction to order organizations. - `const OrganizationListParamsDirectionAsc OrganizationListParamsDirection = "asc"` - `const OrganizationListParamsDirectionDesc OrganizationListParamsDirection = "desc"` - `Match param.Field[OrganizationListParamsMatch]` Whether to match all search requirements or at least one (any). - `const OrganizationListParamsMatchAny OrganizationListParamsMatch = "any"` - `const OrganizationListParamsMatchAll OrganizationListParamsMatch = "all"` - `Name param.Field[string]` Organization name. - `Order param.Field[OrganizationListParamsOrder]` Field to order organizations by. - `const OrganizationListParamsOrderID OrganizationListParamsOrder = "id"` - `const OrganizationListParamsOrderName OrganizationListParamsOrder = "name"` - `const OrganizationListParamsOrderStatus OrganizationListParamsOrder = "status"` - `Page param.Field[float64]` Page number of paginated results. - `PerPage param.Field[float64]` Number of organizations per page. - `Status param.Field[OrganizationListParamsStatus]` Whether the user is a member of the organization or has an inivitation pending. - `const OrganizationListParamsStatusMember OrganizationListParamsStatus = "member"` - `const OrganizationListParamsStatusInvited OrganizationListParamsStatus = "invited"` ### Returns - `type Organization struct{…}` - `ID string` Identifier - `Name string` Organization name. - `Permissions []Permission` Access permissions for this User. - `Roles []string` List of roles that a user has within an organization. - `Status Status` Whether the user is a member of the organization or has an invitation pending. - `const StatusMember Status = "member"` - `const StatusInvited Status = "invited"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/user" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) page, err := client.User.Organizations.List(context.TODO(), user.OrganizationListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "023e105f4ecef8ad9ca31a8372d0c353", "name": "Cloudflare, Inc.", "permissions": [ "#zones:read" ], "roles": [ "All Privileges - Super Administrator" ], "status": "member" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Organization Details `client.User.Organizations.Get(ctx, organizationID) (*OrganizationGetResponse, error)` **get** `/user/organizations/{organization_id}` Gets a specific organization the user is associated with. ### Parameters - `organizationID string` Identifier ### Returns - `type OrganizationGetResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organization, err := client.User.Organizations.Get(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organization) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": {} } ``` ## Leave Organization `client.User.Organizations.Delete(ctx, organizationID) (*OrganizationDeleteResponse, error)` **delete** `/user/organizations/{organization_id}` Removes association to an organization. ### Parameters - `organizationID string` Identifier ### Returns - `type OrganizationDeleteResponse struct{…}` - `ID string` Identifier ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) organization, err := client.User.Organizations.Delete(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", organization.ID) } ``` #### Response ```json { "id": "023e105f4ecef8ad9ca31a8372d0c353" } ``` ## Domain Types ### Organization - `type Organization struct{…}` - `ID string` Identifier - `Name string` Organization name. - `Permissions []Permission` Access permissions for this User. - `Roles []string` List of roles that a user has within an organization. - `Status Status` Whether the user is a member of the organization or has an invitation pending. - `const StatusMember Status = "member"` - `const StatusInvited Status = "invited"`