Integration Callback
curl --request POST \
--url https://api.example.com/integrations/{integrationType}/callback \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"state": "<string>"
}
'import requests
url = "https://api.example.com/integrations/{integrationType}/callback"
payload = {
"code": "<string>",
"state": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>', state: '<string>'})
};
fetch('https://api.example.com/integrations/{integrationType}/callback', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/integrations/{integrationType}/callback",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'state' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/integrations/{integrationType}/callback"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"state\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/integrations/{integrationType}/callback")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"state\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/integrations/{integrationType}/callback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"state\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Notion workspace connected successfully",
"workspace": {
"id": "workspace-id",
"name": "My Workspace",
"icon": "https://notion.so/icons/workspace.png"
},
"passthroughRedirectUri": "https://your-app.com/oauth/callback"
}
Integrations
Integration Callback
Handle OAuth callback for an integration
POST
/
integrations
/
{integrationType}
/
callback
Integration Callback
curl --request POST \
--url https://api.example.com/integrations/{integrationType}/callback \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"state": "<string>"
}
'import requests
url = "https://api.example.com/integrations/{integrationType}/callback"
payload = {
"code": "<string>",
"state": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>', state: '<string>'})
};
fetch('https://api.example.com/integrations/{integrationType}/callback', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/integrations/{integrationType}/callback",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'state' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/integrations/{integrationType}/callback"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"state\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/integrations/{integrationType}/callback")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"state\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/integrations/{integrationType}/callback")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"state\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Notion workspace connected successfully",
"workspace": {
"id": "workspace-id",
"name": "My Workspace",
"icon": "https://notion.so/icons/workspace.png"
},
"passthroughRedirectUri": "https://your-app.com/oauth/callback"
}
Complete the OAuth flow for a third-party integration.
URL Parameters
string
required
The type of integration being connected. Valid values:
google-analyticsnotionslackzohogmail
Request
string
required
The OAuth authorization code
string
required
The state parameter from the OAuth flow
Response
The response format varies by integration type:Google Analytics
boolean
Whether the callback was successful
string
Success or error message
array
List of available Google Analytics properties
{
id: string
name: string
websiteUrl: string
}[]
string
Temporary token for property selection
string
The redirect URI provided during connection
Notion
boolean
Whether the callback was successful
string
Success or error message
object
Connected Notion workspace details
{
id: string
name: string
icon: string
}
string
The redirect URI provided during connection
Slack
boolean
Whether the callback was successful
string
Success or error message
object
Connected Slack team details
{
id: string
name: string
domain: string
}
string
The redirect URI provided during connection
Zoho
boolean
Whether the callback was successful
string
Success or error message
object
Connected Zoho organization details
{
id: string
name: string
modules: string[]
}
string
The redirect URI provided during connection
Gmail
boolean
Whether the callback was successful
string
Success or error message
string
The redirect URI provided during connection
Example
curl -X POST https://suada.ai/api/public/integrations/notion/callback \
-H "Content-Type: application/json" \
-d '{
"code": "oauth-code-from-provider",
"state": "oauth-state-from-provider"
}'
import { Suada } from '@suada/node';
const suada = new Suada({
apiKey: 'your-api-key'
});
const result = await suada.handleIntegrationCallback('notion', {
code: 'oauth-code-from-provider',
state: 'oauth-state-from-provider'
});
// Redirect user back to their application
window.location.href = result.passthroughRedirectUri;
from suada import Suada, SuadaConfig
suada = Suada(
config=SuadaConfig(
api_key="your-api-key"
)
)
result = suada.handle_integration_callback(
integration_type="notion",
code="oauth-code-from-provider",
state="oauth-state-from-provider"
)
# Redirect user back to result.passthrough_redirect_uri
{
"success": true,
"message": "Notion workspace connected successfully",
"workspace": {
"id": "workspace-id",
"name": "My Workspace",
"icon": "https://notion.so/icons/workspace.png"
},
"passthroughRedirectUri": "https://your-app.com/oauth/callback"
}
Error Codes
object
Invalid request
{
"error": "Missing required parameters"
}
object
Invalid OAuth code or state
{
"error": "Invalid OAuth code"
}
object
Server error
{
"error": "Failed to complete OAuth flow"
}
Notes
- This endpoint should be called after receiving the OAuth callback from the integration provider
- The
stateparameter is used to verify the OAuth flow and prevent CSRF attacks - For Google Analytics, you’ll need to make an additional call to select a property
- After successful callback, redirect the user to the
passthroughRedirectUriprovided during connection - The integration will be automatically enabled for the user after successful callback
Was this page helpful?