curl --request POST \
--url https://api.social-api.ai/v1/oauth/exchange \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "AQDtbPB9X...",
"metadata": {},
"platform": "instagram"
}
'import requests
url = "https://api.social-api.ai/v1/oauth/exchange"
payload = {
"code": "AQDtbPB9X...",
"metadata": {},
"platform": "instagram"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: 'AQDtbPB9X...', metadata: {}, platform: 'instagram'})
};
fetch('https://api.social-api.ai/v1/oauth/exchange', 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.social-api.ai/v1/oauth/exchange",
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' => 'AQDtbPB9X...',
'metadata' => [
],
'platform' => 'instagram'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.social-api.ai/v1/oauth/exchange"
payload := strings.NewReader("{\n \"code\": \"AQDtbPB9X...\",\n \"metadata\": {},\n \"platform\": \"instagram\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.social-api.ai/v1/oauth/exchange")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"AQDtbPB9X...\",\n \"metadata\": {},\n \"platform\": \"instagram\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.social-api.ai/v1/oauth/exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"AQDtbPB9X...\",\n \"metadata\": {},\n \"platform\": \"instagram\"\n}"
response = http.request(request)
puts response.read_body{
"connection_id": "pc_4a8f2c1e9b3d7f06a5c2e8b4d1f3a7e2",
"login_id": "<string>",
"lost_access": [
{
"brand_id": "<string>",
"brand_name": "<string>",
"name": "<string>",
"platform_page_id": "<string>"
}
],
"pages": [
{
"assignable": true,
"assigned_account_id": "<string>",
"assigned_brand_id": "<string>",
"assigned_brand_name": "<string>",
"category": "<string>",
"name": "Acme Bakery",
"picture_url": "<string>",
"platform_page_id": "17841400000000000"
}
],
"platform": "google",
"profiles": [
{
"bio": "Wood-fired pizza since 1998",
"display_name": "Joe's Pizza (Downtown)",
"platform_account_id": "accounts/123/locations/456",
"profile_picture_url": "",
"username": ""
}
],
"status": "selection_required"
}{
"account_id": "acc_01HZ9X3Q4R5M6N7P8V2K0W1J",
"display_name": "Acme Corp",
"platform": "instagram",
"username": "acmecorp"
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}Exchange OAuth code
Exchanges an OAuth authorization code for a connected social account. Use this when you handle the OAuth callback on your own server (proxy flow). For a single account the response is a flat ConnectAccountResponse (HTTP 201). When a single OAuth flow connects multiple accounts (e.g. Facebook Pages) the response is OAuthCallbackResponse.
curl --request POST \
--url https://api.social-api.ai/v1/oauth/exchange \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "AQDtbPB9X...",
"metadata": {},
"platform": "instagram"
}
'import requests
url = "https://api.social-api.ai/v1/oauth/exchange"
payload = {
"code": "AQDtbPB9X...",
"metadata": {},
"platform": "instagram"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: 'AQDtbPB9X...', metadata: {}, platform: 'instagram'})
};
fetch('https://api.social-api.ai/v1/oauth/exchange', 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.social-api.ai/v1/oauth/exchange",
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' => 'AQDtbPB9X...',
'metadata' => [
],
'platform' => 'instagram'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.social-api.ai/v1/oauth/exchange"
payload := strings.NewReader("{\n \"code\": \"AQDtbPB9X...\",\n \"metadata\": {},\n \"platform\": \"instagram\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.social-api.ai/v1/oauth/exchange")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"AQDtbPB9X...\",\n \"metadata\": {},\n \"platform\": \"instagram\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.social-api.ai/v1/oauth/exchange")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"AQDtbPB9X...\",\n \"metadata\": {},\n \"platform\": \"instagram\"\n}"
response = http.request(request)
puts response.read_body{
"connection_id": "pc_4a8f2c1e9b3d7f06a5c2e8b4d1f3a7e2",
"login_id": "<string>",
"lost_access": [
{
"brand_id": "<string>",
"brand_name": "<string>",
"name": "<string>",
"platform_page_id": "<string>"
}
],
"pages": [
{
"assignable": true,
"assigned_account_id": "<string>",
"assigned_brand_id": "<string>",
"assigned_brand_name": "<string>",
"category": "<string>",
"name": "Acme Bakery",
"picture_url": "<string>",
"platform_page_id": "17841400000000000"
}
],
"platform": "google",
"profiles": [
{
"bio": "Wood-fired pizza since 1998",
"display_name": "Joe's Pizza (Downtown)",
"platform_account_id": "accounts/123/locations/456",
"profile_picture_url": "",
"username": ""
}
],
"status": "selection_required"
}{
"account_id": "acc_01HZ9X3Q4R5M6N7P8V2K0W1J",
"display_name": "Acme Corp",
"platform": "instagram",
"username": "acmecorp"
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}{
"error": {
"code": "resource.not_found",
"message": "Account not found",
"meta": {}
}
}Authorizations
Prefix your API key with "Bearer ". Example: Authorization: Bearer sapi_key_...
Body
Platform, code, and metadata (redirect_uri + state required)
Code is the authorization code received from the platform callback.
"AQDtbPB9X..."
Metadata must include redirect_uri and state for CSRF validation.
Show child attributes
Show child attributes
Platform identifies the social platform (must match the connect call).
"instagram"
Response
Google login manages multiple Business Profiles; select one
"pc_4a8f2c1e9b3d7f06a5c2e8b4d1f3a7e2"
Facebook page-selection fields (empty for Google Profile selection).
Show child attributes
Show child attributes
Show child attributes
Show child attributes
"google"
Show child attributes
Show child attributes
"selection_required"