Add a code to mails
using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://api.nimles.com/communication/api/tenant/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/Mails/codes"), Headers = { { "Authorization", "Bearer <token>" }, }, Content = new StringContent("{ \"to\": \"example\", \"code\": \"example\", \"name\": \"example\", \"language\": \"example\", \"minutes\": 1 }") { Headers = { ContentType = new MediaTypeHeaderValue("application/json") } }};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}const url = 'https://api.nimles.com/communication/api/tenant/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/Mails/codes';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"to":"example","code":"example","name":"example","language":"example","minutes":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.nimles.com/communication/api/tenant/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/Mails/codes \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "to": "example", "code": "example", "name": "example", "language": "example", "minutes": 1 }'Mails a one-time code to one address in Communication’s own words: the subject and text say the code, what it opens (the
caller’s name for it, as plain text) and for how many minutes it works, in Swedish or English. Needs mails/sendCode or
mails/write. The caller decides who may get a code; Communication only writes and sends it, and an address on a
reserved test domain is recorded and never delivered, as every mail is.
Communication also chooses the sender (security review L7): the tenant’s default sender, or the platform’s
(Nimles.Communication.Adapters.Acs.AcsOptions.FallbackSender, which a tenant sends as its own {unique name}@tenant.nimles.com), never
with a reply address. An address gets at most Nimles.Communication.Domain.Abstractions.MailCodes.MailCodeLimits.PerShortWindow codes in a quarter of an hour
and Nimles.Communication.Domain.Abstractions.MailCodes.MailCodeLimits.PerLongWindow in a day from the tenant (429 MailCodeLimit). The code is sent and
recorded masked, never in clear (L8).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Your tenant id.
Request Body
Section titled “Request Body”The code.
object
Example generated
{ "to": "example", "code": "example", "name": "example", "language": "example", "minutes": 1}Responses
Section titled “Responses”OK
Unauthorized: no bearer token, or one that is expired or not for this API.
Forbidden: the caller holds no role that allows this action at this scope. The body is empty, or a problem whose detail names the action.
An RFC 9457 problem.
object
Example generated
{ "detail": "example", "instance": "example", "status": 1, "title": "example", "type": "example"}Conflict: the item kept changing under concurrent writes; read it again and retry.
An RFC 9457 problem.
object
Example generated
{ "detail": "example", "instance": "example", "status": 1, "title": "example", "type": "example"}Unprocessable: the body or the change is invalid. The errors are keyed by member.
A validation problem: the messages by member (or by JSON Pointer for a patch).
object
object
Example generated
{ "errors": { "additionalProperty": [ "example" ] }, "status": 1, "title": "example", "type": "example"}