curl -X POST 'https://api.moderationapi.com/v1/actions/execute' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}'
import { ModerationApi } from "@moderation-api/sdk";
// Reads your API key from the MODAPI_SECRET_KEY environment variable
const moderationApi = new ModerationApi();
// Or pass the key explicitly
// const moderationApi = new ModerationApi({ secretKey: "<token>" });
await moderationApi.actions.execute({
actionKey: "suspend-author",
contentIds: ["60c9e1c0e4e7e1001c7a0e1e", "60c9e1c0e4e7e1001c7a0e1f"],
value: "Spam",
});
require "moderation_api"
Operations = ModerationApi::Models::Operations
client = ModerationApi::ModerationApi.new(secret_key: ENV.fetch("MODAPI_SECRET_KEY"))
client.actions.execute(body: Operations::ExecuteActionRequestBody.new(
action_key: "suspend-author",
content_ids: [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
value: "Spam"
))
import requests
url = "https://api.moderationapi.com/v1/actions/execute"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}
response = requests.post(url, headers=headers, json=payload)
<?php
$url = "https://api.moderationapi.com/v1/actions/execute";
$headers = array(
"Authorization: Bearer <token>",
"Content-Type: application/json"
);
$data = array(
"contentIds" => array(
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
),
"actionKey" => "suspend-author",
"value" => "Spam"
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
?>
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
String url = "https://api.moderationapi.com/v1/actions/execute";
String requestBody = """
{
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.moderationapi.com/v1/actions/execute"
data := map[string]interface{}{
"contentIds": []string{
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f",
},
"actionKey": "suspend-author",
"value": "Spam",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
{
"success": true
}{
"type": "invalid_request_error",
"code": "invalid_request",
"message": "Invalid input data",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "authentication_error",
"code": "unauthorized",
"message": "Authorization not provided",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "not_found_error",
"code": "resource_not_found",
"message": "Not found",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}Execute moderation action
Execute one action of the project, by ID or key, on content items or authors. A built-in action changes them in Moderation API (for example rejects the items or blocks the authors). Every executed action is recorded, and the project sends it to the webhooks of the action and to its other webhook endpoints, where the customer platform can act on it. List the actions first to see what each one does.
curl -X POST 'https://api.moderationapi.com/v1/actions/execute' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}'
import { ModerationApi } from "@moderation-api/sdk";
// Reads your API key from the MODAPI_SECRET_KEY environment variable
const moderationApi = new ModerationApi();
// Or pass the key explicitly
// const moderationApi = new ModerationApi({ secretKey: "<token>" });
await moderationApi.actions.execute({
actionKey: "suspend-author",
contentIds: ["60c9e1c0e4e7e1001c7a0e1e", "60c9e1c0e4e7e1001c7a0e1f"],
value: "Spam",
});
require "moderation_api"
Operations = ModerationApi::Models::Operations
client = ModerationApi::ModerationApi.new(secret_key: ENV.fetch("MODAPI_SECRET_KEY"))
client.actions.execute(body: Operations::ExecuteActionRequestBody.new(
action_key: "suspend-author",
content_ids: [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
value: "Spam"
))
import requests
url = "https://api.moderationapi.com/v1/actions/execute"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}
response = requests.post(url, headers=headers, json=payload)
<?php
$url = "https://api.moderationapi.com/v1/actions/execute";
$headers = array(
"Authorization: Bearer <token>",
"Content-Type: application/json"
);
$data = array(
"contentIds" => array(
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
),
"actionKey" => "suspend-author",
"value" => "Spam"
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
?>
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
String url = "https://api.moderationapi.com/v1/actions/execute";
String requestBody = """
{
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.moderationapi.com/v1/actions/execute"
data := map[string]interface{}{
"contentIds": []string{
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f",
},
"actionKey": "suspend-author",
"value": "Spam",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
{
"success": true
}{
"type": "invalid_request_error",
"code": "invalid_request",
"message": "Invalid input data",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "authentication_error",
"code": "unauthorized",
"message": "Authorization not provided",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "not_found_error",
"code": "resource_not_found",
"message": "Not found",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}{
"type": "rate_limit_error",
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded",
"request_id": "h8fkz6kkzoa446ffve37atys",
"doc_url": "<string>",
"issues": [
{
"message": "<string>",
"path": [
"<string>"
],
"code": "<string>"
}
]
}curl -X POST 'https://api.moderationapi.com/v1/actions/execute' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}'
import { ModerationApi } from "@moderation-api/sdk";
// Reads your API key from the MODAPI_SECRET_KEY environment variable
const moderationApi = new ModerationApi();
// Or pass the key explicitly
// const moderationApi = new ModerationApi({ secretKey: "<token>" });
await moderationApi.actions.execute({
actionKey: "suspend-author",
contentIds: ["60c9e1c0e4e7e1001c7a0e1e", "60c9e1c0e4e7e1001c7a0e1f"],
value: "Spam",
});
require "moderation_api"
Operations = ModerationApi::Models::Operations
client = ModerationApi::ModerationApi.new(secret_key: ENV.fetch("MODAPI_SECRET_KEY"))
client.actions.execute(body: Operations::ExecuteActionRequestBody.new(
action_key: "suspend-author",
content_ids: [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
value: "Spam"
))
import requests
url = "https://api.moderationapi.com/v1/actions/execute"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
payload = {
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}
response = requests.post(url, headers=headers, json=payload)
<?php
$url = "https://api.moderationapi.com/v1/actions/execute";
$headers = array(
"Authorization: Bearer <token>",
"Content-Type: application/json"
);
$data = array(
"contentIds" => array(
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
),
"actionKey" => "suspend-author",
"value" => "Spam"
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
?>
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
String url = "https://api.moderationapi.com/v1/actions/execute";
String requestBody = """
{
"contentIds": [
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f"
],
"actionKey": "suspend-author",
"value": "Spam"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
url := "https://api.moderationapi.com/v1/actions/execute"
data := map[string]interface{}{
"contentIds": []string{
"60c9e1c0e4e7e1001c7a0e1e",
"60c9e1c0e4e7e1001c7a0e1f",
},
"actionKey": "suspend-author",
"value": "Spam",
}
jsonData, _ := json.Marshal(data)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result)
}
Authorizations
Headers
Body
application/json
Input parameters
Was this page helpful?