curl --request PUT \
--url https://api.sapt.ai/projects/{projectId}/capi-pixel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pixelId": "1234567890",
"accessToken": "<string>",
"testEventCode": "TEST12345",
"useOauthToken": true
}
'import requests
url = "https://api.sapt.ai/projects/{projectId}/capi-pixel"
payload = {
"pixelId": "1234567890",
"accessToken": "<string>",
"testEventCode": "TEST12345",
"useOauthToken": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
pixelId: '1234567890',
accessToken: '<string>',
testEventCode: 'TEST12345',
useOauthToken: true
})
};
fetch('https://api.sapt.ai/projects/{projectId}/capi-pixel', 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.sapt.ai/projects/{projectId}/capi-pixel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'pixelId' => '1234567890',
'accessToken' => '<string>',
'testEventCode' => 'TEST12345',
'useOauthToken' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.sapt.ai/projects/{projectId}/capi-pixel"
payload := strings.NewReader("{\n \"pixelId\": \"1234567890\",\n \"accessToken\": \"<string>\",\n \"testEventCode\": \"TEST12345\",\n \"useOauthToken\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://api.sapt.ai/projects/{projectId}/capi-pixel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"pixelId\": \"1234567890\",\n \"accessToken\": \"<string>\",\n \"testEventCode\": \"TEST12345\",\n \"useOauthToken\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sapt.ai/projects/{projectId}/capi-pixel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"pixelId\": \"1234567890\",\n \"accessToken\": \"<string>\",\n \"testEventCode\": \"TEST12345\",\n \"useOauthToken\": true\n}"
response = http.request(request)
puts response.read_body{
"connected": true,
"pixelId": "<string>",
"tokenSource": "paste",
"testEventCode": "<string>",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}Connect or update the CAPI pixel
Pin a Meta Pixel for server-side Conversions API. Provide accessToken for a pixel-scoped token generated in Events Manager, or set useOauthToken: true to source the token from the project’s Meta OAuth connection.
curl --request PUT \
--url https://api.sapt.ai/projects/{projectId}/capi-pixel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pixelId": "1234567890",
"accessToken": "<string>",
"testEventCode": "TEST12345",
"useOauthToken": true
}
'import requests
url = "https://api.sapt.ai/projects/{projectId}/capi-pixel"
payload = {
"pixelId": "1234567890",
"accessToken": "<string>",
"testEventCode": "TEST12345",
"useOauthToken": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
pixelId: '1234567890',
accessToken: '<string>',
testEventCode: 'TEST12345',
useOauthToken: true
})
};
fetch('https://api.sapt.ai/projects/{projectId}/capi-pixel', 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.sapt.ai/projects/{projectId}/capi-pixel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'pixelId' => '1234567890',
'accessToken' => '<string>',
'testEventCode' => 'TEST12345',
'useOauthToken' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.sapt.ai/projects/{projectId}/capi-pixel"
payload := strings.NewReader("{\n \"pixelId\": \"1234567890\",\n \"accessToken\": \"<string>\",\n \"testEventCode\": \"TEST12345\",\n \"useOauthToken\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://api.sapt.ai/projects/{projectId}/capi-pixel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"pixelId\": \"1234567890\",\n \"accessToken\": \"<string>\",\n \"testEventCode\": \"TEST12345\",\n \"useOauthToken\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sapt.ai/projects/{projectId}/capi-pixel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"pixelId\": \"1234567890\",\n \"accessToken\": \"<string>\",\n \"testEventCode\": \"TEST12345\",\n \"useOauthToken\": true\n}"
response = http.request(request)
puts response.read_body{
"connected": true,
"pixelId": "<string>",
"tokenSource": "paste",
"testEventCode": "<string>",
"updatedAt": "2023-11-07T05:31:56Z"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}{
"message": "<string>",
"code": "<string>"
}Authorizations
JWT token obtained from /api/auth/token endpoint. Token is verified using JWKS and must include a valid user identifier.
Path Parameters
The project id.
"123e4567-e89b-12d3-a456-426614174000"
Body
The Meta Pixel id to send events to.
1"1234567890"
A pixel-scoped CAPI access token generated in Meta Events Manager. Omit and set useOauthToken: true to source the token from the project’s Meta OAuth connection instead.
Optional Events Manager test-event code, used to route test events to the Test Events tab.
"TEST12345"
Set true to source the token from the Meta OAuth connection. Required when accessToken is omitted on first connect.
Response
CAPI pixel connected
Whether a CAPI pixel is connected.
The connected Meta Pixel id.
paste = a pixel-scoped token you supplied; oauth = derived from the Meta connection. The token itself is never returned.
paste, oauth, null