> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Two-Factor Challenge Email Code

> Sends a two-factor authentication code by email for an in-progress login challenge. Use this endpoint after a login attempt returns a `challengeId` for the email two-factor method, to deliver a fresh code to the user.

The endpoint does not require an authenticated session. It is rate-limited to 5 requests per minute per caller. The challenge must exist, must not be expired, and must use the `email` method.

### Changelog
| Version | Description |
| ------- | ----------- |
| 8.5.0   | Added       |

## OpenAPI

````json POST /api/v1/twoFactorChallenges.sendEmailCode
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Authentication"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "Authentication"
    },
    {
      "name": "Two-Factor Authentication"
    }
  ],
  "paths": {
    "/api/v1/twoFactorChallenges.sendEmailCode": {
      "post": {
        "tags": [
          "Two-Factor Authentication"
        ],
        "summary": "Send Two-Factor Challenge Email Code",
        "description": "Sends a two-factor authentication code by email for an in-progress login challenge. Use this endpoint after a login attempt returns a `challengeId` for the email two-factor method, to deliver a fresh code to the user.\n\nThe endpoint does not require an authenticated session. It is rate-limited to 5 requests per minute per caller. The challenge must exist, must not be expired, and must use the `email` method.\n\n### Changelog\n| Version | Description |\n| ------- | ----------- |\n| 8.5.0   | Added       |",
        "operationId": "post-api-v1-twoFactorChallenges.sendEmailCode",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "challengeId": {
                    "type": "string",
                    "description": "The ID of the pending two-factor challenge returned by the login flow.",
                    "example": "8f4c2d1e9a7b6c5d3e2f1a0b"
                  }
                },
                "required": [
                  "challengeId"
                ]
              },
              "examples": {
                "Example 1": {
                  "value": {
                    "challengeId": "8f4c2d1e9a7b6c5d3e2f1a0b"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/trueSuccess"
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "errorType": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "Missing challengeId": {
                    "value": {
                      "success": "false",
                      "error": "challengeId is required",
                      "errorType": "error-parameter-required"
                    }
                  },
                  "Challenge not found": {
                    "value": {
                      "success": "false",
                      "error": "challenge not found",
                      "errorType": "error-challenge-not-found"
                    }
                  },
                  "Challenge expired": {
                    "value": {
                      "success": "false",
                      "error": "challenge expired",
                      "errorType": "error-challenge-expired"
                    }
                  },
                  "Invalid challenge method": {
                    "value": {
                      "success": "false",
                      "error": "invalid challenge method",
                      "errorType": "error-invalid-challenge-method"
                    }
                  },
                  "User not found": {
                    "value": {
                      "success": "false",
                      "error": "user not found",
                      "errorType": "error-user-not-found"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "trueSuccess": {
        "description": "OK",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean"
                }
              },
              "x-examples": {
                "Success": {
                  "success": "true"
                }
              }
            },
            "examples": {
              "Success": {
                "value": {
                  "success": "true"
                }
              }
            }
          }
        }
      }
    }
  }
}
````

