# Classify

## Create Classify Job

`ClassifyCreateResponse classify().create(ClassifyCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/api/v2/classify`

Create a classify job.

Classifies a document against a set of rules. Set `file_input`
to a file ID (`dfl-...`) or parse job ID (`pjb-...`), and provide
either inline `configuration` with rules or a `configuration_id`
referencing a saved preset.

Each rule has a `type` (the label to assign) and a `description`
(natural language criteria). The classifier returns the best
matching rule with a confidence score.

The job runs asynchronously. Poll `GET /classify/{job_id}` to
check status and retrieve results.

### Parameters

- `ClassifyCreateParams params`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

  - `ClassifyCreateRequest classifyCreateRequest`

    Request to create a classify job.

### Returns

- `class ClassifyCreateResponse:`

  Response for a classify job.

  - `String id`

    Unique identifier

  - `ClassifyConfiguration configuration`

    Classify configuration used for this job

    - `List<Rule> rules`

      Classify rules to evaluate against the document (at least one required)

      - `String description`

        Natural language criteria for matching this rule

      - `String type`

        Document type to assign when rule matches

    - `Optional<Mode> mode`

      Classify execution mode

      - `FAST("FAST")`

    - `Optional<ParsingConfiguration> parsingConfiguration`

      Parsing configuration for classify jobs.

      - `Optional<String> lang`

        ISO 639-1 language code for the document

      - `Optional<Long> maxPages`

        Maximum number of pages to process. Omit for no limit.

      - `Optional<String> targetPages`

        Comma-separated page numbers or ranges to process (1-based). Omit to process all pages.

  - `DocumentInputType documentInputType`

    Whether the input was a file or parse job (FILE or PARSE_JOB)

    - `URL("url")`

    - `FILE_ID("file_id")`

    - `PARSE_JOB_ID("parse_job_id")`

  - `String fileInput`

    ID of the input file or parse job

  - `String projectId`

    Project this job belongs to

  - `Status status`

    Current job status: PENDING, RUNNING, COMPLETED, or FAILED

    - `PENDING("PENDING")`

    - `RUNNING("RUNNING")`

    - `COMPLETED("COMPLETED")`

    - `FAILED("FAILED")`

  - `String userId`

    User who created this job

  - `Optional<String> configurationId`

    Product configuration ID

  - `Optional<LocalDateTime> createdAt`

    Creation datetime

  - `Optional<String> errorMessage`

    Error message if job failed

  - `Optional<String> parseJobId`

    Associated parse job ID

  - `Optional<ClassifyResult> result`

    Result of classifying a document.

    - `double confidence`

      Confidence score between 0.0 and 1.0

    - `String reasoning`

      Why the document matched (or didn't match) the returned rule

    - `Optional<String> type`

      Matched rule type, or null if no rule matched

  - `Optional<String> transactionId`

    Idempotency key

  - `Optional<LocalDateTime> updatedAt`

    Update datetime

### Example

```java
package com.llamacloud_prod.api.example;

import com.llamacloud_prod.api.client.LlamaCloudClient;
import com.llamacloud_prod.api.client.okhttp.LlamaCloudOkHttpClient;
import com.llamacloud_prod.api.models.classify.ClassifyCreateParams;
import com.llamacloud_prod.api.models.classify.ClassifyCreateRequest;
import com.llamacloud_prod.api.models.classify.ClassifyCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ClassifyCreateRequest params = ClassifyCreateRequest.builder().build();
        ClassifyCreateResponse classify = client.classify().create(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "configuration": {
    "rules": [
      {
        "description": "contains invoice number, line items, and total amount",
        "type": "invoice"
      }
    ],
    "mode": "FAST",
    "parsing_configuration": {
      "lang": "en",
      "max_pages": 10,
      "target_pages": "1,3,5-7"
    }
  },
  "document_input_type": "url",
  "file_input": "file_input",
  "project_id": "project_id",
  "status": "PENDING",
  "user_id": "user_id",
  "configuration_id": "configuration_id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "error_message": "error_message",
  "parse_job_id": "parse_job_id",
  "result": {
    "confidence": 0,
    "reasoning": "reasoning",
    "type": "type"
  },
  "transaction_id": "transaction_id",
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## List Classify Jobs

`ClassifyListPage classify().list(ClassifyListParamsparams = ClassifyListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/api/v2/classify`

List classify jobs with optional filtering and pagination.

Filter by `status`, `configuration_id`, specific `job_ids`,
or creation date range.

### Parameters

- `ClassifyListParams params`

  - `Optional<String> configurationId`

    Filter by configuration ID

  - `Optional<LocalDateTime> createdAtOnOrAfter`

    Include items created at or after this timestamp (inclusive)

  - `Optional<LocalDateTime> createdAtOnOrBefore`

    Include items created at or before this timestamp (inclusive)

  - `Optional<List<String>> jobIds`

    Filter by specific job IDs

  - `Optional<String> organizationId`

  - `Optional<Long> pageSize`

    Number of items per page

  - `Optional<String> pageToken`

    Token for pagination

  - `Optional<String> projectId`

  - `Optional<Status> status`

    Filter by job status

    - `PENDING("PENDING")`

    - `RUNNING("RUNNING")`

    - `COMPLETED("COMPLETED")`

    - `FAILED("FAILED")`

### Returns

- `class ClassifyListResponse:`

  Response for a classify job.

  - `String id`

    Unique identifier

  - `ClassifyConfiguration configuration`

    Classify configuration used for this job

    - `List<Rule> rules`

      Classify rules to evaluate against the document (at least one required)

      - `String description`

        Natural language criteria for matching this rule

      - `String type`

        Document type to assign when rule matches

    - `Optional<Mode> mode`

      Classify execution mode

      - `FAST("FAST")`

    - `Optional<ParsingConfiguration> parsingConfiguration`

      Parsing configuration for classify jobs.

      - `Optional<String> lang`

        ISO 639-1 language code for the document

      - `Optional<Long> maxPages`

        Maximum number of pages to process. Omit for no limit.

      - `Optional<String> targetPages`

        Comma-separated page numbers or ranges to process (1-based). Omit to process all pages.

  - `DocumentInputType documentInputType`

    Whether the input was a file or parse job (FILE or PARSE_JOB)

    - `URL("url")`

    - `FILE_ID("file_id")`

    - `PARSE_JOB_ID("parse_job_id")`

  - `String fileInput`

    ID of the input file or parse job

  - `String projectId`

    Project this job belongs to

  - `Status status`

    Current job status: PENDING, RUNNING, COMPLETED, or FAILED

    - `PENDING("PENDING")`

    - `RUNNING("RUNNING")`

    - `COMPLETED("COMPLETED")`

    - `FAILED("FAILED")`

  - `String userId`

    User who created this job

  - `Optional<String> configurationId`

    Product configuration ID

  - `Optional<LocalDateTime> createdAt`

    Creation datetime

  - `Optional<String> errorMessage`

    Error message if job failed

  - `Optional<String> parseJobId`

    Associated parse job ID

  - `Optional<ClassifyResult> result`

    Result of classifying a document.

    - `double confidence`

      Confidence score between 0.0 and 1.0

    - `String reasoning`

      Why the document matched (or didn't match) the returned rule

    - `Optional<String> type`

      Matched rule type, or null if no rule matched

  - `Optional<String> transactionId`

    Idempotency key

  - `Optional<LocalDateTime> updatedAt`

    Update datetime

### Example

```java
package com.llamacloud_prod.api.example;

import com.llamacloud_prod.api.client.LlamaCloudClient;
import com.llamacloud_prod.api.client.okhttp.LlamaCloudOkHttpClient;
import com.llamacloud_prod.api.models.classify.ClassifyListPage;
import com.llamacloud_prod.api.models.classify.ClassifyListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ClassifyListPage page = client.classify().list();
    }
}
```

#### Response

```json
{
  "items": [
    {
      "id": "id",
      "configuration": {
        "rules": [
          {
            "description": "contains invoice number, line items, and total amount",
            "type": "invoice"
          }
        ],
        "mode": "FAST",
        "parsing_configuration": {
          "lang": "en",
          "max_pages": 10,
          "target_pages": "1,3,5-7"
        }
      },
      "document_input_type": "url",
      "file_input": "file_input",
      "project_id": "project_id",
      "status": "PENDING",
      "user_id": "user_id",
      "configuration_id": "configuration_id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "error_message": "error_message",
      "parse_job_id": "parse_job_id",
      "result": {
        "confidence": 0,
        "reasoning": "reasoning",
        "type": "type"
      },
      "transaction_id": "transaction_id",
      "updated_at": "2019-12-27T18:11:19.117Z"
    }
  ],
  "next_page_token": "next_page_token",
  "total_size": 0
}
```

## Get Classify Job

`ClassifyGetResponse classify().get(ClassifyGetParamsparams = ClassifyGetParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/api/v2/classify/{job_id}`

Get a classify job by ID.

Returns the job status, configuration, and classify result
when complete. The result includes the matched document type,
confidence score, and reasoning.

### Parameters

- `ClassifyGetParams params`

  - `Optional<String> jobId`

  - `Optional<String> organizationId`

  - `Optional<String> projectId`

### Returns

- `class ClassifyGetResponse:`

  Response for a classify job.

  - `String id`

    Unique identifier

  - `ClassifyConfiguration configuration`

    Classify configuration used for this job

    - `List<Rule> rules`

      Classify rules to evaluate against the document (at least one required)

      - `String description`

        Natural language criteria for matching this rule

      - `String type`

        Document type to assign when rule matches

    - `Optional<Mode> mode`

      Classify execution mode

      - `FAST("FAST")`

    - `Optional<ParsingConfiguration> parsingConfiguration`

      Parsing configuration for classify jobs.

      - `Optional<String> lang`

        ISO 639-1 language code for the document

      - `Optional<Long> maxPages`

        Maximum number of pages to process. Omit for no limit.

      - `Optional<String> targetPages`

        Comma-separated page numbers or ranges to process (1-based). Omit to process all pages.

  - `DocumentInputType documentInputType`

    Whether the input was a file or parse job (FILE or PARSE_JOB)

    - `URL("url")`

    - `FILE_ID("file_id")`

    - `PARSE_JOB_ID("parse_job_id")`

  - `String fileInput`

    ID of the input file or parse job

  - `String projectId`

    Project this job belongs to

  - `Status status`

    Current job status: PENDING, RUNNING, COMPLETED, or FAILED

    - `PENDING("PENDING")`

    - `RUNNING("RUNNING")`

    - `COMPLETED("COMPLETED")`

    - `FAILED("FAILED")`

  - `String userId`

    User who created this job

  - `Optional<String> configurationId`

    Product configuration ID

  - `Optional<LocalDateTime> createdAt`

    Creation datetime

  - `Optional<String> errorMessage`

    Error message if job failed

  - `Optional<String> parseJobId`

    Associated parse job ID

  - `Optional<ClassifyResult> result`

    Result of classifying a document.

    - `double confidence`

      Confidence score between 0.0 and 1.0

    - `String reasoning`

      Why the document matched (or didn't match) the returned rule

    - `Optional<String> type`

      Matched rule type, or null if no rule matched

  - `Optional<String> transactionId`

    Idempotency key

  - `Optional<LocalDateTime> updatedAt`

    Update datetime

### Example

```java
package com.llamacloud_prod.api.example;

import com.llamacloud_prod.api.client.LlamaCloudClient;
import com.llamacloud_prod.api.client.okhttp.LlamaCloudOkHttpClient;
import com.llamacloud_prod.api.models.classify.ClassifyGetParams;
import com.llamacloud_prod.api.models.classify.ClassifyGetResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        LlamaCloudClient client = LlamaCloudOkHttpClient.fromEnv();

        ClassifyGetResponse classify = client.classify().get("job_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "configuration": {
    "rules": [
      {
        "description": "contains invoice number, line items, and total amount",
        "type": "invoice"
      }
    ],
    "mode": "FAST",
    "parsing_configuration": {
      "lang": "en",
      "max_pages": 10,
      "target_pages": "1,3,5-7"
    }
  },
  "document_input_type": "url",
  "file_input": "file_input",
  "project_id": "project_id",
  "status": "PENDING",
  "user_id": "user_id",
  "configuration_id": "configuration_id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "error_message": "error_message",
  "parse_job_id": "parse_job_id",
  "result": {
    "confidence": 0,
    "reasoning": "reasoning",
    "type": "type"
  },
  "transaction_id": "transaction_id",
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Domain Types

### Classify Configuration

- `class ClassifyConfiguration:`

  Configuration for a classify job.

  - `List<Rule> rules`

    Classify rules to evaluate against the document (at least one required)

    - `String description`

      Natural language criteria for matching this rule

    - `String type`

      Document type to assign when rule matches

  - `Optional<Mode> mode`

    Classify execution mode

    - `FAST("FAST")`

  - `Optional<ParsingConfiguration> parsingConfiguration`

    Parsing configuration for classify jobs.

    - `Optional<String> lang`

      ISO 639-1 language code for the document

    - `Optional<Long> maxPages`

      Maximum number of pages to process. Omit for no limit.

    - `Optional<String> targetPages`

      Comma-separated page numbers or ranges to process (1-based). Omit to process all pages.

### Classify Create Request

- `class ClassifyCreateRequest:`

  Request to create a classify job.

  - `Optional<ClassifyConfiguration> configuration`

    Configuration for a classify job.

    - `List<Rule> rules`

      Classify rules to evaluate against the document (at least one required)

      - `String description`

        Natural language criteria for matching this rule

      - `String type`

        Document type to assign when rule matches

    - `Optional<Mode> mode`

      Classify execution mode

      - `FAST("FAST")`

    - `Optional<ParsingConfiguration> parsingConfiguration`

      Parsing configuration for classify jobs.

      - `Optional<String> lang`

        ISO 639-1 language code for the document

      - `Optional<Long> maxPages`

        Maximum number of pages to process. Omit for no limit.

      - `Optional<String> targetPages`

        Comma-separated page numbers or ranges to process (1-based). Omit to process all pages.

  - `Optional<String> configurationId`

    Saved configuration ID

  - `Optional<String> fileId`

    Deprecated: use file_input instead

  - `Optional<String> fileInput`

    File ID or parse job ID to classify

  - `Optional<String> parseJobId`

    Deprecated: use file_input instead

  - `Optional<String> transactionId`

    Idempotency key scoped to the project

  - `Optional<List<WebhookConfiguration>> webhookConfigurations`

    Outbound webhook endpoints to notify on job status changes

    - `Optional<List<WebhookEvent>> webhookEvents`

      Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events are delivered.

      - `EXTRACT_PENDING("extract.pending")`

      - `EXTRACT_SUCCESS("extract.success")`

      - `EXTRACT_ERROR("extract.error")`

      - `EXTRACT_PARTIAL_SUCCESS("extract.partial_success")`

      - `EXTRACT_CANCELLED("extract.cancelled")`

      - `PARSE_PENDING("parse.pending")`

      - `PARSE_RUNNING("parse.running")`

      - `PARSE_SUCCESS("parse.success")`

      - `PARSE_ERROR("parse.error")`

      - `PARSE_PARTIAL_SUCCESS("parse.partial_success")`

      - `PARSE_CANCELLED("parse.cancelled")`

      - `CLASSIFY_PENDING("classify.pending")`

      - `CLASSIFY_RUNNING("classify.running")`

      - `CLASSIFY_SUCCESS("classify.success")`

      - `CLASSIFY_ERROR("classify.error")`

      - `CLASSIFY_PARTIAL_SUCCESS("classify.partial_success")`

      - `CLASSIFY_CANCELLED("classify.cancelled")`

      - `SHEETS_PENDING("sheets.pending")`

      - `SHEETS_SUCCESS("sheets.success")`

      - `SHEETS_ERROR("sheets.error")`

      - `SHEETS_PARTIAL_SUCCESS("sheets.partial_success")`

      - `SHEETS_CANCELLED("sheets.cancelled")`

      - `UNMAPPED_EVENT("unmapped_event")`

    - `Optional<WebhookHeaders> webhookHeaders`

      Custom HTTP headers sent with each webhook request (e.g. auth tokens)

    - `Optional<String> webhookOutputFormat`

      Response format sent to the webhook: 'string' (default) or 'json'

    - `Optional<String> webhookUrl`

      URL to receive webhook POST notifications

### Classify Result

- `class ClassifyResult:`

  Result of classifying a document.

  - `double confidence`

    Confidence score between 0.0 and 1.0

  - `String reasoning`

    Why the document matched (or didn't match) the returned rule

  - `Optional<String> type`

    Matched rule type, or null if no rule matched
