Skip to main content
GET
/
v1
/
usage
/
primitives
from retab import Retab

client = Retab()

# List per-operation usage rows
primitives = client.usage.list_primitives(
    limit=20,
    order="desc",
)

# Filter by operation, project, and date range
primitives = client.usage.list_primitives(
    operation="extraction",
    project_id="proj_123",
    from_date="2024-01-01",
    to_date="2024-12-31",
    limit=50,
)

for primitive in primitives.data:
    print(primitive.primitive_execution_id, primitive.operation, primitive.credits)
import { Retab } from "@retab/node";

const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

// List per-operation usage rows
const primitives = await client.usage.list_primitives({
  limit: 20,
  order: "desc",
});

// Filter by operation, project, and date range
const filtered = await client.usage.list_primitives({
  operation: "extraction",
  projectId: "proj_123",
  fromDate: "2024-01-01",
  toDate: "2024-12-31",
  limit: 50,
});

console.log(primitives.data, filtered.data);
package main

import (
	"context"
	"fmt"
	"log"

	retab "github.com/retab-dev/retab/clients/go"
)

func ptr[T any](v T) *T { return &v }

func main() {
	ctx := context.Background()

	client, err := retab.NewClient("")
	if err != nil {
		log.Fatal(err)
	}

	// List per-operation usage rows
	primitives, err := client.Usage.ListPrimitives(ctx, &retab.UsageListPrimitivesParams{
		PaginationParams: retab.PaginationParams{Limit: ptr(20), Order: ptr("desc")},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(primitives)

	// Filter by operation, project, and date range
	filtered, err := client.Usage.ListPrimitives(ctx, &retab.UsageListPrimitivesParams{
		PaginationParams: retab.PaginationParams{Limit: ptr(50)},
		Operation:        ptr("extraction"),
		ProjectID:        ptr("proj_123"),
		FromDate:         ptr("2024-01-01"),
		ToDate:           ptr("2024-12-31"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(filtered)
}
import com.retab.RetabClient;

public final class Example {
  public static void main(String[] args) throws Exception {
    RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

    var primitives = client.usage().listPrimitives();
    System.out.println(primitives);
  }
}
curl -X 'GET' \
  'https://api.retab.com/v1/usage/primitives?limit=20&order=desc' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <your-api-key>'

# Filter by operation, project, and date range
curl -X 'GET' \
  'https://api.retab.com/v1/usage/primitives?operation=extraction&project_id=proj_123&from_date=2024-01-01&to_date=2024-12-31&limit=50' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <your-api-key>'
{
  "data": [
    {
      "primitive_execution_id": "pex_01G34H8J2K",
      "operation": "extraction",
      "workflow_id": "wf_123",
      "run_id": "run_01G34H8J2K",
      "project_id": "proj_123",
      "block_id": "blk_01G34H8J2K",
      "status": "completed",
      "resource_kind": "extraction",
      "model": "retab-large",
      "created_at": "2024-03-15T10:30:00Z",
      "completed_at": "2024-03-15T10:30:12Z",
      "duration_ms": 12000,
      "page_count": 8,
      "credits": 12.5,
      "documents": [
        {
          "file_id": "file_6dd6eb00688ad8d1",
          "filename": "invoice.pdf"
        }
      ],
      "metadata": {
        "tenant": "acme"
      }
    }
  ],
  "list_metadata": {
    "before": null,
    "after": "pex_01G34H8J2K"
  }
}
from retab import Retab

client = Retab()

# List per-operation usage rows
primitives = client.usage.list_primitives(
    limit=20,
    order="desc",
)

# Filter by operation, project, and date range
primitives = client.usage.list_primitives(
    operation="extraction",
    project_id="proj_123",
    from_date="2024-01-01",
    to_date="2024-12-31",
    limit=50,
)

for primitive in primitives.data:
    print(primitive.primitive_execution_id, primitive.operation, primitive.credits)
import { Retab } from "@retab/node";

const client = new Retab({ apiKey: process.env.RETAB_API_KEY });

// List per-operation usage rows
const primitives = await client.usage.list_primitives({
  limit: 20,
  order: "desc",
});

// Filter by operation, project, and date range
const filtered = await client.usage.list_primitives({
  operation: "extraction",
  projectId: "proj_123",
  fromDate: "2024-01-01",
  toDate: "2024-12-31",
  limit: 50,
});

console.log(primitives.data, filtered.data);
package main

import (
	"context"
	"fmt"
	"log"

	retab "github.com/retab-dev/retab/clients/go"
)

func ptr[T any](v T) *T { return &v }

func main() {
	ctx := context.Background()

	client, err := retab.NewClient("")
	if err != nil {
		log.Fatal(err)
	}

	// List per-operation usage rows
	primitives, err := client.Usage.ListPrimitives(ctx, &retab.UsageListPrimitivesParams{
		PaginationParams: retab.PaginationParams{Limit: ptr(20), Order: ptr("desc")},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(primitives)

	// Filter by operation, project, and date range
	filtered, err := client.Usage.ListPrimitives(ctx, &retab.UsageListPrimitivesParams{
		PaginationParams: retab.PaginationParams{Limit: ptr(50)},
		Operation:        ptr("extraction"),
		ProjectID:        ptr("proj_123"),
		FromDate:         ptr("2024-01-01"),
		ToDate:           ptr("2024-12-31"),
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(filtered)
}
import com.retab.RetabClient;

public final class Example {
  public static void main(String[] args) throws Exception {
    RetabClient client = new RetabClient(System.getenv("RETAB_API_KEY"));

    var primitives = client.usage().listPrimitives();
    System.out.println(primitives);
  }
}
curl -X 'GET' \
  'https://api.retab.com/v1/usage/primitives?limit=20&order=desc' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <your-api-key>'

# Filter by operation, project, and date range
curl -X 'GET' \
  'https://api.retab.com/v1/usage/primitives?operation=extraction&project_id=proj_123&from_date=2024-01-01&to_date=2024-12-31&limit=50' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <your-api-key>'
{
  "data": [
    {
      "primitive_execution_id": "pex_01G34H8J2K",
      "operation": "extraction",
      "workflow_id": "wf_123",
      "run_id": "run_01G34H8J2K",
      "project_id": "proj_123",
      "block_id": "blk_01G34H8J2K",
      "status": "completed",
      "resource_kind": "extraction",
      "model": "retab-large",
      "created_at": "2024-03-15T10:30:00Z",
      "completed_at": "2024-03-15T10:30:12Z",
      "duration_ms": 12000,
      "page_count": 8,
      "credits": 12.5,
      "documents": [
        {
          "file_id": "file_6dd6eb00688ad8d1",
          "filename": "invoice.pdf"
        }
      ],
      "metadata": {
        "tenant": "acme"
      }
    }
  ],
  "list_metadata": {
    "before": null,
    "after": "pex_01G34H8J2K"
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

limit
integer
default:20

Maximum number of execution rows to return.

Required range: 1 <= x <= 100
order
enum<string>
default:desc

Sort direction on execution created_at.

Available options:
asc,
desc
before
string | null

Return executions before this primitive-execution id (keyset cursor).

after
string | null

Return executions after this primitive-execution id (keyset cursor).

environment_id
string | null

Scope the export to this environment id within the caller's organization. Defaults to the authenticated identity's environment.

workflow_id
string | null

Filter to a single workflow id (origin workflow).

project_id
string | null

Filter to executions owned by a single project id.

run_id
string | null

Filter to a single workflow run id (origin run).

block_id
string | null

Filter to a single workflow block id (origin block).

operation
string | null

Filter by operation (extraction, classify, split, parse, edit, schema_generation).

status
string | null

Filter by execution lifecycle status.

metadata
string | null

Filter by metadata equality: a JSON object of string key/value pairs (e.g. {"tenant":"acme"}). Pairs AND together.

from_date
string | null

Inclusive created_at lower bound (YYYY-MM-DD, UTC).

to_date
string | null

Inclusive created_at upper bound (YYYY-MM-DD, UTC).

Response

Successful Response

data
UsagePrimitiveRecord · object[]
required
list_metadata
ListMetadata · object
required

Boundary resource IDs for page navigation.