Create organization invitation

POST /api/organization-invitations

Create an organization invitation and optionally send it via email. The tenant should have an email connector configured if you want to send the invitation via email at this point.

application/json

Body Required

The organization invitation to create.

  • inviterId string | null

    The ID of the user who is inviting the user to join the organization.

    Maximum length is 21.

  • invitee string(email) Required

    The email address of the user to invite to join the organization.

  • organizationId string Required

    The ID of the organization to invite the user to join.

    Minimum length is 1, maximum length is 21.

  • expiresAt number Required

    The epoch time in milliseconds when the invitation expires.

  • organizationRoleIds array[string]

    The IDs of the organization roles to assign to the user when they accept the invitation.

  • messagePayload object | boolean(false) Required

    The message payload for the "OrganizationInvitation" template to use when sending the invitation via email. If it is false, the invitation will not be sent via email.

    One of:

    Default value is false.

Responses

  • 201 application/json

    The organization invitation was created successfully.

    Hide response attributes Show response attributes object
  • The organization invitation could not be created. This can happen if the input is invalid or if the expiration date is in the past.

  • Unauthorized

  • Forbidden

  • Unprocessable Content

  • No email connector is configured for the tenant.

POST /api/organization-invitations
curl \
 -X POST https://[tenant_id].logto.app/api/organization-invitations \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{"inviterId":"string","invitee":"hello@example.com","organizationId":"string","expiresAt":42.0,"organizationRoleIds":["string"],"messagePayload":{"code":"string","link":"string","additionalProperty1":"string","additionalProperty2":"string"}}'
Request examples
{
  "inviterId": "string",
  "invitee": "hello@example.com",
  "organizationId": "string",
  "expiresAt": 42.0,
  "organizationRoleIds": [
    "string"
  ],
  "messagePayload": {
    "code": "string",
    "link": "string",
    "additionalProperty1": "string",
    "additionalProperty2": "string"
  }
}
Response examples (201)
{
  "tenantId": "string",
  "id": "string",
  "inviterId": "string",
  "invitee": "string",
  "acceptedUserId": "string",
  "organizationId": "string",
  "status": "Pending",
  "createdAt": 42.0,
  "updatedAt": 42.0,
  "expiresAt": 42.0,
  "organizationRoles": [
    {
      "id": "string",
      "name": "string"
    }
  ]
}