# AI token fraud (/score-api/endpoints/ai-token-fraud)



{/* Written by scripts/build-use-cases.mjs from internal/usecases/catalog.json and use-cases/site.json. Change those, not this file. */}

**Stop paying for tokens that fraudsters use.** Free credits, stolen cards and leaked keys all end up as compute you pay for. Send the sign-up, top-up or jump in usage, and get a score before you grant the credits.

| Endpoint                        | Price           | Group          |
| ------------------------------- | --------------- | -------------- |
| `POST /v1/score/ai_token_fraud` | $0.002 per call | Policy & Abuse |

## Request [#request]

Send what you know in one `context` object. `activity` is required; every other field is optional. A field can hold text, JSON or CSV.

<Tabs items="[&#x22;curl&#x22;, &#x22;Python&#x22;, &#x22;TypeScript&#x22;]">
  <Tab value="curl">
    ```bash
    curl https://api.finic.ai/v1/score/ai_token_fraud \
      --header "Authorization: Bearer $FINIC_API_KEY" \
      --header "Content-Type: application/json" \
      --data '{
        "context": {
          "activity": [
            { "at": "2026-11-25T09:00:02Z", "type": "signup" },
            { "at": "2026-11-25T09:04:10Z", "type": "credit_purchase", "amount_usd": 2000 },
            { "at": "2026-11-25T09:05:47Z", "type": "api_keys_created", "count": 12 }
          ],
          "account": { "email_domain_registered": "2026-11-24", "lifetime_spend_usd": 0 },
          "payment_method": { "brand": "mastercard", "issuer_country": "BR", "billing_zip_match": false },
          "usage": "hour,requests,distinct_ips\n01:00,18200,58\n02:00,17900,61\n03:00,18400,60",
          "device": { "fingerprint": "fp_9c41e0", "accounts_with_free_credits": 9 }
        }
      }'
    ```
  </Tab>

  <Tab value="Python">
    ```python
    import os
    import requests

    response = requests.post(
        "https://api.finic.ai/v1/score/ai_token_fraud",
        headers={"Authorization": f"Bearer {os.environ['FINIC_API_KEY']}"},
        json={
            "context": {
                "activity": [
                  { "at": "2026-11-25T09:00:02Z", "type": "signup" },
                  { "at": "2026-11-25T09:04:10Z", "type": "credit_purchase", "amount_usd": 2000 },
                  { "at": "2026-11-25T09:05:47Z", "type": "api_keys_created", "count": 12 }
                ],
                "account": { "email_domain_registered": "2026-11-24", "lifetime_spend_usd": 0 },
                "payment_method": { "brand": "mastercard", "issuer_country": "BR", "billing_zip_match": False },
                "usage": "hour,requests,distinct_ips\n01:00,18200,58\n02:00,17900,61\n03:00,18400,60",
                "device": { "fingerprint": "fp_9c41e0", "accounts_with_free_credits": 9 }
            }
        },
        timeout=30,
    )
    response.raise_for_status()
    print(response.json()["score"])
    ```
  </Tab>

  <Tab value="TypeScript">
    ```ts
    const response = await fetch("https://api.finic.ai/v1/score/ai_token_fraud", {
      method: "POST",
      headers: {
        Authorization: `Bearer ${process.env.FINIC_API_KEY}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        context: {
          "activity": [
            { "at": "2026-11-25T09:00:02Z", "type": "signup" },
            { "at": "2026-11-25T09:04:10Z", "type": "credit_purchase", "amount_usd": 2000 },
            { "at": "2026-11-25T09:05:47Z", "type": "api_keys_created", "count": 12 }
          ],
          "account": { "email_domain_registered": "2026-11-24", "lifetime_spend_usd": 0 },
          "payment_method": { "brand": "mastercard", "issuer_country": "BR", "billing_zip_match": false },
          "usage": "hour,requests,distinct_ips\n01:00,18200,58\n02:00,17900,61\n03:00,18400,60",
          "device": { "fingerprint": "fp_9c41e0", "accounts_with_free_credits": 9 }
        },
      }),
    });
    const { score, questions } = await response.json();
    ```
  </Tab>
</Tabs>

## Fields you send [#fields-you-send]

Send the details, not only an ID: an account ID tells the score nothing, but the account's age, profile and history do. Fields that are not in this list are also read.

| Field            |          | Description                                                                                                                       |
| ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `activity`       | Required | The sign-up, top-up or usage you want scored: the events, with amounts and timestamps.                                            |
| `account`        | Optional | A description of the account, not an account ID: its age, its email domain, its plan and what it has spent.                       |
| `payment_method` | Optional | A description of the card or payment method: its type, where it was issued, and whether its details agree. Never the card number. |
| `usage`          | Optional | How the account's keys are used: the volume, the networks the requests come from, and the hours.                                  |
| `device`         | Optional | A description of the device: its fingerprint traits, and the other accounts seen on it.                                           |
| `ip`             | Optional | The IP address with what your lookup says about it: country, city and network type. An address by itself says little.             |
| `other_context`  | Optional | Any other information, structured or unstructured, that is useful for scoring.                                                    |

## Response [#response]

`score` runs from 0, the lowest risk, to 1000, the highest. `questions` are the yes/no questions behind it, each with the probability that the answer is yes.

```json title="200 OK"
{
  "score": 941,
  "questions": [
    {
      "text": "Is a new account spending far more than new accounts usually do?",
      "probability": 0.95
    },
    {
      "text": "Is the same device behind several accounts that claimed free credits?",
      "probability": 0.94
    },
    {
      "text": "Do the card's details disagree with each other?",
      "probability": 0.89
    },
    {
      "text": "Does the usage look like access being resold?",
      "probability": 0.87
    }
  ],
  "request_id": "req_01M4YF1068X8B4C458ENPD4JHT"
}
```

## The questions behind the score [#the-questions-behind-the-score]

1. Is a new account spending far more than new accounts usually do?
2. Is the same device behind several accounts that claimed free credits?
3. Do the card's details disagree with each other?
4. Does the usage look like access being resold?

Every organization gets the same questions for this score. To use your own questions, or to calibrate a score to your own outcomes, copy it to a [custom scoring model](/score-model) in the Finic app (Starter plan and above).

## Turn the score into an action [#turn-the-score-into-an-action]

These thresholds are examples. Choose your own, and change them as you learn.

| Score       | Action  | Example                                  |
| ----------- | ------- | ---------------------------------------- |
| Under 300   | Approve | Grant the credits or serve the request.  |
| 300 to 599  | Step up | Ask for a card or a phone number.        |
| 600 to 849  | Review  | Limit usage and hold for an analyst.     |
| 850 or more | Block   | Suspend the account and revoke its keys. |

## Errors [#errors]

| Status | `type`                 | When                                                                                                            |
| ------ | ---------------------- | --------------------------------------------------------------------------------------------------------------- |
| 400    | `invalid_request`      | `context` is missing, is not a JSON object, or a required field (`activity`) is empty. `param` names the field. |
| 401    | `authentication_error` | The API key is missing or not valid.                                                                            |
| 402    | `insufficient_credit`  | The organization has no credit. Add credit in the Finic app.                                                    |
| 429    | `rate_limited`         | Too many requests. Retry with exponential backoff.                                                              |

See the [API reference](/reference) for every error and limit, and [Pricing](/pricing) for what a call costs.
