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 a moderation action on one or more content items.
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
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
The project to act on, by ID or name. Required with an organization key unless the key reaches only one project; list projects with GET /projects. A project key acts on its own project and needs no value: naming another one is an error.
Body
Input parameters
ID or key of the action to execute
IDs of the content items to apply the action to. Provide this or authorIds.
IDs of the authors to apply the action to. Provide this or contentIds.
Optional value to provide with the action
Optional queue ID if the action is queue-specific
Optional duration in milliseconds for actions with timeouts
x >= 0Response
Action executed successfully
Execution result
Whether the action was executed successfully
Was this page helpful?