Create a SDK token for a user
curl --request POST \
--url https://api.tapti.ai/users/{id}/sdk-token \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"user_platforms": [
"YOUTUBE",
"TIKTOK"
],
"enabled_scopes": [
"PROFILE_READ"
],
"callback_url": "https://your-app.com/api/oauth/callback",
"redirect_url": "https://your-app.com/dashboard/accounts"
}
'import requests
url = "https://api.tapti.ai/users/{id}/sdk-token"
payload = {
"user_platforms": ["YOUTUBE", "TIKTOK"],
"enabled_scopes": ["PROFILE_READ"],
"callback_url": "https://your-app.com/api/oauth/callback",
"redirect_url": "https://your-app.com/dashboard/accounts"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user_platforms: ['YOUTUBE', 'TIKTOK'],
enabled_scopes: ['PROFILE_READ'],
callback_url: 'https://your-app.com/api/oauth/callback',
redirect_url: 'https://your-app.com/dashboard/accounts'
})
};
fetch('https://api.tapti.ai/users/{id}/sdk-token', 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.tapti.ai/users/{id}/sdk-token",
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([
'user_platforms' => [
'YOUTUBE',
'TIKTOK'
],
'enabled_scopes' => [
'PROFILE_READ'
],
'callback_url' => 'https://your-app.com/api/oauth/callback',
'redirect_url' => 'https://your-app.com/dashboard/accounts'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.tapti.ai/users/{id}/sdk-token"
payload := strings.NewReader("{\n \"user_platforms\": [\n \"YOUTUBE\",\n \"TIKTOK\"\n ],\n \"enabled_scopes\": [\n \"PROFILE_READ\"\n ],\n \"callback_url\": \"https://your-app.com/api/oauth/callback\",\n \"redirect_url\": \"https://your-app.com/dashboard/accounts\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.tapti.ai/users/{id}/sdk-token")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user_platforms\": [\n \"YOUTUBE\",\n \"TIKTOK\"\n ],\n \"enabled_scopes\": [\n \"PROFILE_READ\"\n ],\n \"callback_url\": \"https://your-app.com/api/oauth/callback\",\n \"redirect_url\": \"https://your-app.com/dashboard/accounts\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tapti.ai/users/{id}/sdk-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_platforms\": [\n \"YOUTUBE\",\n \"TIKTOK\"\n ],\n \"enabled_scopes\": [\n \"PROFILE_READ\"\n ],\n \"callback_url\": \"https://your-app.com/api/oauth/callback\",\n \"redirect_url\": \"https://your-app.com/dashboard/accounts\"\n}"
response = http.request(request)
puts response.read_body{
"oauth_portal_url": "https://oauth-portal.example.com?sdk_token=8pjBUEbqcA3bkKEBTmZ2WsduYwMH6UU23byRiU2rs.........&origin=https://your-app.com/dashboard/accounts"
}User
Generate SDK Token
POST
/
users
/
{id}
/
sdk-token
Create a SDK token for a user
curl --request POST \
--url https://api.tapti.ai/users/{id}/sdk-token \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"user_platforms": [
"YOUTUBE",
"TIKTOK"
],
"enabled_scopes": [
"PROFILE_READ"
],
"callback_url": "https://your-app.com/api/oauth/callback",
"redirect_url": "https://your-app.com/dashboard/accounts"
}
'import requests
url = "https://api.tapti.ai/users/{id}/sdk-token"
payload = {
"user_platforms": ["YOUTUBE", "TIKTOK"],
"enabled_scopes": ["PROFILE_READ"],
"callback_url": "https://your-app.com/api/oauth/callback",
"redirect_url": "https://your-app.com/dashboard/accounts"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user_platforms: ['YOUTUBE', 'TIKTOK'],
enabled_scopes: ['PROFILE_READ'],
callback_url: 'https://your-app.com/api/oauth/callback',
redirect_url: 'https://your-app.com/dashboard/accounts'
})
};
fetch('https://api.tapti.ai/users/{id}/sdk-token', 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.tapti.ai/users/{id}/sdk-token",
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([
'user_platforms' => [
'YOUTUBE',
'TIKTOK'
],
'enabled_scopes' => [
'PROFILE_READ'
],
'callback_url' => 'https://your-app.com/api/oauth/callback',
'redirect_url' => 'https://your-app.com/dashboard/accounts'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.tapti.ai/users/{id}/sdk-token"
payload := strings.NewReader("{\n \"user_platforms\": [\n \"YOUTUBE\",\n \"TIKTOK\"\n ],\n \"enabled_scopes\": [\n \"PROFILE_READ\"\n ],\n \"callback_url\": \"https://your-app.com/api/oauth/callback\",\n \"redirect_url\": \"https://your-app.com/dashboard/accounts\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.tapti.ai/users/{id}/sdk-token")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"user_platforms\": [\n \"YOUTUBE\",\n \"TIKTOK\"\n ],\n \"enabled_scopes\": [\n \"PROFILE_READ\"\n ],\n \"callback_url\": \"https://your-app.com/api/oauth/callback\",\n \"redirect_url\": \"https://your-app.com/dashboard/accounts\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tapti.ai/users/{id}/sdk-token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_platforms\": [\n \"YOUTUBE\",\n \"TIKTOK\"\n ],\n \"enabled_scopes\": [\n \"PROFILE_READ\"\n ],\n \"callback_url\": \"https://your-app.com/api/oauth/callback\",\n \"redirect_url\": \"https://your-app.com/dashboard/accounts\"\n}"
response = http.request(request)
puts response.read_body{
"oauth_portal_url": "https://oauth-portal.example.com?sdk_token=8pjBUEbqcA3bkKEBTmZ2WsduYwMH6UU23byRiU2rs.........&origin=https://your-app.com/dashboard/accounts"
}Create a SDK token for a user. This token is required for client-side operations and OAuth portal access.
OAuth Portal Integration
The SDK token is essential for using Tapti’s OAuth Portal, where your users can securely connect their social media accounts:// 1. Generate SDK token on your backend
const sdkToken = await tapti.user().createSDKToken(userId);
// 2. Redirect user to OAuth Portal
const oauthUrl = `https://oauth.tapti.dev?sdk_token=${sdkToken}`;
// Optional: Specify platform to skip selection screen
const youtubeOauthUrl = `https://oauth.tapti.dev?sdk_token=${sdkToken}&platform=youtube`;
The OAuth Portal provides a secure, branded experience for connecting social media accounts without requiring you to
implement complex OAuth flows.
Security Considerations
- SDK tokens are short-lived and user-specific - Never store tokens in localStorage or expose them in client-side source code - Generate new tokens just before redirecting to the OAuth Portal - Include only necessary platform permissions
Related Resources
OAuth Portal
Learn more about the OAuth Portal
SDK Tokens
Understanding SDK tokens
Authorizations
Path Parameters
Body
application/json
The SDK token to create
The platforms to create the SDK token for
Available options:
YOUTUBE, TIKTOK, INSTAGRAM, INSTAPRO, FACEBOOK, X, LINKEDIN Example:
["YOUTUBE", "TIKTOK"]
The scopes to create the SDK token for
Available options:
PROFILE_READ, PROFILE_WRITE, CONTENT_READ, CONTENT_WRITE, ANALYTICS_READ, COMMENTS_READ, COMMENTS_WRITE Example:
["PROFILE_READ"]
The callback URL to send the account connection response to
Example:
"https://your-app.com/api/oauth/callback"
The redirect URL to redirect the user after successful authentication
Example:
"https://your-app.com/dashboard/accounts"
Response
SDK token created successfully
The OAuth portal URL to redirect the user to
Example:
"https://oauth-portal.example.com?sdk_token=8pjBUEbqcA3bkKEBTmZ2WsduYwMH6UU23byRiU2rs.........&origin=https://your-app.com/dashboard/accounts"
