Pulse API can transform unstructured document content (like Markdown) into structured JSON output by providing a schema definition in your API request. This allows for precise data extraction tailored to your needs.

Schema Parameter (schema)

The schema parameter uses a simplified format where you directly specify the expected data types for each key. It supports basic types, arrays, and enums without requiring the full OpenAPI 3.0 specification.

Example 1: Transaction Data

{
  "transactions": [
    {
      "date": "date",
      "description": "string",
      "amount": "float",
      "balance": "float",
      "accrued_bank_charges": "float|null"
    }
  ]
}

Example 2: Invoice Data

{
  "name": "string",
  "customer_email": "string",
  "street_address_line_1": "string",
  "street_address_line_2": "string",
  "city": "string",
  "state": "string",
  "zip_code": "string",
  "country": "string",
  "total_price.unit": "USD",
  "revenue_schedule": [
    {
      "service_start_date": "date",
      "service_term": "integer",
      "service_end_date": "date",
      "item_name": "string",
      "item_description": "string|null",
      "integration_item": "string",
      "billing_type": "enum(FLAT_PRICE, PER_UNIT)",
      "total_price": "float",
      "accountingCurrency": "USD",
      "quantity": "integer",
      "start_date": "date",
      "period": "integer",
      "#_of_periods": "integer",
      "frequency_unit": "enum(YEAR, MONTH, DAY)",
      "end_date": "date",
      "net_terms": "integer",
      "arrears": "boolean|null"
    }
  ]
}

(Note: Types like string, float, integer, date, boolean, null, and simple enum(VALUE1, VALUE2) definitions are used directly)

Experimental Schema Parameter (experimental-schema)

The experimental-schema parameter utilizes a subset of the OpenAPI 3.0 specification for more complex schema definitions.

Supported operations:

  • type: (Required) Defines the data type (string, number, integer, boolean, array, object).
  • properties: (Required for object type) Defines key-value pairs within an object, following OpenAPI 3.0 formatting.
  • required: (Optional for object type) An array listing mandatory property keys.
  • items: (Required for array type) Defines the schema for elements within an array, following OpenAPI 3.0 formatting.
  • nullable: (Optional) Boolean (true/false, default false). Allows the value to be null.
  • description: (Optional) A string providing context or use-case for the value.

Example: Condensed Profile Schema

{
  "type": "object",
  "properties": {
    "basics": {
      "type": "object",
      "description": "Basic personal information",
      "properties": {
        "rawName": { "type": "string", "description": "Full name", "nullable": true },
        "email": { "type": "string", "description": "Email address", "nullable": true },
        "phone": { "type": "string", "description": "Phone number", "nullable": true },
        "location": { "type": "string", "description": "Formatted location text", "nullable": true },
        "gender": { 
          "type": "string", 
          "description": "Gender identifier", 
          "enum": ["Male", "Female", "Non-Binary", "Other"],
          "nullable": true
        }
      },
      "required": ["rawName", "email"]
    },
    "experience": {
      "type": "array",
      "description": "List of work experiences",
      "items": {
        "type": "object",
        "properties": {
          "company": { "type": "string", "description": "Company name", "nullable": true },
          "position": { "type": "string", "description": "Job title", "nullable": true },
          "startDate": { "type": "string", "description": "Start date (ISO format)", "format": "date", "nullable": true },
          "endDate": { "type": "string", "description": "End date (ISO format) or null", "format": "date", "nullable": true },
          "description": { "type": "string", "description": "Job details", "nullable": true }
        },
        "required": ["company", "position", "startDate"]
      }
    }
  },
  "required": ["basics", "experience"]
}

Schema Prompting

For both schema types, you can enhance extraction accuracy by providing natural language instructions within the schema’s description fields or as a separate prompt parameter. These prompts guide the model in mapping document content to your schema, handling logical expressions, complex enum mapping, calculations, and other nuanced extraction requirements.