{"id":"sms.template.create","module":"sms","namespace":"sms","action":"template.create","method":"POST","path":"/v1/sms/template/create","idempotent":true,"available":true,"vendors":[],"vendors_ready":[],"vendors_pending":[],"key_status":"live","default_vendor":null,"self_hosted":true,"minimum_tier":"pro","supported_message_classes":null,"regions":["western","china"],"dynamic_params":{},"models_tracked":false,"sdk_hint":"Regular parameters + types are stable — read them from the typed SDK signature / API reference for this capability. discovery only carries the runtime-dynamic values above (available, vendors, dynamic_params).","params":{"title":"SmsTemplateCreateRequest","description":"Register an SMS template. China vendors (Tencent/Aliyun) require template review before a +86 send can reference it; the server submits it and review_state is polled via sms.template.get. Western vendors store it as a convenience.","type":"object","required":["name","body"],"additionalProperties":false,"properties":{"name":{"type":"string","description":"Human label for the template."},"body":{"type":"string","description":"Template text with {{var}} placeholders. Variable names may contain only letters, digits and underscore, and each variable may appear at most once."},"locale":{"type":"string","default":"en","description":"zh/cn locales trigger China-vendor review."},"variables":{"type":"array","items":{"type":"string"},"description":"Declared placeholder names. If provided, it must exactly match the placeholders in body; final order is inferred from first appearance in body."},"vendor":{"type":["string","null"],"description":"Pin the vendor to register at; otherwise the gateway picks per region."},"message_type":{"type":"string","enum":["otp","notification","marketing"],"default":"otp","description":"Template category. Infrai maps this to the vendor-native template type, e.g. Tencent SmsType: otp=3, notification=2, marketing=1."},"international":{"type":"integer","enum":[0,1],"default":1,"description":"Tencent template region flag: 0 mainland China, 1 international/HK/Macau/Taiwan."}}},"response":{"title":"SmsTemplate","description":"SMS template — adds review_state for China vendors. See docs/phase2/P2_03_New_Modules.md §1.2. Optional fields are omitted by the store's to_dict() when null.","type":"object","required":["template_id","name","body","locale","created_at"],"additionalProperties":false,"properties":{"template_id":{"type":"string","description":"Identifier of the template used for rendering"},"name":{"type":"string","description":"Human-readable name for this resource"},"body":{"type":"string","description":"Plain text body of the message"},"locale":{"type":"string","default":"en","description":"Locale code for the template (e.g. en-US, zh-CN)"},"variables":{"type":"array","items":{"type":"string"},"description":"Template variable definitions"},"review_state":{"enum":["pending","approved","rejected","n/a"],"default":"n/a","description":"Required for China vendors; n/a otherwise."},"review_reason":{"type":["string","null"],"description":"Vendor reviewer note when review_state=rejected."},"vendor_template_id":{"type":["string","null"],"description":"Vendor-assigned template id remembered after a real submit (polled by query_review_state)."},"scope":{"enum":["account","platform"],"default":"account","description":"Template visibility: account-private or platform-shared."},"vendor":{"type":["string","null"],"description":"SMS vendor that owns the vendor_template_id."},"message_type":{"enum":["otp","notification","marketing",null],"default":"otp","description":"Template category requested at creation time."},"international":{"type":["integer","null"],"enum":[0,1,null],"description":"Tencent template region flag saved for vendor review polling: 0 mainland China, 1 international/HK/Macau/Taiwan."},"created_at":{"type":"string","format":"date-time","description":"ISO 8601 timestamp when this resource was created"},"updated_at":{"type":["string","null"],"format":"date-time","description":"ISO 8601 timestamp when this resource was last updated"},"found":{"type":"boolean","description":"Present on sms.template.get; true when the template exists. (A missing template should raise a typed 404 once the SMS_TEMPLATE_NOT_FOUND code lands — see module notes.)"}}},"errors":["ACCOUNT_AUTORECHARGE_LIMIT","ACCOUNT_FROZEN","AUTH_RATE_LIMIT","AUTH_REFRESH_TOO_FREQUENT","IDEMPOTENCY_KEY_CONFLICT","INSUFFICIENT_CREDIT","INTERNAL_ERROR","INVALID_ARGUMENT","INVALID_PHONE_NUMBER","KEY_REVOKED","MAINTENANCE","NETWORK_ERROR","RATE_LIMIT_ACCOUNT","RATE_LIMIT_USER","RATE_LIMIT_VENDOR","SCOPE_INSUFFICIENT","SMS_CONFIRMATION_REQUIRED","SMS_CONTENT_REJECTED","SMS_INBOUND_NOT_SUPPORTED","SMS_INVALID_RETENTION","SMS_MESSAGE_NOT_FOUND","SMS_NOT_CONFIGURED","SMS_RATE_LIMIT","SMS_SEGMENT_LIMIT_EXCEEDED","SMS_SENDER_NOT_REGISTERED","SMS_SEND_FAILED","SMS_SIGNATURE_NOT_FOUND","SMS_SUPPRESSED_RECIPIENT","SMS_TEMPLATE_NOT_APPROVED","SMS_TEMPLATE_NOT_FOUND","SMS_TEMPLATE_REQUIRED","SMS_VENDOR_DOWN","SMS_VENDOR_UNSUPPORTED_OP","UNAUTHORIZED","VENDOR_AUTH_ERROR","VENDOR_DOWN","VENDOR_TIMEOUT","WALLET_EXPIRED"],"examples":{"curl":"curl -X POST https://api.infrai.cc/v1/sms/template/create \\\n  -H \"Authorization: Bearer $INFRAI_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\": \"otp\", \"body\": \"Your code is {{code}}\", \"locale\": \"zh\"}'","python":"# Zero-install REST call — no SDK required (short-term the API is REST-only).\nimport os, requests\n\nresp = requests.post(\n    \"https://api.infrai.cc/v1/sms/template/create\",\n    headers={\n        \"Authorization\": f\"Bearer {os.environ['INFRAI_API_KEY']}\",\n    },\n    json={'name': 'otp', 'body': 'Your code is {{code}}', 'locale': 'zh'},\n)\nresp.raise_for_status()\nprint(resp.json())","javascript":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nconst resp = await fetch(\n  \"https://api.infrai.cc/v1/sms/template/create\",\n  {\n    method: \"POST\",\n    headers: {\n      \"Authorization\": `Bearer ${process.env.INFRAI_API_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\"name\": \"otp\", \"body\": \"Your code is {{code}}\", \"locale\": \"zh\"}),\n  },\n);\nconsole.log(await resp.json());","typescript":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nconst resp = await fetch(\n  \"https://api.infrai.cc/v1/sms/template/create\",\n  {\n    method: \"POST\",\n    headers: {\n      \"Authorization\": `Bearer ${process.env.INFRAI_API_KEY}`,\n      \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\"name\": \"otp\", \"body\": \"Your code is {{code}}\", \"locale\": \"zh\"}),\n  },\n);\nif (!resp.ok) throw new Error(`infrai ${resp.status}`);\nconst data: unknown = await resp.json();\nconsole.log(data);","go":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n)\n\nfunc main() {\n\tbody := []byte(`{\"name\": \"otp\", \"body\": \"Your code is {{code}}\", \"locale\": \"zh\"}`)\n\treq, _ := http.NewRequest(\"POST\", \"https://api.infrai.cc/v1/sms/template/create\", bytes.NewReader(body))\n\treq.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"INFRAI_API_KEY\"))\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\tfmt.Println(resp.Status)\n}","java":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nimport java.net.URI;\nimport java.net.http.*;\n\nHttpRequest req = HttpRequest.newBuilder()\n    .uri(URI.create(\"https://api.infrai.cc/v1/sms/template/create\"))\n    .header(\"Authorization\", \"Bearer \" + System.getenv(\"INFRAI_API_KEY\"))\n    .header(\"Content-Type\", \"application/json\")\n    .method(\"POST\", HttpRequest.BodyPublishers.ofString(\"{\\\"name\\\": \\\"otp\\\", \\\"body\\\": \\\"Your code is {{code}}\\\", \\\"locale\\\": \\\"zh\\\"}\"))\n    .build();\nHttpResponse<String> resp = HttpClient.newHttpClient()\n    .send(req, HttpResponse.BodyHandlers.ofString());\nSystem.out.println(resp.body());","csharp":"// Zero-install REST call — no SDK required (short-term the API is REST-only).\nusing System;\nusing System.Net.Http;\n\nvar client = new HttpClient();\nvar req = new HttpRequestMessage(new HttpMethod(\"POST\"), \"https://api.infrai.cc/v1/sms/template/create\");\nvar key = Environment.GetEnvironmentVariable(\"INFRAI_API_KEY\");\nreq.Headers.Add(\"Authorization\", \"Bearer \" + key);\nreq.Content = new StringContent(\"{\\\"name\\\": \\\"otp\\\", \\\"body\\\": \\\"Your code is {{code}}\\\", \\\"locale\\\": \\\"zh\\\"}\", System.Text.Encoding.UTF8, \"application/json\");\nvar resp = await client.SendAsync(req);\nConsole.WriteLine(await resp.Content.ReadAsStringAsync());","php":"<?php\n// Zero-install REST call — no SDK required (short-term the API is REST-only).\n$ch = curl_init(\"https://api.infrai.cc/v1/sms/template/create\");\ncurl_setopt($ch, CURLOPT_CUSTOMREQUEST, \"POST\");\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);\ncurl_setopt($ch, CURLOPT_HTTPHEADER, [\n    \"Authorization: Bearer \" . getenv(\"INFRAI_API_KEY\"),\n    \"Content-Type: application/json\",\n]);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, \"{\\\"name\\\": \\\"otp\\\", \\\"body\\\": \\\"Your code is {{code}}\\\", \\\"locale\\\": \\\"zh\\\"}\");\n$response = curl_exec($ch);\ncurl_close($ch);\necho $response;","ruby":"# Zero-install REST call — no SDK required (short-term the API is REST-only).\nrequire \"net/http\"\nrequire \"uri\"\n\nuri = URI(\"https://api.infrai.cc/v1/sms/template/create\")\nhttp = Net::HTTP.new(uri.host, uri.port)\nhttp.use_ssl = true\nreq = Net::HTTP::Post.new(uri)\nreq[\"Authorization\"] = \"Bearer #{ENV['INFRAI_API_KEY']}\"\nreq[\"Content-Type\"] = \"application/json\"\nreq.body = '{\"name\": \"otp\", \"body\": \"Your code is {{code}}\", \"locale\": \"zh\"}'\nres = http.request(req)\nputs res.body","rust":"// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)\nuse std::env;\n\n#[tokio::main]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n    let resp = reqwest::Client::new()\n        .post(\"https://api.infrai.cc/v1/sms/template/create\")\n        .header(\"Authorization\", format!(\"Bearer {}\", env::var(\"INFRAI_API_KEY\")?))\n        .header(\"Content-Type\", \"application/json\")\n        .body(r#\"{\"name\": \"otp\", \"body\": \"Your code is {{code}}\", \"locale\": \"zh\"}\"#)\n        .send()\n        .await?;\n    println!(\"{}\", resp.text().await?);\n    Ok(())\n}","request":{"name":"otp","body":"Your code is {{code}}","locale":"zh"}},"billing":{"is_billable":false,"free":true,"billing_class":"self_dev_market","unit":"per_call","note":"free (rate-limited); does NOT consume the new-account trial"}}