# Invites ## List Invitations `client.User.Invites.List(ctx) (*SinglePage[Invite], error)` **get** `/user/invites` Lists all invitations associated with my user. ### Returns - `type Invite struct{…}` - `InvitedMemberID string` ID of the user to add to the organization. - `OrganizationID string` ID of the organization the user will be added to. - `ID string` Invite identifier tag. - `ExpiresOn Time` When the invite is no longer active. - `InvitedBy string` The email address of the user who created the invite. - `InvitedMemberEmail string` Email address of the user to add to the organization. - `InvitedOn Time` When the invite was sent. - `OrganizationIsEnforcingTwofactor bool` - `OrganizationName string` Organization name. - `Roles []string` List of role names the membership has for this account. - `Status InviteStatus` Current status of the invitation. - `const InviteStatusPending InviteStatus = "pending"` - `const InviteStatusAccepted InviteStatus = "accepted"` - `const InviteStatusRejected InviteStatus = "rejected"` - `const InviteStatusExpired InviteStatus = "expired"` ### 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"), ) page, err := client.User.Invites.List(context.TODO()) 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": [ { "invited_member_id": "5a7805061c76ada191ed06f989cc3dac", "organization_id": "5a7805061c76ada191ed06f989cc3dac", "id": "4f5f0c14a2a41d5063dd301b2f829f04", "expires_on": "2014-01-01T05:20:00Z", "invited_by": "user@example.com", "invited_member_email": "user@example.com", "invited_on": "2014-01-01T05:20:00Z", "organization_is_enforcing_twofactor": true, "organization_name": "Cloudflare, Inc.", "roles": [ "Account Administrator" ], "status": "accepted" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000 } } ``` ## Invitation Details `client.User.Invites.Get(ctx, inviteID) (*Invite, error)` **get** `/user/invites/{invite_id}` Gets the details of an invitation. ### Parameters - `inviteID string` Invite identifier tag. ### Returns - `type Invite struct{…}` - `InvitedMemberID string` ID of the user to add to the organization. - `OrganizationID string` ID of the organization the user will be added to. - `ID string` Invite identifier tag. - `ExpiresOn Time` When the invite is no longer active. - `InvitedBy string` The email address of the user who created the invite. - `InvitedMemberEmail string` Email address of the user to add to the organization. - `InvitedOn Time` When the invite was sent. - `OrganizationIsEnforcingTwofactor bool` - `OrganizationName string` Organization name. - `Roles []string` List of role names the membership has for this account. - `Status InviteStatus` Current status of the invitation. - `const InviteStatusPending InviteStatus = "pending"` - `const InviteStatusAccepted InviteStatus = "accepted"` - `const InviteStatusRejected InviteStatus = "rejected"` - `const InviteStatusExpired InviteStatus = "expired"` ### 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"), ) invite, err := client.User.Invites.Get(context.TODO(), "4f5f0c14a2a41d5063dd301b2f829f04") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", invite.InvitedMemberID) } ``` #### 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": { "invited_member_id": "5a7805061c76ada191ed06f989cc3dac", "organization_id": "5a7805061c76ada191ed06f989cc3dac", "id": "4f5f0c14a2a41d5063dd301b2f829f04", "expires_on": "2014-01-01T05:20:00Z", "invited_by": "user@example.com", "invited_member_email": "user@example.com", "invited_on": "2014-01-01T05:20:00Z", "organization_is_enforcing_twofactor": true, "organization_name": "Cloudflare, Inc.", "roles": [ "Account Administrator" ], "status": "accepted" } } ``` ## Respond to Invitation `client.User.Invites.Edit(ctx, inviteID, body) (*Invite, error)` **patch** `/user/invites/{invite_id}` Responds to an invitation. ### Parameters - `inviteID string` Invite identifier tag. - `body InviteEditParams` - `Status param.Field[InviteEditParamsStatus]` Status of your response to the invitation (rejected or accepted). - `const InviteEditParamsStatusAccepted InviteEditParamsStatus = "accepted"` - `const InviteEditParamsStatusRejected InviteEditParamsStatus = "rejected"` ### Returns - `type Invite struct{…}` - `InvitedMemberID string` ID of the user to add to the organization. - `OrganizationID string` ID of the organization the user will be added to. - `ID string` Invite identifier tag. - `ExpiresOn Time` When the invite is no longer active. - `InvitedBy string` The email address of the user who created the invite. - `InvitedMemberEmail string` Email address of the user to add to the organization. - `InvitedOn Time` When the invite was sent. - `OrganizationIsEnforcingTwofactor bool` - `OrganizationName string` Organization name. - `Roles []string` List of role names the membership has for this account. - `Status InviteStatus` Current status of the invitation. - `const InviteStatusPending InviteStatus = "pending"` - `const InviteStatusAccepted InviteStatus = "accepted"` - `const InviteStatusRejected InviteStatus = "rejected"` - `const InviteStatusExpired InviteStatus = "expired"` ### 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"), ) invite, err := client.User.Invites.Edit( context.TODO(), "4f5f0c14a2a41d5063dd301b2f829f04", user.InviteEditParams{ Status: cloudflare.F(user.InviteEditParamsStatusAccepted), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", invite.InvitedMemberID) } ``` #### 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": { "invited_member_id": "5a7805061c76ada191ed06f989cc3dac", "organization_id": "5a7805061c76ada191ed06f989cc3dac", "id": "4f5f0c14a2a41d5063dd301b2f829f04", "expires_on": "2014-01-01T05:20:00Z", "invited_by": "user@example.com", "invited_member_email": "user@example.com", "invited_on": "2014-01-01T05:20:00Z", "organization_is_enforcing_twofactor": true, "organization_name": "Cloudflare, Inc.", "roles": [ "Account Administrator" ], "status": "accepted" } } ``` ## Domain Types ### Invite - `type Invite struct{…}` - `InvitedMemberID string` ID of the user to add to the organization. - `OrganizationID string` ID of the organization the user will be added to. - `ID string` Invite identifier tag. - `ExpiresOn Time` When the invite is no longer active. - `InvitedBy string` The email address of the user who created the invite. - `InvitedMemberEmail string` Email address of the user to add to the organization. - `InvitedOn Time` When the invite was sent. - `OrganizationIsEnforcingTwofactor bool` - `OrganizationName string` Organization name. - `Roles []string` List of role names the membership has for this account. - `Status InviteStatus` Current status of the invitation. - `const InviteStatusPending InviteStatus = "pending"` - `const InviteStatusAccepted InviteStatus = "accepted"` - `const InviteStatusRejected InviteStatus = "rejected"` - `const InviteStatusExpired InviteStatus = "expired"`