1"use strict";(self.webpackChunkreddit_ads_api_site=self.webpackChunkreddit_ads_api_site||[]).push([[6371],{12849:(e,t,n)=>{n.d(t,{Ay:()=>x});var s=n(96540),o=n(56555),i=n(26434);function r(e){let t=e;return t=t.replace(/\n\s*"screen_dimensions"\s*:\s*\{\s*\}\s*,?/g,"\n"),t=t.replace(/\n\s*"products"\s*:\s*\[\s*\{\s*\}\s*\]\s*,?/g,"\n"),t=t.replace(/\n\s*"user"\s*:\s*\{\s*\}\s*,?/g,"\n"),t=t.replace(/\n\s*"metadata"\s*:\s*\{\s*\}\s*,?/g,"\n"),t=t.replace(/\s*"destination"\s*:\s*\{\s*"url"\s*:\s*"",\s*"type"\s*:\s*"URL"\s*\}\s*,?/g,""),t=t.replace(/\s*"thumbnail"\s*:\s*\{\s*"media"\s*:\s*\{\s*"url"\s*:\s*"",\s*"type"\s*:\s*"URL"\s*\}\s*\}\s*,?/g,""),t=t.replace(/\n\s*"schedule"\s*:\s*\{\s*\}\s*,?/g,"\n"),t}function a(e,t){return t?.[e]?t[e]:e.charAt(0).toLowerCase()+e.slice(1)}var l=n(27774);function c(e){const{template:t,uniqueVariables:n,values:s,selectedOptions:o,variableOptions:i,optionalVariables:c,optionalVariableJsonKeys:d,allVariablesOptional:p,omitOptionalUnlessControllerAllows:u}=e;let h=t;n.forEach(e=>{let t;if(i[e.name]){const n=i[e.name];t=(0,l.sW)(n,o[e.name])}else t=s[e.name]||"";h=h.replaceAll(e.placeholder,t)}),u?.forEach(e=>{if(!(0,l._c)(e.controllerVariableName,e.allowValues,i,o,s)){const t=a(e.optionalVariableName,d);h=function(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let s=e.replace(new RegExp(`,\\s*\\n\\s*"${n}"\\s*:\\s*"[^"]*"`,"g"),"");return s=s.replace(new RegExp(`\\n\\s*"${n}"\\s*:\\s*"[^"]*"\\s*,`,"g"),"\n"),s=s.replace(new RegExp(`\\n\\s*"${n}"\\s*:\\s*"[^"]*"\\s*\\n`,"g"),"\n"),s}(h,t)}});(p?n.map(e=>e.name):c).forEach(e=>{let t;if(t=i[e]?(0,l.sW)(i[e],o[e]):s[e]||"",!t.trim()){const t=a(e,d);h=function(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");let s=e.replace(new RegExp(`,\\s*\\n\\s*"${n}"\\s*:\\s*""`,"g"),"");return s=s.replace(new RegExp(`\\n\\s*"${n}"\\s*:\\s*""\\s*,`,"g"),"\n"),s=s.replace(new RegExp(`\\n\\s*"${n}"\\s*:\\s*""\\s*\\n`,"g"),"\n"),s=s.replace(new RegExp(`\\n\\s*"${n}"\\s*:\\s*,`,"g"),"\n"),s}(h,t)}});if(p||c.length>0||(u?.length??0)>0){for(let e=0;e<4;e+=1)h=r(h);h=function(e){let t=e,n="";for(;n!==t;)n=t,t=t.replace(/,(\s*[}\]])/g,"$1"),t=t.replace(/}(\s*),(\s*\r?\n\s*)(})/g,"}$1$2$3");return t}(h)}return h}var d=n(54233),p=n(71765);var u=n(31988),h=n(74848);function m(e,t,n){return e?(0,h.jsx)(p.Highlight,{theme:p.themes.dracula,code:e,language:n,children:({tokens:e,getTokenProps:n})=>(0,h.jsx)(h.Fragment,{children:e.map((s,o)=>(0,h.jsxs)("span",{children:[s.map((e,s)=>(0,h.jsx)("span",{...n({token:e})},`${t}-${o}-${s}`)),o<e.length-1&&"\n"]},`${t}-line-${o}`))})}):null}function f(e){const{template:t,variables:n,language:s,variableOptions:i,variableDescriptions:r,values:a,selectedOptions:c,activeDropdown:d,setActiveDropdown:p,dateTimeSet:f,listboxIdPrefix:x,triggerRefs:g,finishCloseDropdown:j,handleValueChange:y,handleOptionToggle:b,disableTextUnlessControllerAllows:w}=e,v=[];let A=0;if([...n].sort((e,t)=>e.start-t.start).forEach((e,n)=>{if(e.start>A){const i=t.slice(A,e.start);v.push((0,h.jsx)("span",{className:o.A.codeText,children:m(i,`seg-${n}`,s)},`text-${n}`))}const k=!!i[e.name],C=(0,l.On)(e.name,i,c),_=k?c[e.name]?.size>0:!!a[e.name]?.trim();if(k){const t=`${e.name}-${n}`,s=`${x}-lb-${n}`;v.push((0,h.jsxs)("span",{className:o.A.inlineFieldWrapper,children:[(0,h.jsxs)("button",{ref:e=>{g.current[t]=e},type:"button",className:`${o.A.inlineDropdownTrigger} ${_?o.A.filled:""}`,"aria-haspopup":"listbox","aria-expanded":d===t,"aria-controls":s,onClick:()=>p(d===t?null:t),children:[C,(0,h.jsx)("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:(0,h.jsx)("path",{d:"M2 4L5 7L8 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})]}),d===t&&(0,h.jsx)(u.b,{variable:e.name,config:i[e.name],variableDescriptions:r,selected:c[e.name]||new Set,onToggle:n=>b(e.name,n,t),onClose:()=>j(t),triggerRefKey:t,triggerRefs:g,listboxId:s})]},`var-${n}`))}else if(f.has(e.name)){const t=function(e){const t=new Date(e.trim());if(Number.isNaN(t.getTime()))return"";const n=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}(a[e.name]||""),s=`cb-dt-cols-${n}`,i=(0,l.bY)(e.name,r,"Shown in your local time and date format; copied as UTC (ISO 8601 ending in Z). Calendar = date; the three columns are hour, minute, second (24-hour).");v.push((0,h.jsx)("span",{className:o.A.inlineFieldWrapper,children:(0,h.jsxs)("span",{className:o.A.inlineDatetimeStack,children:[(0,h.jsxs)("div",{id:s,className:o.A.datetimeLegendRow,children:[(0,h.jsx)("div",{className:o.A.datetimeLegendDateSlot,children:(0,h.jsx)("span",{className:o.A.datetimeNativeColumnLegend,children:"Date"})}),(0,h.jsx)("span",{className:o.A.datetimeNativeColumnLegend,children:"hh : min : s"})]}),(0,h.jsx)("input",{type:"datetime-local",step:1,className:`${o.A.inlineDatetimeInput} ${_?o.A.filled:""}`,value:t,onChange:t=>{const n=t.target.value;y(e.name,n?function(e){const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().replace(/\.\d+Z$/,"Z")}(n):"")},title:i,"aria-label":i,"aria-describedby":s,autoComplete:"off","data-1p-ignore":!0,"data-lpignore":"true"})]})},`var-${n}`))}else{const t=(0,l.Z7)(e.name),s=(0,l.bY)(e.name,r),d=w?.find(t=>t.variableName===e.name),p=!!d&&!(0,l._c)(d.controllerVariableName,d.allowValues,i,c,a);v.push((0,h.jsx)("span",{className:o.A.inlineFieldWrapper,children:(0,h.jsx)("input",{type:"text",className:`${o.A.inlineInput} ${_?o.A.filled:""}`,value:a[e.name],onChange:t=>y(e.name,t.target.value),placeholder:t,title:s,"aria-label":s,disabled:p,style:{width:`${Math.max(t.length,a[e.name]?.length||0)+2}ch`},autoComplete:"off","data-1p-ignore":!0,"data-lpignore":"true"})},`var-${n}`))}A=e.end}),A<t.length){const e=t.slice(A);v.push((0,h.jsx)("span",{className:o.A.codeText,children:m(e,"seg-end",s)},"text-end"))}return v}function x({template:e,title:t="Command Builder",description:n,variableDescriptions:r={},defaultValues:a={},variableOptions:l={},language:p="bash",optionalVariables:u=[],optionalVariableJsonKeys:m,allVariablesOptional:x=!1,dateTimeVariables:g=[],omitOptionalUnlessControllerAllows:j,disableTextUnlessControllerAllows:y}){const b=(0,s.useMemo)(()=>new Set(u),[u]),w=(0,s.useMemo)(()=>new Set(g),[g]),v=(0,s.useMemo)(()=>{const t=/\{\{([^}]+)\}\}/g,n=[],s=new Set;let o;for(;null!==(o=t.exec(e));){const e=o[1].trim();s.has(e)||s.add(e),n.push({name:e,placeholder:o[0],start:o.index,end:o.index+o[0].length})}return n},[e]),A=(0,s.useMemo)(()=>{const e=new Set;return v.filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}
1,[v]),[k,C]=(0,s.useState)(()=>{const e={};return A.forEach(t=>{e[t.name]=a[t.name]||""}),e}),[_,R]=(0,s.useState)(()=>{const e={};return Object.keys(l).forEach(t=>{const n=a[t];if(n){const s=l[t].separator||",";e[t]=new Set(n.split(s).map(e=>e.trim()))}else e[t]=new Set}),e}),[N,S]=(0,s.useState)(null),[D,E]=(0,s.useState)(!1),[$,T]=(0,s.useState)(!1),L=(0,s.useRef)({}),I=(0,s.useId)(),O=(0,s.useCallback)(e=>{S(null),e&&requestAnimationFrame(()=>{L.current[e]?.focus()})},[]);(0,s.useEffect)(()=>{const e=e=>{"Escape"===e.key&&(N?O(N):T(!1))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[N,O]);const B=(0,s.useMemo)(()=>!!x||A.every(e=>!!b.has(e.name)||(l[e.name]?_[e.name]?.size>0:k[e.name]?.trim())),[x,A,k,_,l,b]),F=(0,s.useCallback)(()=>{C(()=>{const e={};return A.forEach(t=>{e[t.name]=""}),e}),R(()=>{const e={};return Object.keys(l).forEach(t=>{e[t]=new Set}),e})},[A,l]),U=(0,s.useCallback)(()=>{C(()=>{const e={};return A.forEach(t=>{e[t.name]=a[t.name]||""}),e}),R(()=>{const e={};return Object.keys(l).forEach(t=>{const n=a[t];if(n){const s=l[t].separator||",";e[t]=new Set(n.split(s).map(e=>e.trim()))}else e[t]=new Set}),e})},[A,l,a]),V=(0,s.useCallback)((e,t)=>{C(n=>({...n,[e]:t}))},[]),z=(0,s.useCallback)((e,t,n)=>{const s=l[e],o=!1!==s?.multiSelect;R(n=>{if(o){const s=new Set(n[e]||[]);return s.has(t)?s.delete(t):s.add(t),{...n,[e]:s}}return{...n,[e]:new Set([t])}}),!o&&n&&O(n)},[l,O]),P=(0,s.useCallback)(async()=>{if(!B)return;const t=c({template:e,uniqueVariables:A,values:k,selectedOptions:_,variableOptions:l,optionalVariables:u,optionalVariableJsonKeys:m,allVariablesOptional:x,omitOptionalUnlessControllerAllows:j});await(0,d.l)(t),E(!0),setTimeout(()=>E(!1),2e3)},[e,A,k,_,l,B,u,m,x,j]);return(0,h.jsx)(i.Y,{title:t,description:n,language:p,warningBadge:B?null:(0,h.jsx)("span",{className:o.A.warningBadge,children:u.length>0?"Fill required fields":"Fill all fields"}),showClearReset:A.length>0,onClear:F,onReset:U,canCopy:B,copied:D,onCopy:P,isExpanded:$,onExpand:()=>T(!0),onCloseFullscreen:()=>T(!1),renderCode:()=>f({template:e,variables:v,language:p,variableOptions:l,variableDescriptions:r,values:k,selectedOptions:_,activeDropdown:N,setActiveDropdown:S,dateTimeSet:w,listboxIdPrefix:I,triggerRefs:L,finishCloseDropdown:O,handleValueChange:V,handleOptionToggle:z,disableTextUnlessControllerAllows:y})})}n(54690),n(27142),n(53963)},17194:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/check-username-730d8ba6fa4b8147f23abe916991eb59.webp"},26434:(e,t,n)=>{n.d(t,{Y:()=>u});var s=n(96540),o=n(86856),i=n(56555),r=n(54690),a=n(74848);const l={"aria-label":"Clear all fields",title:"Empty every field and dropdown so you can paste your own values"},c={"aria-label":"Restore default example values",title:"Restore the page\u2019s example defaults"};function d({canCopy:e,copied:t,onCopy:n,copyDisabledTitle:s,copyTitle:r="Copy to clipboard",copyAriaLabel:l}){const c=e?t?"Copied!":r:s??r,d=l??(t?"Copied":"Copy to clipboard");return(0,a.jsx)("button",{type:"button",className:`${i.A.copyButton} ${t?i.A.copied:""} ${e?"":i.A.disabled}`,onClick:n,disabled:!e,"aria-label":d,title:c,children:t?(0,a.jsx)(o.Ay,{glyph:"checkmark",label:"",size:"md",width:18,height:18}):(0,a.jsx)(o.Ay,{glyph:"duplicate",label:"",size:"md",width:18,height:18})})}function p({clearButton:e,resetButton:t,onClear:n,onReset:s}){return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("button",{type:"button",className:i.A.toolbarLinkButton,onClick:n,"aria-label":e["aria-label"],title:e.title,children:"Clear"}),(0,a.jsx)("button",{type:"button",className:i.A.toolbarLinkButton,onClick:s,"aria-label":t["aria-label"],title:t.title,children:"Reset"})]})}function u({title:e,description:t,language:n="bash",warningBadge:u,fullscreenWarningBadge:h,repeatWarningInFullscreen:m=!1,showClearReset:f=!0,onClear:x,onReset:g,clearButton:j=l,resetButton:y=c,canCopy:b,copied:w,onCopy:v,copyDisabledTitle:A,copyTitle:k="Copy to clipboard",copyAriaLabel:C,isExpanded:_,onExpand:R,onCloseFullscreen:N,fullscreenTitle:S,renderCode:D,afterInlineCode:E,afterFullscreenCode:$,betweenCodeAndAssist:T,children:L,extendedAssistLayout:I=!1}){const O=S??e,B=h??(m?u:null);return(0,s.useEffect)(()=>{const e=_?window.scrollY:0;return _&&Object.assign(document.body.style,{position:"fixed",top:`-${e}px`,left:"0",right:"0",width:"100%"}),()=>{_&&(Object.assign(document.body.style,{position:"",top:"",left:"",right:"",width:""}),window.scrollTo(0,e))}},[_]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:i.A.container,children:[(0,a.jsx)("div",{className:i.A.header,children:(0,a.jsxs)("div",{className:i.A.headerLeft,children:[(0,a.jsx)("h3",{className:i.A.title,children:e}),t?(0,a.jsx)("div",{className:i.A.description,children:t}):null]})}),(0,a.jsxs)("div",{className:i.A.inlineCodeSection,children:[(0,a.jsxs)("div",{className:i.A.inlineToolbar,children:[(0,a.jsx)("span",{className:i.A.languageTag,children:n}),(0,a.jsxs)("div",{className:i.A.toolbarActions,children:[u,f&&(0,a.jsx)(p,{clearButton:j,resetButton:y,onClear:x,onReset:g}),(0,a.jsx)("button",{type:"button",className:i.A.expandButton,onClick:R,"aria-label":"Expand",title:"Expand",children:(0,a.jsx)(o.Ay,{glyph:"expandRight",label:"",size:"md",width:18,height:18})}),(0,a.jsx)(d,{canCopy:b,copied:w,onCopy:v,copyDisabledTitle:A,copyTitle:k,copyAriaLabel:C})]})]}),(0,a.jsxs)("div",{className:`${i.A.inlineCodeBlock} ${I?i.A.inlineCodeBlockJoinAssist:""}`,children:[(0,a.jsx)("pre",{className:i.A.inlinePre,children:(0,a.jsx)("code",{className:i.A.inlineCode,children:D("inline")})}),E]})]}),T,L]}),_&&(0,a.jsx)("div",{className:i.A.fullscreenOverlay,onClick:N,children:(0,a.jsxs)("div",{className:i.A.fullscreenContent,onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:i.A.fullscreenHeader,children:[(0,a.jsx)("span",{className:i.A.fullscreenTitle,children:O}),(0,a.jsxs)("div",{className:i.A.toolbarActions,children:[B,f&&(0,a.jsx)(p,{clearButton:j,resetButton:y,onClear:x,onReset:g}),(0,a.jsx)(d,{canCopy:b,copied:w,onCopy:v,copyDisabledTitle:A,copyTitle:k,copyAriaLabel:C}),(0,a.jsx)("button",{type:"button",className:i.A.closeButton,onClick:N,"aria-label":"Close",children:(0,a.jsx)(r.M,{})})]})]}),(0,a.jsxs)("div",{className:i.A.fullscreenBody,children:[(0,a.jsxs)("div",{className:`${i.A.inlineCodeBlock} ${I?i.A.inlineCodeBlockJoinAssist:""}`,children:[(0,a.jsx)("pre",{className:i.A.inlinePre,children:(0,a.jsx)("code",{className:i.A.inlineCode,children:D("fullscreen")})}),$]}),T]})]})})]})}},27142:(e,t,n)=>{n.d(t,{y:()=>o});var s=n(96540);function o(e){(0,s.useEffect)(()=>
1{if(!e)return;const t=window.scrollY;return Object.assign(document.body.style,{position:"fixed",top:`-${t}px`,left:"0",right:"0",width:"100%"}),()=>{Object.assign(document.body.style,{position:"",top:"",left:"",right:"",width:""}),window.scrollTo(0,t)}},[e])}},27774:(e,t,n)=>{function s(e,t,n){const s=t[e];if(!s)return"";const o=n[e];if(o?.size>0){if(s.joinAsJsonStringLiterals)return Array.from(o).join(", ");const e=s.separator||",";return Array.from(o).join(e)}return e}function o(e,t){if(!t?.size)return"";const n=Array.from(t);if(e.joinAsJsonStringLiterals)return n.map(e=>JSON.stringify(e)).join(", ");const s=e.separator||",";return n.join(s)}function i(e,t,n,s,i){let r="";return r=n[e]?o(n[e],s[e]):i[e]||"",t.includes(r.trim())}function r(e,t){const n=(t[e]||"").trim(),s=/^\{\{\s*(.+?)\s*\}\}$/.exec(n);if(s){const t=s[1].trim();return t===e.trim()?"":t}return n}function a(e){return`{{${e}}}`}function l(e,t,n){const s=r(e,t),o=a(e),i=s?`${o} \u2014 ${s}`:o;return n?`${i}. ${n}`:i}n.d(t,{On:()=>s,Z7:()=>a,_c:()=>i,bY:()=>l,eo:()=>r,sW:()=>o})},31988:(e,t,n)=>{n.d(t,{b:()=>d});var s=n(96540),o=n(40961),i=n(56555),r=n(86856);function a(e){return e?Array.from(e.querySelectorAll("[data-cb-option]")):[]}var l=n(27774),c=n(74848);function d({variable:e,config:t,variableDescriptions:n,selected:d,onToggle:p,onClose:u,triggerRefKey:h,triggerRefs:m,listboxId:f}){const x=(0,s.useRef)(null),g=(0,s.useId)(),j=!1!==t.multiSelect,[y,b]=(0,s.useState)({top:0,left:0}),w=(0,s.useCallback)(()=>m.current[h]??null,[h,m]),v=(0,s.useCallback)(()=>{const e=w();if(!e)return;const t=e.getBoundingClientRect(),n=x.current,s=n?.offsetHeight??250,o=n?.offsetWidth??280;let i=window.innerHeight-t.bottom<s&&t.top>s?t.top-s-4:t.bottom+4,r=t.left;r+o>window.innerWidth-8&&(r=Math.max(8,window.innerWidth-o-8)),r<8&&(r=8),i+s>window.innerHeight-8&&(i=Math.max(8,window.innerHeight-s-8)),i<8&&(i=8),b({top:i,left:r})},[w]);(0,s.useLayoutEffect)(()=>{v();const e=requestAnimationFrame(()=>v());return()=>cancelAnimationFrame(e)},[v]),(0,s.useEffect)(()=>{const e=x.current;if(!e)return;let t=0;const n=new ResizeObserver(()=>{t&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{t=0,v()})});return n.observe(e),()=>{t&&cancelAnimationFrame(t),n.disconnect()}},[v]),(0,s.useEffect)(()=>{const e=w();if(!e)return;const t=()=>v(),n=function(e){const t=[];let n=e?.parentElement??null;for(;n;){const e=window.getComputedStyle(n),s=e.overflowY,o=e.overflowX;(/^(auto|scroll|overlay)$/.test(s)||/^(auto|scroll|overlay)$/.test(o))&&t.push(n),n=n.parentElement}return t}(e);for(const s of n)s.addEventListener("scroll",t,{passive:!0});return window.addEventListener("scroll",t,{passive:!0}),window.addEventListener("resize",t),()=>{for(const e of n)e.removeEventListener("scroll",t);window.removeEventListener("scroll",t),window.removeEventListener("resize",t)}},[v,w]),(0,s.useLayoutEffect)(()=>{const e=x.current;if(!e)return;const t=a(e),n=t.find(e=>d.has(e.dataset.cbOptionValue??""))??t[0];n?.focus()},[]),(0,s.useEffect)(()=>{const e=e=>{const t=e.target;x.current&&!x.current.contains(t)&&w()&&!w().contains(t)&&u()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u,w]),(0,s.useEffect)(()=>{const e=x.current;if(!e)return;const t=t=>{const n=a(e),s=e.querySelector("[data-cb-done]"),o=document.activeElement;if("Tab"===t.key){const e=j&&s?[...n,s]:n;if(0===e.length)return;const i=o?e.indexOf(o):-1;return void(t.shiftKey?i<=0&&(t.preventDefault(),w()?.focus()):i===e.length-1&&(t.preventDefault(),e[0]?.focu
1s()))}if("ArrowDown"===t.key||"ArrowUp"===t.key){if(0===n.length)return;const e=o?n.indexOf(o):-1;if(e<0)return void(o===s&&(t.preventDefault(),"ArrowDown"===t.key?n[0]?.focus():n[n.length-1]?.focus()));t.preventDefault();const i=(e+("ArrowDown"===t.key?1:-1)+n.length)%n.length;return void n[i]?.focus()}if("Home"===t.key){if(0===n.length)return;return t.preventDefault(),void n[0]?.focus()}if("End"===t.key){if(0===n.length)return;t.preventDefault(),n[n.length-1]?.focus()}};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)},[w,j]);const A=t.description&&t.description.trim()||(0,l.eo)(e,n),k=(0,c.jsxs)("div",{ref:x,id:f,role:"listbox","aria-multiselectable":j,"aria-labelledby":g,className:i.A.dropdown,style:{top:y.top,left:y.left},children:[(0,c.jsxs)("div",{className:i.A.dropdownHeader,children:[(0,c.jsx)("span",{id:g,className:i.A.dropdownTitle,children:e}),A?(0,c.jsx)("span",{className:i.A.dropdownDesc,children:A}):null]}),(0,c.jsx)("div",{className:i.A.dropdownOptions,children:t.options.map(e=>{const t=d.has(e);return(0,c.jsxs)("button",{type:"button","data-cb-option":!0,"data-cb-option-value":e,role:"option","aria-selected":t,className:`${i.A.dropdownOption} ${t?i.A.selected:""}`,onClick:()=>p(e),children:[(0,c.jsx)("span",{className:i.A.optionIcon,children:(0,c.jsx)(r.Ay,{label:"",size:"md",glyph:j?t?"checkboxFill":"checkbox":t?"radioButtonFill":"radioButton"})}),(0,c.jsx)("code",{children:e})]},e)})}),j&&(0,c.jsxs)("div",{className:i.A.dropdownFooter,children:[(0,c.jsx)("span",{className:i.A.dropdownHint,children:"Select multiple"}),(0,c.jsx)("button",{type:"button",className:i.A.dropdownDone,"data-cb-done":!0,onClick:u,children:"Done"})]})]});return"undefined"!=typeof document?(0,o.createPortal)(k,document.body):null}},36331:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>d,contentTitle:()=>c,default:()=>h,frontMatter:()=>l,metadata:()=>s,toc:()=>p});const s=JSON.parse('{"id":"guides/quick-start/authenticate","title":"Authenticate Your Developer Application","description":"Authenticate your developer app and get your access token to use the Reddit Ads API for custom integrations that interact with Reddit\u2019s ads platform.","source":"@site/docs/guides/quick-start/authenticate.md","sourceDirName":"guides/quick-start","slug":"/guides/quick-start/authenticate","permalink":"/docs/v3/guides/quick-start/authenticate","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":2,"frontMatter":{"title":"Authenticate Your Developer Application","sidebar_position":2,"description":"Authenticate your developer app and get your access token to use the Reddit Ads API for custom integrations that interact with Reddit\u2019s ads platform."},"sidebar":"tutorialSidebar","previous":{"title":"Create a Developer Application","permalink":"/docs/v3/guides/quick-start/create-dev-app"},"next":{"title":"Programs","permalink":"/docs/v3/guides/programs"}}');var o=n(74848),i=n(28453),r=n(57038),a=n(12849);const l={title:"Authenticate Your Developer Application",sidebar_position:2,description:"Authenticate your developer app and get your access token to use the Reddit Ads API for custom integrations that interact with Reddit\u2019s ads platform."},c=void 0,d={},p=[{value:"1. Authorize your application",id:"1-authorize-your-application",level:2},{value:"2. Get your access token from the Reddit API",id:"2-get-your-access-token-from-the-reddit-api",level:2},{value:"3. (Optional) Refresh your access token",id:"3-optional-refresh-your-access-token",level:2}];function u(e){const t={a:"a",admonition:"admonition",code:"code",em:"em",h2:"h2",img:"img",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components},{Details:s}=t;return s||function(e,t){throw new Error("Expected "+(t?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}("Details",!0),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.p,{children:"You can set up your developer application to gain access to the Reddit API, letting you develop nifty applications and integrations that seamlessly interact with Reddit's ads platform."}),"\n",(0,o.jsx)(t.p,{children:"Before you begin, you should have:"}),"\n",(0,o.jsxs)(t.ul,{children:["\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.a,{href:"https://business.reddithelp.com/s/article/Create-and-manage-your-Reddit-Ads-account#N1",children:"A Reddit Ads account"}),"."]}),"\n",(0,o.jsxs)(t.li,{children:[(0,o.jsx)(t.a,{href:"/docs/v3/guides/quick-start/create-dev-app",children:"A developer application"}),". You'll need its app ID and secret."]}),"\n",(0,o.jsx)(t.li,{children:"Access to a terminal application."}),"\n"]}),"\n",(0,o.jsx)(t.h2,{id:"1-authorize-your-application",children:"1. Authorize your application"}),"\n",(0,o.jsxs)(t.p,{children:["Go to your business's ",(0,o.jsx)(t.a,{href:"https://ads.reddit.com/business/developer-applications",children:"developer applications"})," and find your application's app ID. Replace the values in the following link and navigate to it:"]}),"\n",(0,o.jsx)(a.Ay,{title:"Authorize app",template:"https://www.reddit.com/api/v1/authorize?client_id={{App ID}}
1&response_type=code&state={{Random String}}&redirect_uri={{Redirect URI registered for app}}&duration={{Duration}}&scope={{Scope}}",variableOptions:{Duration:{options:["temporary","permanent"],description:"When token expires",multiSelect:!1},Scope:{options:["adsread","adsedit","adsconversions","history","read"],separator:",",description:"Choose perms"}},language:"url"}),"\n",(0,o.jsxs)(s,{children:[(0,o.jsxs)("summary",{children:[(0,o.jsx)(t.strong,{children:"Reference:"})," Fields"]}),(0,o.jsxs)(t.table,{children:[(0,o.jsx)(t.thead,{children:(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.th,{children:"Field"}),(0,o.jsx)(t.th,{children:"Description"})]})}),(0,o.jsxs)(t.tbody,{children:[(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"{{App ID}}"})}),(0,o.jsx)(t.td,{children:"The ID of your dev app"})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"{{Random String}}"})}),(0,o.jsxs)(t.td,{children:["This can be set to any string with no spaces or special characters, like the name of your dev app. This is used to ",(0,o.jsx)(t.a,{href:"https://owasp.org/www-community/attacks/csrf",children:"detect cross-site request forgeries (CSRF)"}),". You can also set a signature for additional security."]})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"{{Redirect URI registered for app}}"})}),(0,o.jsxs)(t.td,{children:["The redirect URL you set for your dev app. ",(0,o.jsxs)(r.A,{type:"important",children:["Don't change ",(0,o.jsx)(t.code,{children:"redirect_uri"})," to ",(0,o.jsx)(t.code,{children:"redirect_url"}),". This parameter must be used so that the application can correctly route mobile and web application redirects."]})]})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"{{Duration}}"})}),(0,o.jsxs)(t.td,{children:["The time limit that this access token will expire. You probably want to set this to ",(0,o.jsx)(t.code,{children:"permanent"}),", but you can set it to ",(0,o.jsx)(t.code,{children:"temporary"})," to make the access code valid for only one hour. ",(0,o.jsxs)(r.A,{type:"note",children:["If you set this to ",(0,o.jsx)(t.code,{children:"temporary"}),", you won't be able to refresh this option."]})]})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"{{Scope}}"})}),(0,o.jsx)(t.td,{children:"A comma-separated list of the actions performable with the access token."})]})]})]})]}),"\n",(0,o.jsxs)(s,{children:[(0,o.jsxs)("summary",{children:[(0,o.jsx)(t.strong,{children:"Reference:"})," Scope"]}),(0,o.jsxs)(t.table,{children:[(0,o.jsx)(t.thead,{children:(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.th,{children:(0,o.jsx)(t.strong,{children:"Scope"})}),(0,o.jsx)(t.th,{children:(0,o.jsx)(t.strong,{children:"Description"})})]})}),(0,o.jsxs)(t.tbody,{children:[(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"adsconversions"})}),(0,o.jsxs)(t.td,{children:["Post conversion events by enabling access to the ",(0,o.jsx)(t.a,{href:"https://ads-api.reddit.com/docs/v2/#tag/Conversions",children:"Conversions"})," endpoint"]})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"adsedit"})}),(0,o.jsx)(t.td,{children:"Edit ads data"})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"adsread"})}),(0,o.jsx)(t.td,{children:"Read advertising data for your account\xa0"})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"history"})}),(0,o.jsx)(t.td,{children:"Access submission history"})]}),(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"read"})}),(0,o.jsx)(t.td,{children:"Read posts and comments for your Reddit user account"})]})]})]})]}),"\n",(0,o.jsxs)(t.p,{children:["Check that the username listed matches the account you want to authorize the app. If the username is correct, select ",(0,o.jsx)(t.em,{children:"Allow"}),"."]}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.img,{alt:"Check your username",src:n(17194).A+"",width:"1600",height:"770"})}),"\n",(0,o.jsx)(t.admonition,{type:"important",children:(0,o.jsx)(t.p,{children:"If an unexpected username is displayed, you're in an active Reddit session. To fix this, log out of your account, log into the correct account, then revisit the URL."})}),"\n",(0,o.jsxs)(t.p,{children:["You will be sent to the redirect URL that you provided earlier. The URL in your address bar will have 2 query parameters: the state and the code. Copy and record the code value and remove the ",(0,o.jsx)(t.code,{children:"#_"})," characters at the end of the value, if any."]}),"\n",(0,o.jsx)(t.admonition,{type:"important",children:(0,o.jsx)(t.p,{children:"This code should be used within the next ten minutes and only once per authorization."})}),"\n",(0,o.jsx)(t.p,{children:(0,o.jsx)(t.img,{alt:"Copy the code",src:n(75010).A+"",width:"1600",height:"142"})}),"\n",(0,o.jsxs)(s,{children:[(0,o.jsxs)("summary",{children:[(0,o.jsx)("strong",{children:"Example:"})," Find code value from redirect URL"]}),(0,o.jsxs)(t.table,{children:[(0,o.jsx)(t.thead,{children:(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.th,{children:"Redirect URL"}),(0,o.jsx)(t.th,{children:"Code value"})]})}),(0,o.jsx)(t.tbody,{children:(0,o.jsxs)(t.tr,{children:[(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"https://notarealbrand.myshopify.com/oauth/callback?state=my-state&code=Ve49meZ9oh3lZFY35CEizm3jTsfJeA#_"})}),(0,o.jsx)(t.td,{children:(0,o.jsx)(t.code,{children:"Ve49meZ9oh3lZFY35CEizm3jTsfJeA"})})]})})]})]}),"\n",(0,o.jsx)("p",{}
1),"\n",(0,o.jsx)(t.h2,{id:"2-get-your-access-token-from-the-reddit-api",children:"2. Get your access token from the Reddit API"}),"\n",(0,o.jsx)(t.p,{children:"Open a terminal window and execute the following cURL command with your noted values:"}),"\n","\n",(0,o.jsx)(a.Ay,{title:"Get access token",template:"curl -X POST https://www.reddit.com/api/v1/access_token \\\n -H 'content-type: application/x-www-form-urlencoded' \\\n -A '{{App name (User-Agent header)}}' \\\n -u '{{App ID}}:{{App secret (from app page)}}' \\\n -d 'grant_type=authorization_code&code={{OAuth code from redirect}}&redirect_uri={{Redirect URI (same as authorize URL)}}'"}),"\n",(0,o.jsx)(t.p,{children:"If successful, you will receive a response that looks like this:"}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-json",children:'{\n\xa0\xa0\xa0\xa0"access_token": {{Access token}},\n\xa0\xa0\xa0\xa0"token_type": "bearer",\n\xa0\xa0\xa0\xa0"expires_in": {{Expiration time in Unix epoch}},\n\xa0\xa0\xa0\xa0"refresh_token": {{Refresh token}},\n\xa0\xa0\xa0\xa0"scope": {{Scope string}}\n}\n'})}),"\n",(0,o.jsxs)(t.p,{children:["Record the value for ",(0,o.jsx)(t.code,{children:"access_token"})," and ",(0,o.jsx)(t.code,{children:"refresh_token"}),". You'll use ",(0,o.jsx)(t.code,{children:"access_token"})," to access the Reddit Ads API for either one hour (3600) or one day (86400), whichever is listed for the value for ",(0,o.jsx)(t.code,{children:"expires_in"}),"."]}),"\n",(0,o.jsx)(t.h2,{id:"3-optional-refresh-your-access-token",children:"3. (Optional) Refresh your access token"}),"\n",(0,o.jsx)(t.p,{children:"You can use an active access token to maintain continuous access to the API without requiring re-authentication.\xa0"}),"\n",(0,o.jsx)(t.p,{children:"To refresh your token, open a terminal window and execute the following cURL command with your noted values:"}),"\n",(0,o.jsx)(a.Ay,{title:"Refresh access token",description:"Use your refresh token to get a new access token",template:"curl -X POST https://www.reddit.com/api/v1/access_token \\\n -A '{{App name}}' \\\n -u '{{App ID}}:{{App secret}}' \\\n -d 'grant_type=refresh_token&refresh_token={{Refresh token (Step 2)}}'",language:"bash"}),"\n",(0,o.jsx)(t.p,{children:"If successful, you will receive a response that looks like this:"}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-json",children:'{\n\xa0\xa0\xa0\xa0"access_token": {{Access token}},\n\xa0\xa0\xa0\xa0"token_type": "bearer",\n\xa0\xa0\xa0\xa0"expires_in": {{Expiration time in Unix epoch}},\n\xa0\xa0\xa0\xa0"refresh_token": {{Refresh token}},\n\xa0\xa0\xa0\xa0"scope": {{Scope string}}\n}\n'})}),"\n",(0,o.jsxs)(t.p,{children:["Record the value for ",(0,o.jsx)(t.code,{children:"access_token"})," and ",(0,o.jsx)(t.code,{children:"refresh_token"}),". You'll use ",(0,o.jsx)(t.code,{children:"access_token"})," to access the Reddit Ads API for either one hour (3600) or one day (86400), whichever is listed for the value for ",(0,o.jsx)(t.code,{children:"expires_in"}),"."]})]})}function h(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(u,{...e})}):u(e)}},53963:(e,t,n)=>{n.d(t,{i:()=>o});var s=n(96540);function o(e,t){const n=(0,s.useRef)(t);n.current=t,(0,s.useEffect)(()=>{if(!e)return;const t=e=>{"Escape"===e.key&&n.current()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e])}},54233:(e,t,n)=>{async function s(e){try{await navigator.clipboard.writeText(e)}catch{const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}}n.d(t,{l:()=>s})},54690:(e,t,n)=>{n.d(t,{M:()=>o});n(96540);var s=n(74848);function o(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,children:(0,s.jsx)("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})}},56555:(e,t,n)=>{n.d(t,{A:()=>s});const s={container:"container_hZmB",header:"header_sQI7",headerLeft:"headerLeft_VGxn",title:"title_U_Ew",description:"description_Wmmy",inlineCodeSection:"inlineCodeSection_a8nc",inlineToolbar:"inlineToolbar_aFW4",languageTag:"languageTag_PyKi",toolbarActions:"toolbarActions_FDab",toolbarLinkButton:"toolbarLinkButton_mQSt",warningBadge:"warningBadge_VXUW",expandButton:"expandButton_ZA06",copyButton:"copyButton_wn56",copied:"copied_tDqs",disabled:"disabled_Lb_g",inlineCodeBlock:"inlineCodeBlock__tPi",inlineCodeBlockJoinAssist:"inl
1ineCodeBlockJoinAssist_AdVb",inlinePre:"inlinePre_SIvA",inlineCode:"inlineCode_BG5s",inlineFieldWrapper:"inlineFieldWrapper_eT5W",inlineInput:"inlineInput_ADrj",filled:"filled_G3JG",inlineSelect:"inlineSelect_FN4t",inlineDatetimeInput:"inlineDatetimeInput_v5SQ",inlineDatetimeStack:"inlineDatetimeStack_WaRd",datetimeLegendRow:"datetimeLegendRow_iUVS",datetimeLegendDateSlot:"datetimeLegendDateSlot_w7QF",datetimeNativeColumnLegend:"datetimeNativeColumnLegend_aQ25",inlineDropdownTrigger:"inlineDropdownTrigger_x4a0",dropdown:"dropdown_LiwR",dropdownIn:"dropdownIn_yZBQ",dropdownHeader:"dropdownHeader_VXXm",dropdownTitle:"dropdownTitle_WBVK",dropdownDesc:"dropdownDesc_J7Nv",dropdownOptions:"dropdownOptions_m4ii",dropdownOption:"dropdownOption_Klwx",selected:"selected_pUpI",optionIcon:"optionIcon_tSS2",dropdownFooter:"dropdownFooter_wfZN",dropdownHint:"dropdownHint_vBIa",dropdownDone:"dropdownDone_yz5m",fullscreenOverlay:"fullscreenOverlay_SzQp",fadeIn:"fadeIn_HxSH",fullscreenContent:"fullscreenContent_QawN",scaleIn:"scaleIn_Itn7",fullscreenHeader:"fullscreenHeader_dpby",fullscreenTitle:"fullscreenTitle_NJyI",closeButton:"closeButton_jGKn",fullscreenBody:"fullscreenBody_j6tM",slideUp:"slideUp_RIOt"}},75010:(e,t,n)=>{n.d(t,{A:()=>s});const s=n.p+"assets/images/copy-code-7529e9db824d1ea0b85628912f583ca6.webp"}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.