# OrganizationInvitation

The `OrganizationInvitation` object is the model around an Organization invitation.

## Properties

| Name           | Type                                 | Description                                                                                               |
| -------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------- |
| id             | string                               | The unique identifier for this Organization invitation.                                                   |
| emailAddress   | string                               | The email address the invitation has been sent to.                                                        |
| organizationId | string                               | The Organization ID of the Organization this invitation is for.                                           |
| publicMetadata | OrganizationInvitationPublicMetadata | Metadata that can be read from the Frontend API and Backend API and can be set only from the Backend API. |
| role           | OrganizationCustomRoleKey            | The Role of the current user in the Organization.                                                         |
| status         | 'pending' | 'accepted' | 'revoked' | The status of the invitation.                                                                             |
| createdAt      | Date                                 | The date when the invitation was created.                                                                 |
| updatedAt      | Date                                 | The date when the invitation was last updated.                                                            |

## Methods

### `revoke()`

Revokes the invitation for the email it corresponds to.

```typescript
function revoke(): Promise<OrganizationInvitation>
```

### Example

The following example demonstrates how to revoke an Organization invitation. It first gets the list of Organization invitations using [getInvitations()](https://clerk.com/docs/astro/reference/objects/organization.md#get-invitations) and then revokes the first invitation in the list.

It assumes:

- you have followed the [quickstart](https://clerk.com/docs/js-frontend/getting-started/quickstart.md) in order to add Clerk to your JavaScript application
- you have [enabled the Organizations feature in the Clerk Dashboard](https://clerk.com/docs/guides/organizations/configure.md?sdk=astro#enable-organizations)

  filename: main.js

  ```js
  import { Clerk } from '@clerk/clerk-js'

  const pubKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY

  const clerk = new Clerk(pubKey)
  await clerk.load()

  if (clerk.isSignedIn) {
    // Check for an Active Organization
    if (clerk.organization) {
      // Get list of organization invitations
      const { totalCount, data } = await clerk.organization.getInvitations()

      const invitations = data
      console.log(`Invitations:`, invitations)

      if (invitations.length === 0) {
        console.log('No invitations to revoke.')
      }

      // Revoke the first invitation in the list
      invitations[0]
        .revoke()
        .then((res) => console.log(res))
        .catch((error) => console.log(error.errors))
    } else {
      // If there is no Active Organization,
      // mount Clerk's <OrganizationSwitcher />
      // to allow the user to set an organization as active
      document.getElementById('app').innerHTML = `
        <h2>Select an organization to set it as active</h2>
        <div id="org-switcher"></div>
      `

      const orgSwitcherDiv = document.getElementById('org-switcher')

      clerk.mountOrganizationSwitcher(orgSwitcherDiv)
    }
  } else {
    document.getElementById('app').innerHTML = `
      <div id="sign-in"></div>
    `

    const signInDiv = document.getElementById('sign-in')

    clerk.mountSignIn(signInDiv)
  }
  ```

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
