curl -X GET "https://api.adrelay.dev/v1/connections/google/authorize" \
-H "X-API-Key: $ADRELAY_API_KEY"
curl -X GET "https://api.adrelay.dev/v1/connections/google/authorize?redirect_uri=https://myapp.com/callback" \
-H "X-API-Key: $ADRELAY_API_KEY"
import { AdRelay } from "@adrelay/sdk";
const client = new AdRelay({ apiKey: process.env.ADRELAY_API_KEY });
// Default — redirects to AdRelay dashboard after OAuth
const { data: { url } } = await client.connections.getAuthUrl("google");
// Custom — redirects to your app after OAuth
const { data: { url: customUrl } } = await client.connections.getAuthUrl("google", {
redirectUri: "https://myapp.com/callback",
});
import requests
response = requests.get(
"https://api.adrelay.dev/v1/connections/google/authorize",
headers={"X-API-Key": "your-api-key-here"},
params={"redirect_uri": "https://myapp.com/callback"},
)
data = response.json()
# Redirect user to data["data"]["url"]
{
"data": {
"url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=...&scope=..."
}
}
{
"error": {
"code": "INVALID_REDIRECT_URI",
"message": "Redirect URI is not registered. Add it in your dashboard settings first.",
"retryable": false,
"requestId": "req_abc123"
}
}
Connections
Authorize Connection
Start the OAuth flow to connect an ad platform account.
GET
/
v1
/
connections
/
google
/
authorize
curl -X GET "https://api.adrelay.dev/v1/connections/google/authorize" \
-H "X-API-Key: $ADRELAY_API_KEY"
curl -X GET "https://api.adrelay.dev/v1/connections/google/authorize?redirect_uri=https://myapp.com/callback" \
-H "X-API-Key: $ADRELAY_API_KEY"
import { AdRelay } from "@adrelay/sdk";
const client = new AdRelay({ apiKey: process.env.ADRELAY_API_KEY });
// Default — redirects to AdRelay dashboard after OAuth
const { data: { url } } = await client.connections.getAuthUrl("google");
// Custom — redirects to your app after OAuth
const { data: { url: customUrl } } = await client.connections.getAuthUrl("google", {
redirectUri: "https://myapp.com/callback",
});
import requests
response = requests.get(
"https://api.adrelay.dev/v1/connections/google/authorize",
headers={"X-API-Key": "your-api-key-here"},
params={"redirect_uri": "https://myapp.com/callback"},
)
data = response.json()
# Redirect user to data["data"]["url"]
{
"data": {
"url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=...&scope=..."
}
}
{
"error": {
"code": "INVALID_REDIRECT_URI",
"message": "Redirect URI is not registered. Add it in your dashboard settings first.",
"retryable": false,
"requestId": "req_abc123"
}
}
curl -X GET "https://api.adrelay.dev/v1/connections/google/authorize" \
-H "X-API-Key: $ADRELAY_API_KEY"
curl -X GET "https://api.adrelay.dev/v1/connections/google/authorize?redirect_uri=https://myapp.com/callback" \
-H "X-API-Key: $ADRELAY_API_KEY"
import { AdRelay } from "@adrelay/sdk";
const client = new AdRelay({ apiKey: process.env.ADRELAY_API_KEY });
// Default — redirects to AdRelay dashboard after OAuth
const { data: { url } } = await client.connections.getAuthUrl("google");
// Custom — redirects to your app after OAuth
const { data: { url: customUrl } } = await client.connections.getAuthUrl("google", {
redirectUri: "https://myapp.com/callback",
});
import requests
response = requests.get(
"https://api.adrelay.dev/v1/connections/google/authorize",
headers={"X-API-Key": "your-api-key-here"},
params={"redirect_uri": "https://myapp.com/callback"},
)
data = response.json()
# Redirect user to data["data"]["url"]
{
"data": {
"url": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...&redirect_uri=...&scope=..."
}
}
{
"error": {
"code": "INVALID_REDIRECT_URI",
"message": "Redirect URI is not registered. Add it in your dashboard settings first.",
"retryable": false,
"requestId": "req_abc123"
}
}
{platform} path parameter accepts: google, meta, or tiktok.
Direct the user to the returned URL in their browser. After completing authorization, they will be redirected to your redirect_uri (or the AdRelay dashboard by default) with query params:
?success=true&platform=GOOGLE&connectionId=...on success?error=...on failure
Custom Redirect URIs
By default, OAuth callbacks land on the AdRelay dashboard. To redirect to your own app:- Register your URI via Settings or the Redirect URIs API
- Pass
redirect_urias a query parameter when calling authorize
The
redirect_uri only controls the final hop (AdRelay → your app). The platform-side OAuth callback (Google/Meta/TikTok → AdRelay) stays the same.