Invitation Error Codes
The invitation API throws specific errors when operations fail. This table summarizes the most common error codes.
Error Code Reference
| Code | Scenario |
|---|---|
| 400 BAD_REQUEST | Missing required fields or invalid ID |
| 404 NOT_FOUND | Invitation not found or not in the expected state |
| 409 CONFLICT | Duplicate token when creating an invitation |
| 500 INTERNAL_SERVER_ERROR | Unexpected database failure |
Lifecycle Operations
Lifecycle operations have specific error behaviors:
Soft Delete
DELETE /invitations/:id
- 404: Invitation not found
- 400: Invitation already deleted
Restore
POST /invitations/:id/restore
- 404: Invitation not found
- 400: Invitation is not deleted (cannot restore)
Permanent Delete
DELETE /invitations/:id/permanent
- 404: Invitation not found
- 400: Invitation must be soft-deleted first
Common Scenarios
Creating an Invitation
// Error: 409 CONFLICT
{
"statusCode": 409,
"message": "Invitation with this token already exists",
"error": "Conflict"
}
Accepting an Expired Invitation
// Error: 400 BAD_REQUEST
{
"statusCode": 400,
"message": "Invitation has expired",
"error": "Bad Request"
}
Accessing a Deleted Invitation
// Error: 404 NOT_FOUND
{
"statusCode": 404,
"message": "Invitation not found",
"error": "Not Found"
}
Troubleshooting
- Token conflicts: Ensure invitation tokens are unique. The system generates UUIDs by default.
- State transitions: Follow the invitation lifecycle: pending → accepted/declined/expired → deleted.
- Permission errors: Verify the user has
INVITATION_MGMTcapabilities.