[{"data":1,"prerenderedAt":500},["ShallowReactive",2],{"docs-nav":3,"docs-\u002Fdocs\u002Fapi\u002Fsubscribe":70},[4,10,14,19,23,26,29,33,36,40,43,47,50,54,58,62,66],{"title":5,"path":6,"order":7,"section":8,"group":9},"Concepts","\u002Fdocs\u002Fapi\u002Fconcepts",1,"api",null,{"title":11,"path":12,"order":7,"section":13,"group":9},"Introduction","\u002Fdocs","general",{"title":15,"path":16,"order":7,"section":17,"group":18},"Usage","\u002Fdocs\u002Fsdk\u002Fusage","sdk","Script",{"title":20,"path":21,"order":22,"section":8,"group":9},"\u002Fv1\u002Fme","\u002Fdocs\u002Fapi\u002Fme",2,{"title":24,"path":25,"order":22,"section":13,"group":9},"Getting started","\u002Fdocs\u002Fgetting-started",{"title":24,"path":27,"order":22,"section":17,"group":28},"\u002Fdocs\u002Fsdk\u002Fpackage","Package",{"title":30,"path":31,"order":32,"section":8,"group":9},"\u002Fv1\u002Fsubscribe","\u002Fdocs\u002Fapi\u002Fsubscribe",3,{"title":34,"path":35,"order":32,"section":17,"group":28},"Browser client","\u002Fdocs\u002Fsdk\u002Fpackage\u002Fclient",{"title":37,"path":38,"order":39,"section":8,"group":9},"\u002Fv1\u002Funsubscribe","\u002Fdocs\u002Fapi\u002Funsubscribe",4,{"title":41,"path":42,"order":39,"section":17,"group":28},"Server client","\u002Fdocs\u002Fsdk\u002Fpackage\u002Fserver",{"title":44,"path":45,"order":46,"section":8,"group":9},"\u002Fv1\u002Fevents","\u002Fdocs\u002Fapi\u002Fevents",5,{"title":48,"path":49,"order":46,"section":17,"group":28},"Types","\u002Fdocs\u002Fsdk\u002Fpackage\u002Ftypes",{"title":51,"path":52,"order":53,"section":8,"group":9},"\u002Fv1\u002Fsend","\u002Fdocs\u002Fapi\u002Fsend",6,{"title":55,"path":56,"order":57,"section":8,"group":9},"\u002Fv1\u002Fbroadcasts","\u002Fdocs\u002Fapi\u002Fbroadcasts",7,{"title":59,"path":60,"order":61,"section":8,"group":9},"\u002Fv1\u002Fgroups","\u002Fdocs\u002Fapi\u002Fgroups",8,{"title":63,"path":64,"order":65,"section":8,"group":9},"\u002Fv1\u002Fsubscribers","\u002Fdocs\u002Fapi\u002Fsubscribers",9,{"title":67,"path":68,"order":69,"section":8,"group":9},"Webhooks","\u002Fdocs\u002Fapi\u002Fwebhooks",10,{"id":71,"title":30,"apiModule":9,"body":72,"description":492,"extension":493,"generated":494,"group":9,"meta":495,"navigation":496,"order":32,"path":31,"section":8,"seo":497,"stem":498,"__hash__":499},"docs\u002Fdocs\u002Fapi\u002Fsubscribe.md",{"type":73,"value":74,"toc":489},"minimark",[75,82,100,112,119,132,142,153,158,291,296,362,371,407,413,418,461,485],[76,77,79],"h1",{"id":78},"v1subscribe",[80,81,30],"code",{},[83,84,85,86,89,90,93,94,99],"p",{},"Project auth (",[80,87,88],{},"?project="," query param or ",[80,91,92],{},"X-LitePush-Project"," header). See ",[95,96,98],"a",{"href":97},"\u002Fdocs\u002Fapi\u002Fconcepts#authentication","Concepts → Authentication",".",[83,101,102,103,107,108,111],{},"This is called from the user's browser. In normal use, ",[104,105,106],"strong",{},"you don't call it directly"," — the ",[95,109,110],{"href":16},"Browser SDK"," does. It's documented here for custom integrations (e.g. a native app shell, a server-side mirror, or debugging).",[113,114,116],"h2",{"id":115},"post-v1subscribe",[80,117,118],{},"POST \u002Fv1\u002Fsubscribe",[83,120,121,124,125,128,129,99],{},[104,122,123],{},"What it does:"," Stores a browser's push subscription so LitePush can deliver pushes to it later. Idempotent on ",[80,126,127],{},"(project_id, endpoint)"," — calling it twice for the same browser just refreshes ",[80,130,131],{},"last_seen_at",[83,133,134,137,138,141],{},[104,135,136],{},"When to use it:"," Almost never. ",[80,139,140],{},"litepush.subscribe()"," in the browser SDK calls this for you with the right body. Call it manually only if you're (a) replacing the SDK with your own implementation, or (b) seeding subscribers from a server-side flow.",[83,143,144,147,148,89,150,152],{},[104,145,146],{},"Authentication:"," Project — ",[80,149,88],{},[80,151,92],{}," header.",[83,154,155],{},[104,156,157],{},"Request body:",[159,160,161,180],"table",{},[162,163,164],"thead",{},[165,166,167,171,174,177],"tr",{},[168,169,170],"th",{},"Field",[168,172,173],{},"Type",[168,175,176],{},"Required",[168,178,179],{},"Description",[181,182,183,203,221,238,268],"tbody",{},[165,184,185,191,194,197],{},[186,187,188],"td",{},[80,189,190],{},"endpoint",[186,192,193],{},"string (URL, ≤ 2048 chars)",[186,195,196],{},"yes",[186,198,199,200,99],{},"The push gateway URL the browser handed back. From ",[80,201,202],{},"PushSubscription.endpoint",[165,204,205,210,213,215],{},[186,206,207],{},[80,208,209],{},"keys.p256dh",[186,211,212],{},"string (≤ 256 chars)",[186,214,196],{},[186,216,217,218,99],{},"Base64url-encoded ECDH public key. From ",[80,219,220],{},"PushSubscription.getKey('p256dh')",[165,222,223,228,230,232],{},[186,224,225],{},[80,226,227],{},"keys.auth",[186,229,212],{},[186,231,196],{},[186,233,234,235,99],{},"Base64url-encoded auth secret. From ",[80,236,237],{},"PushSubscription.getKey('auth')",[165,239,240,245,247,250],{},[186,241,242],{},[80,243,244],{},"external_id",[186,246,212],{},[186,248,249],{},"no",[186,251,252,253,256,257,260,261,264,265,99],{},"Your own user ID. Lets you target this user across all their devices via ",[80,254,255],{},"target: { type: 'user', external_id }",". May only contain ",[104,258,259],{},"letters, numbers, underscores, and hyphens"," (",[80,262,263],{},"A–Z a–z 0–9 _ -",") — anything else returns ",[80,266,267],{},"400",[165,269,270,275,282,284],{},[186,271,272],{},[80,273,274],{},"group_ids",[186,276,277,278,281],{},"string",[279,280],"span",{}," (≤ 50 items)",[186,283,249],{},[186,285,286,287,290],{},"Group IDs to assign this subscriber to at create time. ",[104,288,289],{},"Invalid IDs (typos, deleted groups, or IDs from another project) are silently dropped — the subscriber is still created with no membership in those groups."," See note under Errors below.",[83,292,293],{},[104,294,295],{},"Example:",[297,298,303],"pre",{"className":299,"code":300,"language":301,"meta":302,"style":302},"language-sh shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","curl -X POST 'https:\u002F\u002Fapi.litepush.dev\u002Fv1\u002Fsubscribe?project=prj_xxxxxxxx' \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\n    \"endpoint\": \"https:\u002F\u002Ffcm.googleapis.com\u002Ffcm\u002Fsend\u002FcZxJ...\",\n    \"keys\": {\n      \"p256dh\": \"BNcRdreALR...\",\n      \"auth\": \"tBHItJI5sj...\"\n    },\n    \"external_id\": \"user_42\",\n    \"group_ids\": [\"grp_01HXM...\"]\n  }'\n","sh","",[80,304,305,311,316,321,326,331,336,341,346,351,356],{"__ignoreMap":302},[279,306,308],{"class":307,"line":7},"line",[279,309,310],{},"curl -X POST 'https:\u002F\u002Fapi.litepush.dev\u002Fv1\u002Fsubscribe?project=prj_xxxxxxxx' \\\n",[279,312,313],{"class":307,"line":22},[279,314,315],{},"  -H \"Content-Type: application\u002Fjson\" \\\n",[279,317,318],{"class":307,"line":32},[279,319,320],{},"  -d '{\n",[279,322,323],{"class":307,"line":39},[279,324,325],{},"    \"endpoint\": \"https:\u002F\u002Ffcm.googleapis.com\u002Ffcm\u002Fsend\u002FcZxJ...\",\n",[279,327,328],{"class":307,"line":46},[279,329,330],{},"    \"keys\": {\n",[279,332,333],{"class":307,"line":53},[279,334,335],{},"      \"p256dh\": \"BNcRdreALR...\",\n",[279,337,338],{"class":307,"line":57},[279,339,340],{},"      \"auth\": \"tBHItJI5sj...\"\n",[279,342,343],{"class":307,"line":61},[279,344,345],{},"    },\n",[279,347,348],{"class":307,"line":65},[279,349,350],{},"    \"external_id\": \"user_42\",\n",[279,352,353],{"class":307,"line":69},[279,354,355],{},"    \"group_ids\": [\"grp_01HXM...\"]\n",[279,357,359],{"class":307,"line":358},11,[279,360,361],{},"  }'\n",[83,363,364],{},[104,365,366,367,370],{},"Success — ",[80,368,369],{},"201 Created",":",[297,372,376],{"className":373,"code":374,"language":375,"meta":302,"style":302},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{ \"id\": \"sub_01HXM...\" }\n","json",[80,377,378],{"__ignoreMap":302},[279,379,380,384,387,391,394,396,398,402,404],{"class":307,"line":7},[279,381,383],{"class":382},"sMK4o","{",[279,385,386],{"class":382}," \"",[279,388,390],{"class":389},"spNyl","id",[279,392,393],{"class":382},"\"",[279,395,370],{"class":382},[279,397,386],{"class":382},[279,399,401],{"class":400},"sfazB","sub_01HXM...",[279,403,393],{"class":382},[279,405,406],{"class":382}," }\n",[83,408,409,410,412],{},"The returned ",[80,411,390],{}," is the LitePush subscriber identifier — keep it if you want to manage group membership server-side later.",[83,414,415],{},[104,416,417],{},"Errors:",[419,420,421,434,439,445,451],"ul",{},[422,423,424,427,428,430,431,433],"li",{},[80,425,426],{},"400 missing_project"," — neither ",[80,429,88],{}," nor ",[80,432,92],{}," was provided.",[422,435,436,438],{},[80,437,267],{}," (validation) — body shape is wrong (e.g. endpoint isn't a URL, keys missing).",[422,440,441,444],{},[80,442,443],{},"404 project_not_found"," — the project ID doesn't exist.",[422,446,447,450],{},[80,448,449],{},"403 subscriber_limit_reached"," — the project is at its plan's subscriber cap. Returned with the cap value in the message.",[422,452,453,456,457,99],{},[80,454,455],{},"429 rate_limited"," — see ",[95,458,460],{"href":459},"\u002Fdocs\u002Fapi\u002Fconcepts#rate-limits","Concepts → Rate limits",[462,463,464],"blockquote",{},[83,465,466,472,473,478,479,484],{},[104,467,468,469,471],{},"Invalid ",[80,470,274],{}," do NOT cause an error."," They're silently dropped while the subscriber row is still created successfully. The choice is deliberate — failing the whole subscribe over a typo would block real users from opting in, and the SDK gives you no good recovery path. If initial group membership matters to you, fetch ",[95,474,475],{"href":60},[80,476,477],{},"GET \u002Fv1\u002Fgroups"," first to validate, or assign membership in a second call via ",[95,480,481],{"href":60},[80,482,483],{},"POST \u002Fv1\u002Fgroups\u002F:id\u002Fsubscribers"," (which DOES 404 on bad group IDs).",[486,487,488],"style",{},"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 .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":302,"searchDepth":22,"depth":22,"links":490},[491],{"id":115,"depth":22,"text":118},"Register a browser's push subscription. Project-authed; normally called for you by the browser SDK.","md",false,{},true,{"title":30,"description":492},"docs\u002Fapi\u002Fsubscribe","kM8bShads8qDLwjc1ikmMv4leWGJtVTCzTOjqWFX77Y",1780560203630]