# Classify content (/docs/api-reference/risk/classify-risk-content)

Scores text people post on your platform (a profile bio, a comment, a listing) for spam, phishing, malware and fraud with an AI model, with zero data retention. Returns scores only: you decide what they mean. Neither the text nor the scores are stored, and request logs keep no body for this endpoint. Takes up to 3 seconds; a failure is a 503 you can retry or treat as unknown. Each live classification the model answered is billed (`risk.content_checks`; plans include some every month, and Free stops at its allowance). Limited per organization as well as per key. Sandbox keys use markers instead of a model: `[coss-test:phishing]` scores 0.99, `[coss-test:spam:0.4]` exactly 0.4, everything else 0.01.

`POST https://api.coss.com/v1/risk/content/classify`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Request body

- `text` (string, required, 1-50000 characters): The text to classify (a profile bio, a comment, a listing). The model reads the first 8,000 characters.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.risk.classify({
  text: "Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash",
});
```

HTTP:

```sh
curl -X POST "https://api.coss.com/v1/risk/content/classify" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash"
}'
```

Python:

```python
from coss import Coss

client = Coss()  # api_key= or COSS_API_KEY

client.risk.classify(
    text="Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash",
)
```

Go:

```go
import (
	"context"

	coss "github.com/cosscom/coss-go"
	cossclient "github.com/cosscom/coss-go/client"
)

client := cossclient.NewClient() // option.WithAPIKey(…) or COSS_API_KEY

request := &coss.RiskContentClassifyRequest{
    Text: "Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash",
}
client.Risk.Classify(
    context.TODO(),
    request,
)
```

Ruby:

```ruby
require "coss"

client = Coss::Client.new # api_key: or COSS_API_KEY

client.risk.classify(text: "Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash")
```

PHP:

```php
<?php

use Coss\Coss;
use Coss\Risk\Requests\RiskContentClassifyRequest;

$client = new Coss(); // apiKey: or COSS_API_KEY

$client->risk->classify(
    new RiskContentClassifyRequest([
        'text' => 'Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash',
    ]),
);
```

Java:

```java
import com.coss.Coss;
import com.coss.resources.risk.requests.RiskContentClassifyRequest;

Coss client = Coss.builder().build(); // .apiKey(…) or COSS_API_KEY

client.risk().classify(
    RiskContentClassifyRequest
        .builder()
        .text("Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash")
        .build()
);
```

.NET:

```csharp
using Coss;

var client = new CossClient(); // apiKey: or COSS_API_KEY

await client.Risk.ClassifyAsync(
    new RiskContentClassifyRequest
    {
        Text = "Earn $5,000 a week from home! DM me on Telegram: t.me/fast-cash",
    }
);
```

## Response 200

The scores.

- `object` ("risk_content_classification", required)
- `scores` (object, required): Per category, the model's probability (0-1) that the content belongs to it. Scores are not calibrated: pick thresholds by looking at your own traffic.
  - `spam` (number, required, 0-1): The model's probability (0-1) that it's spam.
  - `phishing` (number, required, 0-1): The model's probability (0-1) that it's phishing.
  - `malware` (number, required, 0-1): The model's probability (0-1) that it's malware.
  - `fraud` (number, required, 0-1): The model's probability (0-1) that it's fraud.
- `truncated` (boolean, required): The text was longer than the model reads: only its beginning was classified.

Example:

```json
{
  "object": "risk_content_classification",
  "scores": {
    "spam": 0.91,
    "phishing": 0.04,
    "malware": 0.01,
    "fraud": 0.86
  },
  "truncated": false
}
```

## Errors

- `400`: The body is not valid JSON (`invalid_json`). Also when the `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `402`: The plan's included content checks are used up (`usage_limit_exceeded`), or live checks are paused by an overdue invoice, a spend limit (`billing_hold`) or a budget (`budget_exceeded`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `413`: The request body is larger than 5 MB (`payload_too_large`).
- `415`: The body is not sent as `application/json` (`unsupported_media_type`).
- `422`: The body failed validation (`validation_error`, see `issues`).
- `429`: Too many requests with this API key (`rate_limited`), too many classifications for this organization (`classification_rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds.
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The model failed or took longer than 3 seconds (`classification_unavailable`), or the API key could not be verified right now (`service_unavailable`). Retry later, or go without the scores.