{"title":"Product Analytics authentication","description":"Authenticate Product Analytics SDKs and API requests with public API keys for the target staging or production environment.","order":150,"askSuggestions":["Should I use separate API keys for staging and production?","Can a Product Analytics API key read my analytics data?"],"navigation":true,"routeId":"ingestDataProductAnalyticsAuthentication","body":{"code":"var Component=(()=>{var g=Object.create;var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var k=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),x=(n,e)=>{for(var i in e)s(n,i,{get:e[i],enumerable:!0})},l=(n,e,i,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let o of m(e))!P.call(n,o)&&o!==i&&s(n,o,{get:()=>e[o],enumerable:!(a=f(e,o))||a.enumerable});return n};var I=(n,e,i)=>(i=n!=null?g(A(n)):{},l(e||!n||!n.__esModule?s(i,\"default\",{value:n,enumerable:!0}):i,n)),D=n=>l(s({},\"__esModule\",{value:!0}),n);var u=k((w,h)=>{h.exports=_jsx_runtime});var S={};x(S,{default:()=>y,frontmatter:()=>v});var t=I(u()),v={title:\"Product Analytics authentication\",routeId:\"ingestDataProductAnalyticsAuthentication\",description:\"Authenticate Product Analytics SDKs and API requests with public API keys for the target staging or production environment.\",order:150,askSuggestions:[\"Should I use separate API keys for staging and production?\",\"Can a Product Analytics API key read my analytics data?\"]};function p(n){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",li:\"li\",ol:\"ol\",p:\"p\",strong:\"strong\",ul:\"ul\",...n.components},{DocsAppAction:i,DocsCallout:a,DocsPreviewDocument:o,DocsPreviewSection:r,DocsSdkCodeTabs:d}=e;return i||c(\"DocsAppAction\",!0),a||c(\"DocsCallout\",!0),o||c(\"DocsPreviewDocument\",!0),r||c(\"DocsPreviewSection\",!0),d||c(\"DocsSdkCodeTabs\",!0),(0,t.jsxs)(o,{anchors:\"product-analytics-authentication get-an-api-key sdk-authentication-examples direct-api-authentication next-steps\",children:[(0,t.jsxs)(r,{sectionId:\"product-analytics-authentication\",sectionTitle:\"Product Analytics authentication\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,t.jsx)(e.h1,{id:\"product-analytics-authentication\",children:\"Product Analytics authentication\"}),`\n`,(0,t.jsx)(e.p,{children:\"Product Analytics uses public API keys. Each key belongs to one organization and environment, and events sent with it go there.\"}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"get-an-api-key\",sectionTitle:\"Get an API key\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,t.jsx)(e.h2,{id:\"get-an-api-key\",children:\"Get an API key\"}),`\n`,(0,t.jsxs)(e.ol,{children:[`\n`,(0,t.jsxs)(e.li,{children:[\"Open the \",(0,t.jsx)(e.strong,{children:\"Product Analytics\"}),\" catalog.\"]}),`\n`,(0,t.jsxs)(e.li,{children:[\"Open the \",(0,t.jsx)(e.strong,{children:\"Details\"}),\" tab.\"]}),`\n`,(0,t.jsxs)(e.li,{children:[\"In \",(0,t.jsx)(e.strong,{children:\"Credentials\"}),\", copy an existing key, or create one if you manage API keys for the organization.\"]}),`\n`]}),`\n`,(0,t.jsx)(i,{destination:\"productAnalyticsApiKeys\"}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"sdk-authentication-examples\",sectionTitle:\"SDK authentication examples\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,t.jsx)(e.h2,{id:\"sdk-authentication-examples\",children:\"SDK authentication examples\"}),`\n`,(0,t.jsx)(e.p,{children:\"Initialize your SDK once with the API key for the target environment:\"}),`\n`,(0,t.jsx)(d,{category:\"product-analytics\",snippetId:\"authentication\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"To send data to another environment, use that environment's key. The SDK \",(0,t.jsx)(e.code,{children:\"environment\"}),\" option is deprecated and ignored, so remove it from your configuration.\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"direct-api-authentication\",sectionTitle:\"Direct API authentication\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,t.jsx)(e.h2,{id:\"direct-api-authentication\",children:\"Direct API authentication\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"For direct HTTP requests, use the same API key as your SDKs. See \",(0,t.jsx)(e.a,{href:\"/docs/api-references/product-analytics#authentication\",children:\"API authentication\"}),\" for supported headers and query parameters.\"]}),`\n`,(0,t.jsx)(a,{title:\"Security guidance\",children:(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsx)(e.li,{children:\"API keys are ingestion keys for product events and user identification. They cannot read historical analytics data. Identity requests can update user traits or merge identities.\"}),`\n`,(0,t.jsx)(e.li,{children:\"Prefer sending keys in headers. Use the query parameter form only when a header is not practical.\"}),`\n`]})}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"next-steps\",sectionTitle:\"Next steps\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,t.jsx)(e.h2,{id:\"next-steps\",children:\"Next steps\"}),`\n`,(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:(0,t.jsx)(e.a,{href:\"/docs/product-analytics/track\",children:\"Track events\"})}),\": Start sending product events\"]}),`\n`,(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:(0,t.jsx)(e.a,{href:\"/docs/product-analytics/identify\",children:\"Identify users\"})}),\": Set up user identification\"]}),`\n`]})]})]})}function y(n={}){let{wrapper:e}=n.components||{};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(p,{...n})}):p(n)}function c(n,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+n+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return D(S);})();\n;return Component;"},"_id":"docs/product-analytics/authentication.mdx","_raw":{"sourceFilePath":"docs/product-analytics/authentication.mdx","sourceFileName":"authentication.mdx","sourceFileDir":"docs/product-analytics","contentType":"mdx","flattenedPath":"docs/product-analytics/authentication"},"type":"Docs","path":"/product-analytics/authentication","level":2,"parent":"product-analytics"}