Moderate Text
The Copyleaks Text Moderation API provides real-time content moderation capabilities to help you maintain safe and appropriate content across your platform. This API automatically scans and flags potentially harmful content across multiple categories, enabling you to take appropriate action to protect your users and maintain community standards.
Request
Section titled “Request”Path Parameters
Section titled “Path Parameters”A unique scan id provided by you. We recommend you use the same id in your database to represent the scan in the Copyleaks database. This will help you to debug incidents. Using the same ID for the same file will help you to avoid network problems that may lead to multiple scans for the same file. learn more about the criteria for creating a Scan ID.
>= 3 characters
<= 36 characters
Match pattern: [a-z0-9] !@$^&-+%=_(){}<>';:/.",~
|
Headers
Section titled “Headers”Content-Type: application/jsonAuthorization: Bearer YOUR_LOGIN_TOKEN
Request Body
Section titled “Request Body”The request body is a JSON object containing the text to scan.
Text to produce Text Moderation report for.
>= 1 characters
<= 25000 characters
Use sandbox mode to test your integration with the Copyleaks API without consuming any credits.
Submit content for Text Moderation and get returned mock results, simulating Copyleaks’ API functionality to ensure you have successfully integrated the API.
This feature is intended to be used for development purposes only.
The language code of your content. The selected language should be on the Supported Languages list above. If the ‘language’ field is not specified, our system will automatically detect the language of the content.
Example: "en"
labels array[object]
A list of label configurations to be used for the moderation process.
Identifier for the label. List of moderation labels.
>= 1 characters
<= 32 characters
Responses
Section titled “Responses”The scan was Created.
Response Schema
The response contains the following fields:
moderations object
scannedDocument object
Example Response
A typical response from this endpoint:
{ "modelVersion": "v1", "moderations": { "text": { "chars": { "labels": [ 4, 4, 4, 2, 7, 6 ], "starts": [ 15,// ... truncated
Bad Request.
Example Response
A typical response from this endpoint:
{ "ErrorMessage": "Id Label my-label is not supported", "ErrorCode": "Bad Request"}
Authorization has been denied for this request.
Example Response
A typical response from this endpoint:
{ "type": "https://tools.ietf.org/html/rfc9110#section-15.5.2", "title": "Unauthorized", "status": 401, "traceId": "00-ef0db7690ced98431ac97782051edc77-2c4194d74ae6c08b-00"}
A scan with the same Id already exists in the system.
Example Response
A typical response from this endpoint:
{ "type": "https://tools.ietf.org/html/rfc9110#section-15.5.10", "title": "Conflict", "status": 409, "traceId": "00-561fe3b2451eb51ce489557a2f34f247-3acd41c0b4ad1295-00"}
Too many requests have been sent. The request has been rejected.
Example Response
A typical response from this endpoint:
{ "error": "Rate limit exceeded",}
Examples
Section titled “Examples”POST https://api.copyleaks.com/v1/text-moderation/my-scan-123/checkContent-Type: application/jsonAuthorization: Bearer YOUR_LOGIN_TOKEN
{ "text": "Your text content to be moderated goes here.", "sandbox": true, "labels": [ { "id": "toxic-v1" }, { "id": "profanity-v1" }, { "id": "hate-speech-v1" } ]}
curl --request POST \ --url https://api.copyleaks.com/v1/text-moderation/my-scan-123/check \ --header 'Authorization: Bearer YOUR_LOGIN_TOKEN' \ --header 'Content-Type: application/json' \ --data '{ "text": "Your text content to be moderated goes here.", "sandbox": true, "labels": [ { "id": "toxic-v1" }, { "id": "profanity-v1" }, { "id": "hate-speech-v1" } ] }'