[{"data":1,"prerenderedAt":730},["ShallowReactive",2],{"navigation":3,"\u002Fwebhooks":43,"\u002Fwebhooks-surround":726},[4,8,13,18,23,28,33,38],{"title":5,"path":6,"stem":7},"Getting started","\u002F","index",{"title":9,"path":10,"stem":11,"order":12},"Numbers","\u002Fnumbers","numbers",1,{"title":14,"path":15,"stem":16,"order":17},"Rent","\u002Frent","rent",2,{"title":19,"path":20,"stem":21,"order":22},"User","\u002Fuser","user",3,{"title":24,"path":25,"stem":26,"order":27},"Free numbers","\u002Ffree","free",4,{"title":29,"path":30,"stem":31,"order":32},"Webhooks","\u002Fwebhooks","webhooks",5,{"title":34,"path":35,"stem":36,"order":37},"Testing","\u002Ftesting","testing",6,{"title":39,"path":40,"stem":41,"order":42},"Changelog","\u002Fchangelog","changelog",7,{"id":44,"title":29,"body":45,"description":720,"extension":721,"meta":722,"navigation":723,"path":30,"seo":724,"stem":31,"__hash__":725},"docs\u002Fwebhooks.md",{"type":46,"value":47,"toc":716},"minimark",[48,80,85,91,143,154,161,498,502,508,712],[49,50,51,52,60,61,64,65,68,69,72,73,79],"p",{},"Set a URL with ",[53,54,56],"a",{"href":55},"\u002Fuser#setwebhookurlasync",[57,58,59],"code",{},"client.User.SetWebhookUrlAsync",". For each SMS the server POSTs a JSON body to it: ",[57,62,63],{},"webhook_type"," ",[57,66,67],{},"receiving_sms"," for numbers, ",[57,70,71],{},"rent_sms"," for rents. Delivery attempts are listed by ",[53,74,76],{"href":75},"\u002Fuser#webhooklogsasync",[57,77,78],{},"client.User.WebhookLogsAsync",".",[81,82,84],"h2",{"id":83},"webhookparse","Webhook.Parse",[49,86,87,88,79],{},"Parse an inbound webhook body from a JSON string or an already parsed ",[57,89,90],{},"JsonElement",[92,93,98],"pre",{"className":94,"code":95,"language":96,"meta":97,"style":97},"language-csharp shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","static WebhookPayload Parse(string payload)\nstatic WebhookPayload Parse(JsonElement payload)\n","csharp","",[57,99,100,129],{"__ignoreMap":97},[101,102,104,108,112,116,120,123,126],"span",{"class":103,"line":12},"line",[101,105,107],{"class":106},"spNyl","static",[101,109,111],{"class":110},"sBMFI"," WebhookPayload",[101,113,115],{"class":114},"s2Zo4"," Parse",[101,117,119],{"class":118},"sMK4o","(",[101,121,122],{"class":118},"string",[101,124,125],{"class":110}," payload",[101,127,128],{"class":118},")\n",[101,130,131,135,137,139,141],{"class":103,"line":17},[101,132,134],{"class":133},"sTEyZ","static WebhookPayload Parse",[101,136,119],{"class":118},[101,138,90],{"class":110},[101,140,125],{"class":110},[101,142,128],{"class":118},[49,144,145,146,149,150,153],{},"Lenient: numeric fields may arrive as strings, missing or malformed fields become ",[57,147,148],{},"null",", unknown fields are dropped. It throws ",[57,151,152],{},"OnlineSimException"," only when the input is not a JSON object.",[49,155,156,157,160],{},"Any web framework works: pass it the raw request body. With the BCL's ",[57,158,159],{},"HttpListener"," (also on .NET Framework):",[92,162,164],{"className":94,"code":163,"language":96,"meta":97,"style":97},"using System.IO;\nusing System.Net;\nusing OnlineSim.Api;\n\nvar listener = new HttpListener();\nlistener.Prefixes.Add(\"http:\u002F\u002F+:8080\u002Fonlinesim-hook\u002F\");\nlistener.Start();\nwhile (true)\n{\n    var context = await listener.GetContextAsync();\n    using (var reader = new StreamReader(context.Request.InputStream))\n    {\n        var hook = Webhook.Parse(await reader.ReadToEndAsync());\n        if (hook.WebhookType == Webhook.ReceivingSms) Console.WriteLine($\"{hook.OperationId} {hook.Code}\");\n    }\n    context.Response.Close();\n}\n",[57,165,166,183,196,210,216,236,265,276,292,298,321,359,365,397,468,474,492],{"__ignoreMap":97},[101,167,168,172,175,177,180],{"class":103,"line":12},[101,169,171],{"class":170},"sbssI","using",[101,173,174],{"class":133}," System",[101,176,79],{"class":118},[101,178,179],{"class":133},"IO",[101,181,182],{"class":118},";\n",[101,184,185,187,189,191,194],{"class":103,"line":17},[101,186,171],{"class":170},[101,188,174],{"class":133},[101,190,79],{"class":118},[101,192,193],{"class":133},"Net",[101,195,182],{"class":118},[101,197,198,200,203,205,208],{"class":103,"line":22},[101,199,171],{"class":170},[101,201,202],{"class":133}," OnlineSim",[101,204,79],{"class":118},[101,206,207],{"class":133},"Api",[101,209,182],{"class":118},[101,211,212],{"class":103,"line":27},[101,213,215],{"emptyLinePlaceholder":214},true,"\n",[101,217,218,221,224,227,230,233],{"class":103,"line":32},[101,219,220],{"class":110},"var",[101,222,223],{"class":110}," listener",[101,225,226],{"class":118}," =",[101,228,229],{"class":118}," new",[101,231,232],{"class":110}," HttpListener",[101,234,235],{"class":118},"();\n",[101,237,238,241,243,246,248,251,253,256,260,262],{"class":103,"line":37},[101,239,240],{"class":133},"listener",[101,242,79],{"class":118},[101,244,245],{"class":133},"Prefixes",[101,247,79],{"class":118},[101,249,250],{"class":114},"Add",[101,252,119],{"class":118},[101,254,255],{"class":118},"\"",[101,257,259],{"class":258},"sfazB","http:\u002F\u002F+:8080\u002Fonlinesim-hook\u002F",[101,261,255],{"class":118},[101,263,264],{"class":118},");\n",[101,266,267,269,271,274],{"class":103,"line":42},[101,268,240],{"class":133},[101,270,79],{"class":118},[101,272,273],{"class":114},"Start",[101,275,235],{"class":118},[101,277,279,283,286,290],{"class":103,"line":278},8,[101,280,282],{"class":281},"s7zQu","while",[101,284,285],{"class":118}," (",[101,287,289],{"class":288},"sfNiH","true",[101,291,128],{"class":118},[101,293,295],{"class":103,"line":294},9,[101,296,297],{"class":118},"{\n",[101,299,301,304,307,309,312,314,316,319],{"class":103,"line":300},10,[101,302,303],{"class":110},"    var",[101,305,306],{"class":110}," context",[101,308,226],{"class":118},[101,310,311],{"class":118}," await",[101,313,223],{"class":133},[101,315,79],{"class":118},[101,317,318],{"class":114},"GetContextAsync",[101,320,235],{"class":118},[101,322,324,327,329,331,334,336,338,341,343,346,348,351,353,356],{"class":103,"line":323},11,[101,325,326],{"class":281},"    using",[101,328,285],{"class":118},[101,330,220],{"class":110},[101,332,333],{"class":110}," reader",[101,335,226],{"class":118},[101,337,229],{"class":118},[101,339,340],{"class":110}," StreamReader",[101,342,119],{"class":118},[101,344,345],{"class":133},"context",[101,347,79],{"class":118},[101,349,350],{"class":133},"Request",[101,352,79],{"class":118},[101,354,355],{"class":133},"InputStream",[101,357,358],{"class":118},"))\n",[101,360,362],{"class":103,"line":361},12,[101,363,364],{"class":118},"    {\n",[101,366,368,371,374,376,379,381,384,387,389,391,394],{"class":103,"line":367},13,[101,369,370],{"class":110},"        var",[101,372,373],{"class":110}," hook",[101,375,226],{"class":118},[101,377,378],{"class":133}," Webhook",[101,380,79],{"class":118},[101,382,383],{"class":114},"Parse",[101,385,386],{"class":118},"(await",[101,388,333],{"class":133},[101,390,79],{"class":118},[101,392,393],{"class":114},"ReadToEndAsync",[101,395,396],{"class":118},"());\n",[101,398,400,403,405,408,410,413,416,418,420,423,426,429,431,434,436,439,442,444,446,449,452,455,457,459,462,464,466],{"class":103,"line":399},14,[101,401,402],{"class":281},"        if",[101,404,285],{"class":118},[101,406,407],{"class":133},"hook",[101,409,79],{"class":118},[101,411,412],{"class":133},"WebhookType ",[101,414,415],{"class":118},"==",[101,417,378],{"class":133},[101,419,79],{"class":118},[101,421,422],{"class":133},"ReceivingSms",[101,424,425],{"class":118},")",[101,427,428],{"class":133}," Console",[101,430,79],{"class":118},[101,432,433],{"class":114},"WriteLine",[101,435,119],{"class":118},[101,437,438],{"class":118},"$\"",[101,440,441],{"class":118},"{",[101,443,407],{"class":133},[101,445,79],{"class":118},[101,447,448],{"class":133},"OperationId",[101,450,451],{"class":118},"}",[101,453,454],{"class":118}," {",[101,456,407],{"class":133},[101,458,79],{"class":118},[101,460,461],{"class":133},"Code",[101,463,451],{"class":118},[101,465,255],{"class":118},[101,467,264],{"class":118},[101,469,471],{"class":103,"line":470},15,[101,472,473],{"class":118},"    }\n",[101,475,477,480,482,485,487,490],{"class":103,"line":476},16,[101,478,479],{"class":133},"    context",[101,481,79],{"class":118},[101,483,484],{"class":133},"Response",[101,486,79],{"class":118},[101,488,489],{"class":114},"Close",[101,491,235],{"class":118},[101,493,495],{"class":103,"line":494},17,[101,496,497],{"class":118},"}\n",[81,499,501],{"id":500},"payload-fields","Payload fields",[49,503,504,507],{},[57,505,506],{},"WebhookPayload",":",[509,510,511,527],"table",{},[512,513,514],"thead",{},[515,516,517,521,524],"tr",{},[518,519,520],"th",{},"Property",[518,522,523],{},"Type",[518,525,526],{},"Description",[528,529,530,555,572,586,601,633,650,664,681,698],"tbody",{},[515,531,532,538,543],{},[533,534,535],"td",{},[57,536,537],{},"WebhookType",[533,539,540],{},[57,541,542],{},"string?",[533,544,545,548,549,552,553,79],{},[57,546,547],{},"Webhook.ReceivingSms",", ",[57,550,551],{},"Webhook.RentSms",", or ",[57,554,148],{},[515,556,557,561,566],{},[533,558,559],{},[57,560,448],{},[533,562,563],{},[57,564,565],{},"long?",[533,567,568,571],{},[57,569,570],{},"tzid"," of the operation or rent.",[515,573,574,579,583],{},[533,575,576],{},[57,577,578],{},"UserId",[533,580,581],{},[57,582,565],{},[533,584,585],{},"Account id.",[515,587,588,593,598],{},[533,589,590],{},[57,591,592],{},"CountryCode",[533,594,595],{},[57,596,597],{},"int?",[533,599,600],{},"Country code of the number.",[515,602,603,608,612],{},[533,604,605],{},[57,606,607],{},"Number",[533,609,610],{},[57,611,542],{},[533,613,614,615,618,619,622,623,626,627,285,629,632],{},"Numbers: ",[57,616,617],{},"+"," and the full number (",[57,620,621],{},"+79001234567","), or ",[57,624,625],{},"hidden",". Rent: the full number in digits without ",[57,628,617],{},[57,630,631],{},"79001234567",").",[515,634,635,640,644],{},[533,636,637],{},[57,638,639],{},"Sender",[533,641,642],{},[57,643,542],{},[533,645,646,647,79],{},"Sender of the SMS, e.g. ",[57,648,649],{},"VK",[515,651,652,657,661],{},[533,653,654],{},[57,655,656],{},"Message",[533,658,659],{},[57,660,542],{},[533,662,663],{},"Full SMS text.",[515,665,666,670,674],{},[533,667,668],{},[57,669,461],{},[533,671,672],{},[57,673,542],{},[533,675,676,677,680],{},"Code extracted from the SMS; ",[57,678,679],{},"\"\""," when none was found.",[515,682,683,688,692],{},[533,684,685],{},[57,686,687],{},"TimeStart",[533,689,690],{},[57,691,542],{},[533,693,694,695,79],{},"Numbers: when the operation was ordered. Rent: when the SMS arrived. ",[57,696,697],{},"YYYY-MM-DD HH:MM:SS",[515,699,700,705,709],{},[533,701,702],{},[57,703,704],{},"TimeLeft",[533,706,707],{},[57,708,565],{},[533,710,711],{},"Time left: seconds for numbers, minutes for rent.",[713,714,715],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":97,"searchDepth":17,"depth":17,"links":717},[718,719],{"id":83,"depth":17,"text":84},{"id":500,"depth":17,"text":501},"Receive SMS as HTTP callbacks and parse them with Webhook.Parse.","md",{},{"order":32},{"title":29,"description":720},"RMRGGxFe8qO-FBN5uF9j4sAe91dJMrjCCZmx7ZbOdhM",[727,729],{"title":19,"path":20,"stem":21,"description":728,"order":22},"Balance, profile, payments and the webhook URL — client.User.",null,1795164313952]