# `createOrganizationInvitation()`

Creates an invitation for a user to join an Organization.

Returns the newly created [`OrganizationInvitation`](/content/docs/reference/backend/types/backend-organization-invitation/index.html) object.

```
function createOrganizationInvitation(params: CreateOrganizationInvitationParams): Promise<OrganizationInvitation>
```

## [`CreateOrganizationInvitationParams`](/content/docs/reference/backend/organization/create-organization-invitation#create-organization-invitation-params/index.html)

- Name `emailAddress`  
  Type `string`  
  Description  
  The email address of the user being invited.

- Name `expiresInDays?`  
  Type `number`  
  Description  
  The number of days until the invitation expires. Defaults to `30`.

- Name `inviterUserId?`  
  Type `string`  
  Description  
  The ID of the user creating the invitation.

- Name `organizationId`  
  Type `string`  
  Description  
  The ID of the Organization the user is being invited to.

- Name `privateMetadata?`  
  Type [OrganizationInvitationPrivateMetadata](/content/docs/nextjs/reference/types/metadata#organization-invitation-private-metadata/index.html)  
  Description  
  Metadata that can be read and set only from the [Backend API⁠](/content/docs/reference/backend-api/index.html).

- Name `publicMetadata?`  
  Type [OrganizationInvitationPublicMetadata](/content/docs/nextjs/reference/types/metadata#organization-invitation-public-metadata/index.html)  
  Description  
  Metadata that can be read from the Frontend API and [Backend API⁠](/content/docs/reference/backend-api/index.html), but can be set only from the Backend API.

- Name `redirectUrl?`  
  Type `string`  
  Description  
  The full URL or path where the user will land after accepting the invitation.

- Name `role`  
  Type [OrganizationCustomRoleKey](/content/docs/nextjs/reference/types/organization-custom-role-key/index.html)  
  Description  
  The [Role](/content/docs/guides/organizations/control-access/roles-and-permissions/index.html) to assign to the user.

## [Usage](/content/docs/reference/backend/organization/create-organization-invitation#usage/index.html)

Using `clerkClient` varies based on the SDK you're using. Refer to the [overview](/content/docs/reference/backend/overview/index.html) for usage details, including guidance on [how to access the `userId` and other properties](/content/docs/reference/backend/overview#example-get-the-user-id-and-other-properties/index.html).

```
const organizationId = 'org_123'
const inviterUserId = 'user_123'
const emailAddress = 'testclerk123@clerk.dev'
const role = 'org:member'

const response = await clerkClient.organizations.createOrganizationInvitation({
  organizationId,
  inviterUserId,
  emailAddress,
  role,
})
```

## [Backend API (BAPI) endpoint](/content/docs/reference/backend/organization/create-organization-invitation#backend-api-bapi-endpoint/index.html)

This method in the SDK is a wrapper around the BAPI endpoint `POST/organizations/{organization_id}/invitations`. See the [BAPI reference⁠](/content/docs/reference/backend-api/tag/organization-invitations/POST/organizations/%7Borganization_id%7D/invitations/index.html) for more information.
