# Rate image

> Queues a content rating for an image and returns the task. The result is a single level, so this is the cheap check to run before publishing something generated.

`POST /image/rate`

**Auth:** API key or OAuth token

## Request body

### nsfw_sfw

- `url` (required, string) — format: uri.
- `mode` ("nsfw_sfw") — Default `"nsfw_sfw"`.

### custom

- `url` (required, string) — format: uri.
- `mode` (required, "custom")
- `levels` (required, object[]) — ≥ 2 items, ≤ 7 items.
  - `value` (required, string) — ≥ 1 characters, ≤ 24 characters.
  - `description` (required, string) — ≥ 1 characters, ≤ 150 characters.

## Response

### 201 — Image rating task created

- `data` (required, object)
  - `task_id` (required, string) — Task ID Example `"tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"`.
  - `estimated_cost` (required, string) — Estimated cost in USD reserved for this task. Work that fails is refunded, so the final cost may be lower. Example `"0.03"`.

```json
{
  "data": {
    "task_id": "tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP",
    "estimated_cost": "0.03"
  }
}
```

### 400 — The request was rejected before anything was queued. `error.message` says what to change. A field that failed the schema, or one the endpoint does not take, is also listed in `error.issues`.

- `error` (required, object)
  - `code` (required, string) — `validation_error` for a body that failed validation, `invalid_json` for one that is not JSON. One of: `"validation_error"`, `"invalid_json"`.
  - `message` (required, string) — Every problem, in one sentence each, led by the field it is about.
  - `issues` (object[]) — One entry per field that failed the schema, and one per field the endpoint does not take.
    - `path` (required, (string | integer)[]) — Where the problem is, e.g. `["inputs", 0, "source"]`. Empty for the body as a whole.
    - `message` (required, string)

```json
{
  "error": {
    "code": "validation_error",
    "message": "count: Too big: expected number to be <=20. colour: Unknown field.",
    "issues": [
      {
        "path": [
          "count"
        ],
        "message": "Too big: expected number to be <=20"
      },
      {
        "path": [
          "colour"
        ],
        "message": "Unknown field."
      }
    ]
  }
}
```

## Request samples

### cURL

```bash
curl -X POST https://api.mynth.io/image/rate \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "string"
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/image/rate", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "url": "string"
  }),
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
