rough-kilobyte-98919
08/14/2025, 7:27 AM60123456789
which should be a valid phone number, and it return is not valid \“tel\”brief-egg-61061
08/14/2025, 7:27 AMbrief-egg-61061
08/14/2025, 7:27 AM"format": "tel"
field in the identity schema to validate phone numbers. This validation is performed using the Go port of Google's [libphonenumber](https://github.com/google/libphonenumber) library, which is a widely used standard for phone number validation. The relevant documentation states: > By using the "format": "tel"
field we enable validation of phone numbers using the Golang port of Google's libphonenumber. This means that the phone number you provide (e.g., 60123456789
) must be in a format recognized as valid by libphonenumber. Typically, libphonenumber expects phone numbers in E.164 format, which usually starts with a +
followed by the country code and the subscriber number (e.g., +60123456789
for Malaysia). If you input 60123456789
(without the +
), it may not be recognized as valid. Try using the E.164 format: +60123456789
instead. If you continue to experience issues, ensure that your schema is correctly set up with "format": "tel"
for the phone trait and that the input matches the expected format for your country code and number length as per libphonenumber's rules [Phone number](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#phone-number).rough-kilobyte-98919
08/14/2025, 7:43 AMExpected sms template but got <nil>
brief-egg-61061
08/14/2025, 7:43 AMbrief-egg-61061
08/14/2025, 7:44 AMExpected sms template but got <nil>
typically means that Ory Kratos is trying to send an SMS (for example, for verification, login, or recovery), but it cannot find a configured SMS template for the message type it needs to send. To resolve this, you need to ensure that you have configured the required SMS templates in your Ory Identities configuration. Only the recovery_code
, verification_code
, and login_code
templates support an SMS variant. Here’s how you can add them: 1. Download your Ory Identities config. 2. Add the SMS templates under the courier.templates
section. For example: yaml courier: templates: verification_code: valid: sms: body: plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>=" login_code: valid: sms: body: plaintext: "<base64://WW91ciBsb2dpbiBjb2RlIGlzOiB7eyAuTG9naW5Db2RlIH19>" recovery_code: valid: sms: body: plaintext: "<base64://WW91ciByZWNvdmVyeSBjb2RlIGlzOiB7eyAuUmVjb3ZlcnlDb2RlIH19CgpAe3sgLlJlcXVlc3RVUkxEb21haW4gfX0gI3t7IC5SZWNvdmVyeUNvZGUgfX0K>"
3. Upload the updated config back to Ory. If you do not provide these templates, Ory will not be able to send SMS messages and will return the error you are seeing [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). If you are using Ory Network, make sure you use Base64-encoded templates, as http://
or file://
URIs are not supported [Using custom message templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates). If you have already configured the templates and still see this error, double-check that the template type (e.g., verification_code
) matches the flow you are triggering and that the SMS channel is properly set up. If you need more details on configuring SMS templates, refer to the official documentation [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms).rough-kilobyte-98919
08/14/2025, 8:21 AMbrief-egg-61061
08/14/2025, 8:21 AMbrief-egg-61061
08/14/2025, 8:21 AMverification_code
SMS template is required. If you also want to support SMS for account recovery or login, you must add the recovery_code
and/or login_code
SMS templates as well. If you attempt to trigger a flow (like recovery or login) that sends an SMS but have not configured the corresponding template, you will encounter the Expected sms template but got <nil>
error for that flow [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). So, only configure the SMS templates for the flows you intend to support via SMS.rough-kilobyte-98919
08/14/2025, 8:29 AMbrief-egg-61061
08/14/2025, 8:29 AMbrief-egg-61061
08/14/2025, 8:30 AMtemplates.verification_code.valid.sms.body.plaintext
template and are still seeing the error Expected sms template but got <nil>
, there are a few things to check based on the official Ory documentation: 1. Template Placement and Structure Ensure your configuration matches the required structure. The template should be under: yaml courier: templates: verification_code: valid: sms: body: plaintext: "base64://<your_base64_encoded_template>"
Only the recovery_code
, verification_code
, and login_code
templates support an SMS variant. Double-check that you are not using a different template key or structure, as other templates (like verification.valid
) do not support SMS variants [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 2. Base64 Encoding The value for plaintext
must be a valid base64-encoded string, and the prefix must be base64://
. If the encoding or prefix is incorrect, the template will not be recognized [Using custom message templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates). 3. SMS Channel Configuration Make sure you have configured an SMS channel in your courier.channels
section. Without a properly configured SMS channel, the template will not be used, and you may see this error [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 4. Flow Type Confirm that the flow you are triggering is actually using the verification_code
template. If you are triggering a different flow (like recovery or login), you will need to provide the corresponding SMS template for that flow. If all of the above are correct and you are still experiencing the issue, the knowledge sources do not provide further troubleshooting steps for this specific error. In that case, it may be a bug or a misconfiguration not covered in the documentation, and you may want to open an issue with your configuration details for further support. Summary: - Double-check the template structure and encoding. - Ensure the SMS channel is configured. - Make sure the correct flow and template type are being used. If the problem persists after these checks, the knowledge sources do not contain enough information to provide a more specific solution.rough-kilobyte-98919
08/14/2025, 8:41 AMSending out registration email with code.
, eventhough I register using traits.phonebrief-egg-61061
08/14/2025, 8:41 AMbrief-egg-61061
08/14/2025, 8:42 AM"verification": { "via": "sms" }
for phone and "verification": { "via": "email" }
for email). Even if you register using traits.phone
(SMS), Ory Kratos will still send a verification email to the email address if email verification is enabled in the schema. This is confirmed in the [GitHub issue](https://github.com/ory/kratos/issues/4161), where users report that after registering with a phone number and SMS code, a verification email is still sent. The only way to prevent this is to remove the email verification configuration from the schema: diff "email": { "type": "string", "format": "email", "title": "E-mail", "minLength": 3, "<http://ory.sh/kratos|ory.sh/kratos>": { "credentials": { "password": { "identifier": true }, "code": { "identifier": true, "via": "email" } }, - "verification": { - "via": "email" - } } },
So, if both phone and email are marked as verifiable, Kratos will attempt to verify both, regardless of which trait was used for registration. This is not configurable per-flow in the current version, and is considered a limitation or bug by some users [Phone+email schema: verification email is sent when signed up with SMS code](https://github.com/ory/kratos/issues/4161). Summary: If you want to avoid sending a verification email when registering with a phone number, you must remove the email verification configuration from your identity schema. There is currently no built-in way to have Kratos only verify the trait used for registration when both are present and verifiable in the schema.rough-kilobyte-98919
08/14/2025, 8:43 AMExpected sms template but got <nil>
brief-egg-61061
08/14/2025, 8:43 AMbrief-egg-61061
08/14/2025, 8:43 AMExpected sms template but got <nil>
, this means Ory Kratos is attempting to send an SMS (for example, for verification), but it cannot find the required SMS template for the message type. Based on the official documentation, you must ensure that: 1. The SMS template is configured for the correct template type. Only the following templates support an SMS variant: - verification_code
- login_code
- recovery_code
The configuration should look like this: yaml courier: templates: verification_code: valid: sms: body: plaintext: "base64://<your_base64_encoded_template>"
2. The template is base64-encoded and prefixed with base64://
. If the encoding or prefix is incorrect, Kratos will not recognize the template [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 3. You have a properly configured SMS channel. Without an SMS channel in courier.channels
, the template will not be used [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). If all of the above are correct and you are still seeing the error, the knowledge sources do not provide further troubleshooting steps for this specific error. In that case, it may be a bug or a misconfiguration not covered in the documentation, and you may want to open an issue with your configuration details for further support. Summary: - Double-check your template structure and encoding. - Ensure the SMS channel is configured. - Make sure the correct template type is used. If the problem persists after these checks, the knowledge sources do not contain enough information to provide a more specific solution.rough-kilobyte-98919
08/14/2025, 8:45 AMbrief-egg-61061
08/14/2025, 8:45 AMrough-kilobyte-98919
08/14/2025, 8:45 AMcourier:
delivery_strategy: smtp
smtp:
connection_uri: <smtp://redacted:10025/?disable_starttls=true>
from_address: redacted
from_name: "redacted"
channels:
- id: sms
type: http
request_config:
url: <https://verify.twilio.com/v2/Services/redacted/Verifications>
method: POST
body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ==
headers:
Content-Type: application/x-www-form-urlencoded
templates:
verification_code:
valid:
sms:
body:
plaintext: "<base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ=="
email:
body:
plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGU>gfX0="
brief-egg-61061
08/14/2025, 8:45 AMcourier
and templates
sections) here, and I'll review it for issues related to the Expected sms template but got <nil>
error. Based on the knowledge sources, here’s what you should check in your YAML: - The courier.templates.verification_code.valid.sms.body.plaintext
field must be present and correctly formatted. - The value must be a base64-encoded string, prefixed with base64://
. - Only the verification_code
, login_code
, and recovery_code
templates support SMS variants [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). - You must have an SMS channel configured under courier.channels
. Please paste your YAML, and I’ll review it for you!brief-egg-61061
08/14/2025, 8:45 AMbrief-egg-61061
08/14/2025, 8:45 AMplaintext
under your SMS template should not include angle brackets (<
and >
). It should be: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ==
not <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ==>
- Remove the angle brackets from all base64 values. 2. Template Structure - Your structure for the SMS template under verification_code
is correct. Only verification_code
, login_code
, and recovery_code
support SMS templates [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 3. SMS Channel - You have an SMS channel configured, which is required. 4. Jsonnet Template - The base64-encoded value for the SMS body should decode to a valid Jsonnet function. Double-check that your template, when decoded, matches the expected structure: jsonnet function(ctx) { To: ctx.recipient, Body: ctx.body, }
- If your template is different, it may cause issues. 5. No Need for Email in SMS-Only Flows - If you are only using phone verification, you can omit the email
section under verification_code
if not needed. ### Example (Corrected) yaml courier: delivery_strategy: smtp smtp: connection_uri: <smtp://redacted:10025/?disable_starttls=true> from_address: redacted from_name: "redacted" channels: - id: sms type: http request_config: url: <https://verify.twilio.com/v2/Services/redacted/Verifications> method: POST body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDogY3R4Lm1lc3NhZ2VfdHlwZSwKfQ>== headers: Content-Type: application/x-www-form-urlencoded templates: verification_code: valid: sms: body: plaintext: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDogY3R4Lm1lc3NhZ2VfdHlwZSwKfQ>==
### Summary - Remove angle brackets from all base64 values. - Ensure your base64-encoded template decodes to a valid Jsonnet function as expected by Ory. - Your structure is otherwise correct for SMS verification. If you make these corrections and still see the error, the knowledge sources do not provide further troubleshooting steps for this specific issue. In that case, you may want to reach out to Ory support or open a GitHub issue with your configuration details. For more details, see the official documentation: [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms).rough-kilobyte-98919
08/14/2025, 8:59 AMbrief-egg-61061
08/14/2025, 8:59 AMbrief-egg-61061
08/14/2025, 8:59 AMrough-kilobyte-98919
08/14/2025, 9:53 AMbrief-egg-61061
08/14/2025, 9:53 AMbrief-egg-61061
08/14/2025, 9:53 AMrough-kilobyte-98919
08/14/2025, 9:58 AMbrief-egg-61061
08/14/2025, 9:58 AMbrief-egg-61061
08/14/2025, 9:58 AM"format": "tel"
and, if you want verification, with the appropriate "verification"
extension. When a user submits the registration form with their phone number (and any other required fields), and the submission passes validation, Ory will then create the identity. If phone verification is enabled, the verification process (such as sending an SMS code) will be triggered after the account is created [Phone number verification](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#phone-number-verification). So, the account is created only after the registration form is submitted and validated, not when the flow is merely started—this applies to phone number registration as well.rough-kilobyte-98919
08/14/2025, 10:03 AMbrief-egg-61061
08/14/2025, 10:03 AMbrief-egg-61061
08/14/2025, 10:04 AM