[{"data":1,"prerenderedAt":910},["ShallowReactive",2],{"navigation":3,"\u002Fwebhooks":43,"\u002Fwebhooks-surround":906},[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":900,"extension":901,"meta":902,"navigation":903,"path":30,"seo":904,"stem":31,"__hash__":905},"docs\u002Fwebhooks.md",{"type":46,"value":47,"toc":896},"minimark",[48,80,85,88,142,153,634,638,892],[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#setwebhookurl",[57,58,59],"code",{},"client.User().SetWebhookURL",". 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#webhooklogs",[57,77,78],{},"client.User().WebhookLogs",".",[81,82,84],"h2",{"id":83},"parsewebhook","ParseWebhook",[49,86,87],{},"Parse an inbound webhook body.",[89,90,95],"pre",{"className":91,"code":92,"language":93,"meta":94,"style":94},"language-go shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","func ParseWebhook(data []byte) (WebhookPayload, error)\n","go","",[57,96,97],{"__ignoreMap":94},[98,99,101,105,109,112,116,119,123,126,129,133,136,139],"span",{"class":100,"line":12},"line",[98,102,104],{"class":103},"sMK4o","func",[98,106,108],{"class":107},"s2Zo4"," ParseWebhook",[98,110,111],{"class":103},"(",[98,113,115],{"class":114},"sHdIc","data",[98,117,118],{"class":103}," []",[98,120,122],{"class":121},"spNyl","byte",[98,124,125],{"class":103},")",[98,127,128],{"class":103}," (",[98,130,132],{"class":131},"sBMFI","WebhookPayload",[98,134,135],{"class":103},",",[98,137,138],{"class":121}," error",[98,140,141],{"class":103},")\n",[49,143,144,145,148,149,152],{},"Lenient: numeric fields may arrive as strings, missing or malformed fields become zero values (",[57,146,147],{},"\"\"",", ",[57,150,151],{},"0","), unknown fields are ignored. It returns an error only when the input is not a JSON object.",[89,154,156],{"className":91,"code":155,"language":93,"meta":94,"style":94},"package main\n\nimport (\n    \"io\"\n    \"log\"\n    \"net\u002Fhttp\"\n\n    onlinesim \"github.com\u002Fs00d\u002Fonlinesim-go-api\u002Fv3\"\n)\n\nfunc main() {\n    http.HandleFunc(\"\u002Fonlinesim-hook\", func(w http.ResponseWriter, r *http.Request) {\n        body, err := io.ReadAll(r.Body)\n        if err != nil {\n            http.Error(w, err.Error(), http.StatusBadRequest)\n            return\n        }\n        hook, err := onlinesim.ParseWebhook(body)\n        if err != nil {\n            http.Error(w, err.Error(), http.StatusBadRequest)\n            return\n        }\n        if hook.WebhookType == onlinesim.WebhookReceivingSMS {\n            log.Println(hook.OperationID, hook.Code)\n        }\n        _, _ = io.WriteString(w, \"ok\")\n    })\n    log.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n",[57,157,158,166,172,181,192,201,210,214,229,234,239,253,310,344,360,396,402,408,434,447,478,483,488,514,546,551,588,594,628],{"__ignoreMap":94},[98,159,160,163],{"class":100,"line":12},[98,161,162],{"class":103},"package",[98,164,165],{"class":131}," main\n",[98,167,168],{"class":100,"line":17},[98,169,171],{"emptyLinePlaceholder":170},true,"\n",[98,173,174,178],{"class":100,"line":22},[98,175,177],{"class":176},"s7zQu","import",[98,179,180],{"class":103}," (\n",[98,182,183,186,189],{"class":100,"line":27},[98,184,185],{"class":103},"    \"",[98,187,188],{"class":131},"io",[98,190,191],{"class":103},"\"\n",[98,193,194,196,199],{"class":100,"line":32},[98,195,185],{"class":103},[98,197,198],{"class":131},"log",[98,200,191],{"class":103},[98,202,203,205,208],{"class":100,"line":37},[98,204,185],{"class":103},[98,206,207],{"class":131},"net\u002Fhttp",[98,209,191],{"class":103},[98,211,212],{"class":100,"line":42},[98,213,171],{"emptyLinePlaceholder":170},[98,215,217,221,224,227],{"class":100,"line":216},8,[98,218,220],{"class":219},"sTEyZ","    onlinesim ",[98,222,223],{"class":103},"\"",[98,225,226],{"class":131},"github.com\u002Fs00d\u002Fonlinesim-go-api\u002Fv3",[98,228,191],{"class":103},[98,230,232],{"class":100,"line":231},9,[98,233,141],{"class":103},[98,235,237],{"class":100,"line":236},10,[98,238,171],{"emptyLinePlaceholder":170},[98,240,242,244,247,250],{"class":100,"line":241},11,[98,243,104],{"class":103},[98,245,246],{"class":107}," main",[98,248,249],{"class":103},"()",[98,251,252],{"class":103}," {\n",[98,254,256,259,261,264,266,268,272,274,276,279,282,285,287,290,292,295,298,301,303,306,308],{"class":100,"line":255},12,[98,257,258],{"class":219},"    http",[98,260,79],{"class":103},[98,262,263],{"class":107},"HandleFunc",[98,265,111],{"class":103},[98,267,223],{"class":103},[98,269,271],{"class":270},"sfazB","\u002Fonlinesim-hook",[98,273,223],{"class":103},[98,275,135],{"class":103},[98,277,278],{"class":103}," func(",[98,280,281],{"class":114},"w",[98,283,284],{"class":131}," http",[98,286,79],{"class":103},[98,288,289],{"class":131},"ResponseWriter",[98,291,135],{"class":103},[98,293,294],{"class":114}," r",[98,296,297],{"class":103}," *",[98,299,300],{"class":131},"http",[98,302,79],{"class":103},[98,304,305],{"class":131},"Request",[98,307,125],{"class":103},[98,309,252],{"class":103},[98,311,313,316,318,321,324,327,329,332,334,337,339,342],{"class":100,"line":312},13,[98,314,315],{"class":219},"        body",[98,317,135],{"class":103},[98,319,320],{"class":219}," err ",[98,322,323],{"class":103},":=",[98,325,326],{"class":219}," io",[98,328,79],{"class":103},[98,330,331],{"class":107},"ReadAll",[98,333,111],{"class":103},[98,335,336],{"class":219},"r",[98,338,79],{"class":103},[98,340,341],{"class":219},"Body",[98,343,141],{"class":103},[98,345,347,350,352,355,358],{"class":100,"line":346},14,[98,348,349],{"class":176},"        if",[98,351,320],{"class":219},[98,353,354],{"class":103},"!=",[98,356,357],{"class":103}," nil",[98,359,252],{"class":103},[98,361,363,366,368,371,373,375,377,380,382,384,387,389,391,394],{"class":100,"line":362},15,[98,364,365],{"class":219},"            http",[98,367,79],{"class":103},[98,369,370],{"class":107},"Error",[98,372,111],{"class":103},[98,374,281],{"class":219},[98,376,135],{"class":103},[98,378,379],{"class":219}," err",[98,381,79],{"class":103},[98,383,370],{"class":107},[98,385,386],{"class":103},"(),",[98,388,284],{"class":219},[98,390,79],{"class":103},[98,392,393],{"class":219},"StatusBadRequest",[98,395,141],{"class":103},[98,397,399],{"class":100,"line":398},16,[98,400,401],{"class":176},"            return\n",[98,403,405],{"class":100,"line":404},17,[98,406,407],{"class":103},"        }\n",[98,409,411,414,416,418,420,423,425,427,429,432],{"class":100,"line":410},18,[98,412,413],{"class":219},"        hook",[98,415,135],{"class":103},[98,417,320],{"class":219},[98,419,323],{"class":103},[98,421,422],{"class":219}," onlinesim",[98,424,79],{"class":103},[98,426,84],{"class":107},[98,428,111],{"class":103},[98,430,431],{"class":219},"body",[98,433,141],{"class":103},[98,435,437,439,441,443,445],{"class":100,"line":436},19,[98,438,349],{"class":176},[98,440,320],{"class":219},[98,442,354],{"class":103},[98,444,357],{"class":103},[98,446,252],{"class":103},[98,448,450,452,454,456,458,460,462,464,466,468,470,472,474,476],{"class":100,"line":449},20,[98,451,365],{"class":219},[98,453,79],{"class":103},[98,455,370],{"class":107},[98,457,111],{"class":103},[98,459,281],{"class":219},[98,461,135],{"class":103},[98,463,379],{"class":219},[98,465,79],{"class":103},[98,467,370],{"class":107},[98,469,386],{"class":103},[98,471,284],{"class":219},[98,473,79],{"class":103},[98,475,393],{"class":219},[98,477,141],{"class":103},[98,479,481],{"class":100,"line":480},21,[98,482,401],{"class":176},[98,484,486],{"class":100,"line":485},22,[98,487,407],{"class":103},[98,489,491,493,496,498,501,504,506,508,511],{"class":100,"line":490},23,[98,492,349],{"class":176},[98,494,495],{"class":219}," hook",[98,497,79],{"class":103},[98,499,500],{"class":219},"WebhookType ",[98,502,503],{"class":103},"==",[98,505,422],{"class":219},[98,507,79],{"class":103},[98,509,510],{"class":219},"WebhookReceivingSMS ",[98,512,513],{"class":103},"{\n",[98,515,517,520,522,525,527,530,532,535,537,539,541,544],{"class":100,"line":516},24,[98,518,519],{"class":219},"            log",[98,521,79],{"class":103},[98,523,524],{"class":107},"Println",[98,526,111],{"class":103},[98,528,529],{"class":219},"hook",[98,531,79],{"class":103},[98,533,534],{"class":219},"OperationID",[98,536,135],{"class":103},[98,538,495],{"class":219},[98,540,79],{"class":103},[98,542,543],{"class":219},"Code",[98,545,141],{"class":103},[98,547,549],{"class":100,"line":548},25,[98,550,407],{"class":103},[98,552,554,557,559,562,565,567,569,572,574,576,578,581,584,586],{"class":100,"line":553},26,[98,555,556],{"class":219},"        _",[98,558,135],{"class":103},[98,560,561],{"class":219}," _ ",[98,563,564],{"class":103},"=",[98,566,326],{"class":219},[98,568,79],{"class":103},[98,570,571],{"class":107},"WriteString",[98,573,111],{"class":103},[98,575,281],{"class":219},[98,577,135],{"class":103},[98,579,580],{"class":103}," \"",[98,582,583],{"class":270},"ok",[98,585,223],{"class":103},[98,587,141],{"class":103},[98,589,591],{"class":100,"line":590},27,[98,592,593],{"class":103},"    })\n",[98,595,597,600,602,605,607,609,611,614,616,618,621,623,625],{"class":100,"line":596},28,[98,598,599],{"class":219},"    log",[98,601,79],{"class":103},[98,603,604],{"class":107},"Fatal",[98,606,111],{"class":103},[98,608,300],{"class":219},[98,610,79],{"class":103},[98,612,613],{"class":107},"ListenAndServe",[98,615,111],{"class":103},[98,617,223],{"class":103},[98,619,620],{"class":270},":8080",[98,622,223],{"class":103},[98,624,135],{"class":103},[98,626,627],{"class":103}," nil))\n",[98,629,631],{"class":100,"line":630},29,[98,632,633],{"class":103},"}\n",[81,635,637],{"id":636},"payload-fields","Payload fields",[639,640,641,660],"table",{},[642,643,644],"thead",{},[645,646,647,651,654,657],"tr",{},[648,649,650],"th",{},"Field",[648,652,653],{},"JSON",[648,655,656],{},"Type",[648,658,659],{},"Description",[661,662,663,691,713,732,752,790,812,831,851,873],"tbody",{},[645,664,665,671,675,679],{},[666,667,668],"td",{},[57,669,670],{},"WebhookType",[666,672,673],{},[57,674,63],{},[666,676,677],{},[57,678,670],{},[666,680,681,148,684,687,688,690],{},[57,682,683],{},"WebhookReceivingSMS",[57,685,686],{},"WebhookRentSMS",", or ",[57,689,147],{}," for anything else.",[645,692,693,697,702,707],{},[666,694,695],{},[57,696,534],{},[666,698,699],{},[57,700,701],{},"operation_id",[666,703,704],{},[57,705,706],{},"int64",[666,708,709,712],{},[57,710,711],{},"tzid"," of the operation or rent.",[645,714,715,720,725,729],{},[666,716,717],{},[57,718,719],{},"UserID",[666,721,722],{},[57,723,724],{},"user_id",[666,726,727],{},[57,728,706],{},[666,730,731],{},"Account id.",[645,733,734,739,744,749],{},[666,735,736],{},[57,737,738],{},"CountryCode",[666,740,741],{},[57,742,743],{},"country_code",[666,745,746],{},[57,747,748],{},"int",[666,750,751],{},"Country code of the number.",[645,753,754,759,764,769],{},[666,755,756],{},[57,757,758],{},"Number",[666,760,761],{},[57,762,763],{},"number",[666,765,766],{},[57,767,768],{},"string",[666,770,771,772,775,776,779,780,783,784,128,786,789],{},"Numbers: ",[57,773,774],{},"+"," and the full number (",[57,777,778],{},"+79001234567","), or ",[57,781,782],{},"hidden",". Rent: the full number in digits without ",[57,785,774],{},[57,787,788],{},"79001234567",").",[645,791,792,797,802,806],{},[666,793,794],{},[57,795,796],{},"Sender",[666,798,799],{},[57,800,801],{},"sender",[666,803,804],{},[57,805,768],{},[666,807,808,809,79],{},"Sender of the SMS, e.g. ",[57,810,811],{},"VK",[645,813,814,819,824,828],{},[666,815,816],{},[57,817,818],{},"Message",[666,820,821],{},[57,822,823],{},"message",[666,825,826],{},[57,827,768],{},[666,829,830],{},"Full SMS text.",[645,832,833,837,841,845],{},[666,834,835],{},[57,836,543],{},[666,838,839],{},[57,840,57],{},[666,842,843],{},[57,844,768],{},[666,846,847,848,850],{},"Code extracted from the SMS; ",[57,849,147],{}," when none was found.",[645,852,853,858,863,867],{},[666,854,855],{},[57,856,857],{},"TimeStart",[666,859,860],{},[57,861,862],{},"time_start",[666,864,865],{},[57,866,768],{},[666,868,869,870,79],{},"Numbers: when the operation was ordered. Rent: when the SMS arrived. ",[57,871,872],{},"YYYY-MM-DD HH:MM:SS",[645,874,875,880,885,889],{},[666,876,877],{},[57,878,879],{},"TimeLeft",[666,881,882],{},[57,883,884],{},"time_left",[666,886,887],{},[57,888,706],{},[666,890,891],{},"Time left: seconds for numbers, minutes for rent.",[893,894,895],"style",{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}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 .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 .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 .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":94,"searchDepth":17,"depth":17,"links":897},[898,899],{"id":83,"depth":17,"text":84},{"id":636,"depth":17,"text":637},"Receive SMS as HTTP callbacks and parse them with ParseWebhook.","md",{},{"order":32},{"title":29,"description":900},"18SqaZoF1wbd6qr9E5yA46aVLt-buMSYlfXC-de-dAc",[907,909],{"title":19,"path":20,"stem":21,"description":908,"order":22},"Balance, profile, payments and the webhook URL — client.User().",null,1795164111719]