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"
}
'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));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){
"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"
}
'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));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){
"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"
login_id identifies the login and is set for both Facebook and Google. pages and lost_access are Facebook page-selection only.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
"google"
Show child attributes
Show child attributes
"selection_required"