If your API key is compromised, rotate it immediately. The old key will be invalidated and a new one will be issued.
curl -X POST "https://api.adrelay.dev/v1/api-keys/rotate" \ -H "X-API-Key: $ADRELAY_API_KEY"
Rotating your API key immediately invalidates the previous key. Update all applications using the old key before rotating.
Security Best Practices
Store your API key in environment variables, never in source code
Rotate your key periodically and immediately if compromised
Use separate API keys for development and production environments
OAuth for Ad Platforms
To manage campaigns on a specific platform, you must first connect that platform’s ad account via OAuth. AdRelay handles the full OAuth lifecycle:
Initiate — Call the authorize endpoint to get an OAuth URL
Authorize — User completes the OAuth flow in their browser
Store — AdRelay stores and manages the OAuth tokens
Refresh — Tokens are automatically refreshed before expiration
Starting the OAuth Flow
curl -X GET "https://api.adrelay.dev/v1/connections/{platform}/authorize" \ -H "X-API-Key: $ADRELAY_API_KEY"
Replace {platform} with one of: google_ads, meta_ads, tiktok_ads.The response includes a redirect URL that the user should open in their browser to complete authorization.
Token Lifecycle
Event
Behavior
Initial authorization
Tokens stored securely by AdRelay
Token near expiration
Automatically refreshed using refresh token
Refresh token expired
Connection status set to REVOKED; re-authorization required
User revokes access
Connection status set to REVOKED on next sync
Error Codes
Status Code
Error
Description
401
UNAUTHORIZED
Missing or invalid API key. Verify the X-API-Key header is present and correct.
403
FORBIDDEN
API key is valid but does not have permission for this operation. This may occur if your plan does not include access to the requested resource.
429
RATE_LIMITED
Too many requests. See the Retry-After header for when to retry.
Example Error Response
{ "error": "Invalid or missing API key.", "code": "UNAUTHORIZED", "timestamp": 1711036800, "request_id": "req_abc123"}
{"docsConfig":{"$schema":"https://mintlify.com/docs.json","theme":"mint","name":"AdRelay API","colors":{"primary":"#4F46E5","light":"#818CF8","dark":"#3730A3"},"favicon":"/favicon.svg","logo":{"light":"https://mintcdn.com/adrelay/SESDrz0j9x7BeLSI/logo/light.svg?fit=max\u0026auto=format\u0026n=SESDrz0j9x7BeLSI\u0026q=85\u0026s=f40c3e1e5f24c356cc680b03e4d8d42f","dark":"https://mintcdn.com/adrelay/SESDrz0j9x7BeLSI/logo/dark.svg?fit=max\u0026auto=format\u0026n=SESDrz0j9x7BeLSI\u0026q=85\u0026s=ba4a1d74f3d9c9af806f5a50b2009540","href":"https://adrelay.dev"},"api":{"openapi":"openapi.json","mdx":{"server":"https://api.adrelay.dev/v1","auth":{"method":"key","name":"X-API-Key"}}},"navbar":{"links":[{"label":"Dashboard","href":"https://app.adrelay.dev"}],"primary":{"type":"button","label":"Sign Up","href":"https://app.adrelay.dev/sign-up"}},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"adrelay","hasAudioNarration":false,"actualSubdomain":"adrelay","customDomains":["docs.adrelay.dev"],"gitSource":{"type":"github","owner":"adrelay","repo":"adrelay-api","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{},"buildId":"6ae94a94e9b395905efdff47:success","clientVersion":"0.0.4149","searchFilterCounts":[{"language":"default","tag":"API Reference","count":38},{"language":"default","tag":"Documentation","count":9},{"language":"default","tag":"Connections","count":5},{"language":"default","tag":"Campaigns","count":4},{"language":"default","tag":"Guides","count":4},{"language":"default","tag":"Billing","count":3},{"language":"default","tag":"Redirect URIs","count":3},{"language":"default","tag":"Getting Started","count":3},{"language":"default","tag":"API Keys","count":2},{"language":"default","tag":"SDKs","count":2}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"authentication","slug":"/authentication","pageMetadata":{"title":"Authentication","description":"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.","href":"/authentication"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`AdRelay uses two layers of authentication:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`API Key`}),` — Authenticates your requests to the AdRelay API`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`OAuth`}),` — Connects your ad platform accounts (Google, Meta, TikTok)`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`api-key-authentication`,children:`API Key Authentication`}),`\n`,_jsxs(_components.p,{children:[`Every request to the AdRelay API must include your API key in the `,_jsx(_components.code,{children:`X-API-Key`}),` header.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` GET`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://api.adrelay.dev/v1/campaigns\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"X-API-Key: your-api-key-here\"`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`getting-your-api-key`,children:`Getting Your API Key`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`Sign in to the `,_jsx(_components.a,{href:`https://app.adrelay.dev`,children:`AdRelay Dashboard`})]}),`\n`,_jsxs(_components.li,{children:[`Navigate to `,_jsx(_components.strong,{children:`Settings > API Keys`})]}),`\n`,_jsx(_components.li,{children:`Copy your API key`}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`rotating-your-api-key`,children:`Rotating Your API Key`}),`\n`,_jsx(_components.p,{children:`If your API key is compromised, rotate it immediately. The old key will be invalidated and a new one will be issued.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://api.adrelay.dev/v1/api-keys/rotate\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"X-API-Key: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$ADRELAY_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`]})})}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Rotating your API key immediately invalidates the previous key. Update all applications using the old key before rotating.`})}),`\n`,_jsx(Heading,{level:`3`,id:`security-best-practices`,children:`Security Best Practices`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Store your API key in environment variables, never in source code`}),`\n`,_jsx(_components.li,{children:`Rotate your key periodically and immediately if compromised`}),`\n`,_jsx(_components.li,{children:`Use separate API keys for development and production environments`}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`oauth-for-ad-platforms`,children:`OAuth for Ad Platforms`}),`\n`,_jsx(_components.p,{children:`To manage campaigns on a specific platform, you must first connect that platform’s ad account via OAuth. AdRelay handles the full OAuth lifecycle:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Initiate`}),` — Call the authorize endpoint to get an OAuth URL`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Authorize`}),` — User completes the OAuth flow in their browser`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Store`}),` — AdRelay stores and manages the OAuth tokens`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Refresh`}),` — Tokens are automatically refreshed before expiration`]}),`\n`]}),`\n`,_jsx(Heading,{level:`3`,id:`starting-the-oauth-flow`,children:`Starting the OAuth Flow`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`2`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`2`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` GET`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://api.adrelay.dev/v1/connections/{platform}/authorize\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"X-API-Key: `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$ADRELAY_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Replace `,_jsx(_components.code,{children:`{platform}`}),` with one of: `,_jsx(_components.code,{children:`google_ads`}),`, `,_jsx(_components.code,{children:`meta_ads`}),`, `,_jsx(_components.code,{children:`tiktok_ads`}),`.`]}),`\n`,_jsx(_components.p,{children:`The response includes a redirect URL that the user should open in their browser to complete authorization.`}),`\n`,_jsx(Heading,{level:`3`,id:`token-lifecycle`,children:`Token Lifecycle`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Event`}),_jsx(_components.th,{children:`Behavior`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Initial authorization`}),_jsx(_components.td,{children:`Tokens stored securely by AdRelay`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Token near expiration`}),_jsx(_components.td,{children:`Automatically refreshed using refresh token`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Refresh token expired`}),_jsxs(_components.td,{children:[`Connection status set to `,_jsx(_components.code,{children:`REVOKED`}),`; re-authorization required`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`User revokes access`}),_jsxs(_components.td,{children:[`Connection status set to `,_jsx(_components.code,{children:`REVOKED`}),` on next sync`]})]})]})]}),`\n`,_jsx(Heading,{level:`2`,id:`error-codes`,children:`Error Codes`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Status Code`}),_jsx(_components.th,{children:`Error`}),_jsx(_components.th,{children:`Description`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`401`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`UNAUTHORIZED`})}),_jsxs(_components.td,{children:[`Missing or invalid API key. Verify the `,_jsx(_components.code,{children:`X-API-Key`}),` header is present and correct.`]})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`403`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`FORBIDDEN`})}),_jsx(_components.td,{children:`API key is valid but does not have permission for this operation. This may occur if your plan does not include access to the requested resource.`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{\"data-numeric\":`true`,children:_jsx(_components.code,{children:`429`})}),_jsx(_components.td,{children:_jsx(_components.code,{children:`RATE_LIMITED`})}),_jsxs(_components.td,{children:[`Too many requests. See the `,_jsx(_components.code,{children:`Retry-After`}),` header for when to retry.`]})]})]})]}),`\n`,_jsx(Heading,{level:`3`,id:`example-error-response`,children:`Example Error Response`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`6`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`6`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"error\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Invalid or missing API key.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"code\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"UNAUTHORIZED\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"timestamp\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1711036800`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"request_id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"req_abc123\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Authentication","description":"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.","href":"/authentication"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"API Key Authentication","slug":"api-key-authentication","depth":2,"children":[{"title":"Getting Your API Key","slug":"getting-your-api-key","depth":3,"children":[]},{"title":"Rotating Your API Key","slug":"rotating-your-api-key","depth":3,"children":[]},{"title":"Security Best Practices","slug":"security-best-practices","depth":3,"children":[]}]},{"title":"OAuth for Ad Platforms","slug":"oauth-for-ad-platforms","depth":2,"children":[{"title":"Starting the OAuth Flow","slug":"starting-the-oauth-flow","depth":3,"children":[]},{"title":"Token Lifecycle","slug":"token-lifecycle","depth":3,"children":[]}]},{"title":"Error Codes","slug":"error-codes","depth":2,"children":[{"title":"Example Error Response","slug":"example-error-response","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":[],"subdomain":"adrelay","siteName":"AdRelay API","title":"Authentication - AdRelay API","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-03-23T01:30:23.262Z","originalFileLocation":"authentication.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.\">\u003cmeta data-mint-head name=\"application-name\" content=\"AdRelay API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Authentication - AdRelay API\">\u003cmeta data-mint-head property=\"og:description\" content=\"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"AdRelay API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.adrelay.dev/authentication\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://adrelay.mintlify.site/_mintlify/api/og/v2?division=Getting+Started\u0026amp;title=Authentication\u0026amp;description=How+to+authenticate+with+the+AdRelay+API+using+API+keys+and+connect+ad+accounts+via+OAuth.\u0026amp;theme=64c8cff38a8b9a2a66591451\u0026amp;signature=73e9cc9685d66e5bd113a43259681e9993332ac1ff52b3adf50c6a608f3ac096\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Authentication - AdRelay API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://adrelay.mintlify.site/_mintlify/api/og/v2?division=Getting+Started\u0026amp;title=Authentication\u0026amp;description=How+to+authenticate+with+the+AdRelay+API+using+API+keys+and+connect+ad+accounts+via+OAuth.\u0026amp;theme=64c8cff38a8b9a2a66591451\u0026amp;signature=73e9cc9685d66e5bd113a43259681e9993332ac1ff52b3adf50c6a608f3ac096\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/adrelay/S3gwe0kOAamaRyy0/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"AdRelay API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#4F46E5\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.adrelay.dev/authentication\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/authentication.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.adrelay.dev/#organization\",\"name\":\"AdRelay API\",\"url\":\"https://docs.adrelay.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/adrelay/SESDrz0j9x7BeLSI/logo/light.svg?fit=max\u0026auto=format\u0026n=SESDrz0j9x7BeLSI\u0026q=85\u0026s=f40c3e1e5f24c356cc680b03e4d8d42f\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.adrelay.dev#website\",\"name\":\"AdRelay API\",\"url\":\"https://docs.adrelay.dev\",\"publisher\":{\"@id\":\"https://docs.adrelay.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.adrelay.dev/authentication#webpage\",\"url\":\"https://docs.adrelay.dev/authentication\",\"name\":\"Authentication\",\"description\":\"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.\",\"dateModified\":\"2026-03-23T01:30:23.262Z\",\"isPartOf\":{\"@id\":\"https://docs.adrelay.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.adrelay.dev/authentication#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.adrelay.dev/authentication#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Getting Started\",\"item\":\"https://docs.adrelay.dev/introduction\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Authentication\",\"item\":\"https://docs.adrelay.dev/authentication\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.adrelay.dev/authentication#article\",\"headline\":\"Authentication\",\"name\":\"Authentication\",\"description\":\"How to authenticate with the AdRelay API using API keys and connect ad accounts via OAuth.\",\"url\":\"https://docs.adrelay.dev/authentication\",\"mainEntityOfPage\":{\"@id\":\"https://docs.adrelay.dev/authentication#webpage\"},\"dateModified\":\"2026-03-23T01:30:23.262Z\",\"publisher\":{\"@id\":\"https://docs.adrelay.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.adrelay.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"AdRelay API\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"AdRelay API\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/authentication.md","siteName":"AdRelay API","nav":{"global":null,"anchors":[{"anchor":"Documentation","icon":"book-open","groups":[{"group":"Getting Started","pages":[{"title":"Introduction","href":"/introduction"},{"title":"Quickstart","description":"Get up and running with AdRelay in under 5 minutes.","href":"/quickstart"},{"title":"Authentication","href":"/authentication"}]},{"group":"Guides","pages":[{"title":"Connecting Ad Accounts","description":"Connect Google Ads, Meta Ads, and TikTok Ads accounts via OAuth.","href":"/guides/connecting-ad-accounts"},{"title":"Fetching Campaigns","href":"/guides/fetching-campaigns"},{"title":"Creating Campaigns","href":"/guides/creating-campaigns"},{"title":"Multi-Platform Campaigns","href":"/guides/multi-platform-campaigns"}]},{"group":"SDKs","pages":[{"title":"TypeScript SDK","href":"/sdks/typescript"},{"title":"Python SDK","href":"/sdks/python"}]}]},{"anchor":"API Reference","icon":"code","pages":[{"title":"API Reference","href":"/api-reference/campaigns/list"}]},{"anchor":"GitHub","href":"https://github.com/adrelay","icon":"github"}]},"basePath":"","title":"Authentication - AdRelay API","buildId":"dpl_4D8r1dHg6bQcRuBgQyL3z9waJJtn","deploymentId":"dpl_4D8r1dHg6bQcRuBgQyL3z9waJJtn","dynamics":[],"chunks":[]}