List the moderation actions of the project. The list is paginated.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.actions.list(page=1, page_size=20)
while res is not None:
# Handle items
res = res.next()
| Parameter |
Type |
Required |
Description |
queue_id |
Optional[str] |
➖ |
N/A |
page |
Optional[int] |
➖ |
N/A |
page_size |
Optional[int] |
➖ |
N/A |
project_id |
Optional[str] |
➖ |
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. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ListActionsResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.PermissionDeniedError |
403 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.InternalServerError |
500 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Create an action.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.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)
| Parameter |
Type |
Required |
Description |
name |
str |
✔️ |
The name of the action. |
project_id |
Optional[str] |
➖ |
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. |
key |
OptionalNullable[str] |
➖ |
User defined key of the action. |
description |
OptionalNullable[str] |
➖ |
The description of the action. |
type |
OptionalNullable[models.CreateActionTypeRequest] |
➖ |
The type of the action. |
built_in |
OptionalNullable[bool] |
➖ |
Whether the action is a built-in action or a custom one. |
queue_behaviour |
Optional[models.CreateActionQueueBehaviourRequest] |
➖ |
Whether the action resolves and removes the item, unresolves and re-add it to the queue, or does not change the resolve status. |
filter_in_queue_ids |
List[str] |
➖ |
The IDs of the queues the action is available in. |
position |
Optional[models.CreateActionPositionRequest] |
➖ |
Show the action in all queues, selected queues or no queues (to use via API only). |
possible_values |
List[models.CreateActionPossibleValueRequest] |
➖ |
The possible values of the action. The user will be prompted to select one of these values when executing the action. |
value_required |
Optional[bool] |
➖ |
Whether the action requires a value to be executed. |
free_text |
Optional[bool] |
➖ |
Whether the action allows any text to be entered as a value or if it must be one of the possible values. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.CreateActionResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.ConflictError |
409 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Get an action by ID.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.actions.retrieve(id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
str |
✔️ |
The ID of the action to get. |
project_id |
Optional[str] |
➖ |
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. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.GetActionResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Update an action.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.actions.update(id="<id>", built_in=False, queue_behaviour="NO_CHANGE", position="ALL_QUEUES", value_required=False, free_text=False)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
str |
✔️ |
The ID of the action to update. |
project_id |
Optional[str] |
➖ |
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. |
key |
OptionalNullable[str] |
➖ |
User defined key of the action. |
name |
Optional[str] |
➖ |
The name of the action. |
description |
OptionalNullable[str] |
➖ |
The description of the action. |
type |
OptionalNullable[models.UpdateActionTypeRequest] |
➖ |
The type of the action. |
built_in |
OptionalNullable[bool] |
➖ |
Whether the action is a built-in action or a custom one. |
queue_behaviour |
Optional[models.UpdateActionQueueBehaviourRequest] |
➖ |
Whether the action resolves and removes the item, unresolves and re-add it to the queue, or does not change the resolve status. |
filter_in_queue_ids |
List[str] |
➖ |
The IDs of the queues the action is available in. |
position |
Optional[models.UpdateActionPositionRequest] |
➖ |
Show the action in all queues, selected queues or no queues (to use via API only). |
possible_values |
List[models.UpdateActionPossibleValueRequest] |
➖ |
The possible values of the action. The user will be prompted to select one of these values when executing the action. |
value_required |
Optional[bool] |
➖ |
Whether the action requires a value to be executed. |
free_text |
Optional[bool] |
➖ |
Whether the action allows any text to be entered as a value or if it must be one of the possible values. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.UpdateActionResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.ConflictError |
409 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Delete an action and all of its webhooks.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.actions.delete(id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
str |
✔️ |
The ID of the action to delete. |
project_id |
Optional[str] |
➖ |
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. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.DeleteActionResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |
Execute a moderation action on one or more content items.
from moderation_api import ModerationAPI
import os
with ModerationAPI(
secret_key=os.getenv("MODAPI_SECRET_KEY", ""),
) as ma_client:
res = ma_client.actions.execute(action_key="suspend-24h", author_ids=[
"user-1092",
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
action_key |
str |
✔️ |
ID or key of the action to execute |
project_id |
Optional[str] |
➖ |
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. |
content_ids |
List[str] |
➖ |
IDs of the content items to apply the action to. Provide this or authorIds. |
author_ids |
List[str] |
➖ |
IDs of the authors to apply the action to. Provide this or contentIds. |
value |
Optional[str] |
➖ |
Optional value to provide with the action |
queue_id |
Optional[str] |
➖ |
Optional queue ID if the action is queue-specific |
duration |
Optional[float] |
➖ |
Optional duration in milliseconds for actions with timeouts |
moderator |
Optional[str] |
➖ |
The user ID or email of the organization member who made the decision. The action is recorded as theirs. |
create_casebook_case |
Optional[bool] |
➖ |
Record an allow or reject decision as a casebook case. Defaults to true when moderator is set, else false. Without moderator, the case is recorded as System. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ExecuteActionResponse
| Error Type |
Status Code |
Content Type |
| errors.BadRequestError |
400 |
application/json |
| errors.AuthenticationError |
401 |
application/json |
| errors.NotFoundError |
404 |
application/json |
| errors.RateLimitError |
429 |
application/json |
| errors.ModerationAPIDefaultError |
4XX, 5XX |
*/* |