import { ModerationApi } from "@moderation-api/sdk";
const moderationApi = new ModerationApi({
secretKey: process.env["MODAPI_SECRET_KEY"] ?? "",
});
async function run() {
const result = await moderationApi.actions.create({
body: {
key: "suspend-24h",
name: "Suspend for 24 hours",
type: "AUTHOR_BLOCK_TEMP",
queueBehaviour: "REMOVE",
},
});
console.log(result);
}
run();
import os
from moderation_api import ModerationAPI
with ModerationAPI(
secret_key=os.environ["MODAPI_SECRET_KEY"],
) as moderation_api:
res = moderation_api.actions.create(name="Suspend for 24 hours", key="suspend-24h", type_="AUTHOR_BLOCK_TEMP", built_in=False, queue_behaviour="REMOVE", position="ALL_QUEUES", value_required=False, free_text=False)
# Handle response
print(res)
declare(strict_types=1);
require 'vendor/autoload.php';
use ModerationApi;
use ModerationApi\Models\Operations;
$sdk = ModerationApi\ModerationApi::builder()
->setSecurity(
getenv('MODAPI_SECRET_KEY')
)
->build();
$body = new Operations\CreateActionRequestBody(
key: 'suspend-24h',
name: 'Suspend for 24 hours',
type: Operations\CreateActionTypeRequest::AuthorBlockTemp,
queueBehaviour: Operations\CreateActionQueueBehaviourRequest::Remove,
);
$response = $sdk->actions->create(
body: $body
);
if ($response->object !== null) {
// handle response
}
require 'moderation_api'
Models = ::ModerationApi::Models
s = ::ModerationApi::ModerationApi.new(
secret_key: ENV.fetch('MODAPI_SECRET_KEY')
)
res = s.actions.create(body: Models::Operations::CreateActionRequestBody.new(
key: 'suspend-24h',
name: 'Suspend for 24 hours',
type: Models::Operations::CreateActionTypeRequest::AUTHOR_BLOCK_TEMP,
queue_behaviour: Models::Operations::CreateActionQueueBehaviourRequest::REMOVE
))
unless res.object.nil?
# handle response
end
modapi actions create --secret-key "$MODAPI_SECRET_KEY" --key '"suspend-24h"' --name 'Suspend for 24 hours' --type '"AUTHOR_BLOCK_TEMP"' --queue-behaviour REMOVE
{
"id": "<string>",
"createdAt": "<string>",
"name": "<string>",
"builtIn": false,
"queueBehaviour": "NO_CHANGE",
"filterInQueueIds": [],
"position": "ALL_QUEUES",
"possibleValues": [],
"valueRequired": false,
"freeText": false,
"key": "<string>",
"description": "<string>",
"type": "AUTHOR_BLOCK"
}{
"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": "conflict_error",
"code": "resource_conflict",
"message": "Action with this key already exists",
"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>"
}
]
}Create an action
Create an action.
import { ModerationApi } from "@moderation-api/sdk";
const moderationApi = new ModerationApi({
secretKey: process.env["MODAPI_SECRET_KEY"] ?? "",
});
async function run() {
const result = await moderationApi.actions.create({
body: {
key: "suspend-24h",
name: "Suspend for 24 hours",
type: "AUTHOR_BLOCK_TEMP",
queueBehaviour: "REMOVE",
},
});
console.log(result);
}
run();
import os
from moderation_api import ModerationAPI
with ModerationAPI(
secret_key=os.environ["MODAPI_SECRET_KEY"],
) as moderation_api:
res = moderation_api.actions.create(name="Suspend for 24 hours", key="suspend-24h", type_="AUTHOR_BLOCK_TEMP", built_in=False, queue_behaviour="REMOVE", position="ALL_QUEUES", value_required=False, free_text=False)
# Handle response
print(res)
declare(strict_types=1);
require 'vendor/autoload.php';
use ModerationApi;
use ModerationApi\Models\Operations;
$sdk = ModerationApi\ModerationApi::builder()
->setSecurity(
getenv('MODAPI_SECRET_KEY')
)
->build();
$body = new Operations\CreateActionRequestBody(
key: 'suspend-24h',
name: 'Suspend for 24 hours',
type: Operations\CreateActionTypeRequest::AuthorBlockTemp,
queueBehaviour: Operations\CreateActionQueueBehaviourRequest::Remove,
);
$response = $sdk->actions->create(
body: $body
);
if ($response->object !== null) {
// handle response
}
require 'moderation_api'
Models = ::ModerationApi::Models
s = ::ModerationApi::ModerationApi.new(
secret_key: ENV.fetch('MODAPI_SECRET_KEY')
)
res = s.actions.create(body: Models::Operations::CreateActionRequestBody.new(
key: 'suspend-24h',
name: 'Suspend for 24 hours',
type: Models::Operations::CreateActionTypeRequest::AUTHOR_BLOCK_TEMP,
queue_behaviour: Models::Operations::CreateActionQueueBehaviourRequest::REMOVE
))
unless res.object.nil?
# handle response
end
modapi actions create --secret-key "$MODAPI_SECRET_KEY" --key '"suspend-24h"' --name 'Suspend for 24 hours' --type '"AUTHOR_BLOCK_TEMP"' --queue-behaviour REMOVE
{
"id": "<string>",
"createdAt": "<string>",
"name": "<string>",
"builtIn": false,
"queueBehaviour": "NO_CHANGE",
"filterInQueueIds": [],
"position": "ALL_QUEUES",
"possibleValues": [],
"valueRequired": false,
"freeText": false,
"key": "<string>",
"description": "<string>",
"type": "AUTHOR_BLOCK"
}{
"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": "conflict_error",
"code": "resource_conflict",
"message": "Action with this key already exists",
"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>"
}
]
}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
The name of the action.
User defined key of the action.
The description of the action.
The type of the action.
AUTHOR_BLOCK, AUTHOR_BLOCK_TEMP, AUTHOR_UNBLOCK, AUTHOR_DELETE, AUTHOR_REPORT, AUTHOR_WARN, AUTHOR_CUSTOM, ITEM_REJECT, ITEM_ALLOW, ITEM_CUSTOM Whether the action is a built-in action or a custom one.
Whether the action resolves and removes the item, unresolves and re-add it to the queue, or does not change the resolve status.
REMOVE, ADD, NO_CHANGE The IDs of the queues the action is available in.
Show the action in all queues, selected queues or no queues (to use via API only).
ALL_QUEUES, SOME_QUEUES, HIDDEN The possible values of the action. The user will be prompted to select one of these values when executing the action.
Show child attributes
Show child attributes
Whether the action requires a value to be executed.
Whether the action allows any text to be entered as a value or if it must be one of the possible values.
Response
Action created successfully
The ID of the action.
The date the action was created.
The name of the action.
Whether the action is a built-in action or a custom one.
Whether the action resolves and removes the item, unresolves and re-add it to the queue, or does not change the resolve status.
REMOVE, ADD, NO_CHANGE The IDs of the queues the action is available in.
Show the action in all queues, selected queues or no queues (to use via API only).
ALL_QUEUES, SOME_QUEUES, HIDDEN The possible values of the action. The user will be prompted to select one of these values when executing the action.
Show child attributes
Show child attributes
Whether the action requires a value to be executed.
Whether the action allows any text to be entered as a value or if it must be one of the possible values.
User defined key of the action.
The description of the action.
The type of the action.
AUTHOR_BLOCK, AUTHOR_BLOCK_TEMP, AUTHOR_UNBLOCK, AUTHOR_DELETE, AUTHOR_REPORT, AUTHOR_WARN, AUTHOR_CUSTOM, ITEM_REJECT, ITEM_ALLOW, ITEM_CUSTOM Was this page helpful?