Examples

Examples and workflows for using the Kognitos REST API v2.

1. Check Health

Check the health and availability of the REST API v2.

curl -X GET "https://rest-api.app.kognitos.com/v2/health" \
    -H "x-api-key: YOUR_API_KEY"

2. List Processes

List all processes in a specified agent.

curl -X GET "https://rest-api.app.kognitos.com/v2/processes?agent_id=YOUR_AGENT_ID&limit=10" \
  -H "x-api-key: YOUR_API_KEY"

3. Get a Specific Process

Get details for a specific process by ID.

curl -X GET "https://rest-api.app.kognitos.com/v2/processes/YOUR_PROCESS_ID?agent_id=YOUR_AGENT_ID" \
  -H "x-api-key: YOUR_API_KEY"

4. List Runs

List all runs for a specific process and agent.

curl -X GET "https://rest-api.app.kognitos.com/v2/runs?process_id=YOUR_PROCESS_ID&agent_id=YOUR_AGENT_ID&limit=10" \
  -H "x-api-key: YOUR_API_KEY"

5. Get a Specific Run

Get the status and details of a specific run.

curl -X GET "https://rest-api.app.kognitos.com/v2/runs/YOUR_RUN_ID" \
  -H "x-api-key: YOUR_API_KEY"

6. Start a New Run

Trigger a new process run (without a file upload). The request body must be sent as JSON with the following fields:

Required Fields

Field
Description

name

The process name (e.g., "to process the invoices")

process_id

The unique identifier of the process you want to execute.

agent_id

The unique identifier of the agent that will execute the process.

stage

The version of the process to run. Use "Published" for production processes or "Draft" for testing processes still in development.

Optional Fields

Field
Description

inputs

An array of input parameters to pass to your process. Each input is an object with name (the name of the data element/fact as defined in your process) and value (the actual value for that data element/fact).

file_ids

An array of file IDs for the run.

curl -X POST "https://rest-api.app.kognitos.com/v2/runs" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "to process the invoices",
    "process_id": "b4fznghynbdemslfd5k044fgd",
    "agent_id": "a7xm2kp9qwj3v5nh8t4c6r1e9z",
    "stage": "Published",
    "inputs": [
        {
            "name": "invoice number", 
            "value": "INV-2024-001"
        },
        {
            "name": "customer id",
            "value": "CUST-12345" 
        },
        {
            "name": "amount",
            "value": "1500.00"
        }
    ]
  }'

7. Start a New Run (with File Upload)

Trigger a new process run with an uploaded file. This is a 3-step process.

Step 1

First, make a POST request to /v2/files to get an upload URL.

The request body must be sent as JSON with two required fields:

  • file_name: The name of your file

  • agent_id: Your agent ID

curl -X POST "https://rest-api.app.kognitos.com/v2/files" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "document.pdf",
    "agent_id": "YOUR_AGENT_ID"
  }'

Step 2

Next, make a POST request to the upload_url from the response in Step 1.

The request body must be sent as form data (multipart/form-data) and should include all the upload_fields (key, AWSAccessKeyId, x-amz-security-token, policy, signature, Content-Type) from the response in Step 1, plus the file to be uploaded.

curl -X POST "https://example.com/file.pdf" \
  -F "key=path/to/file.pdf" \
  -F "AWSAccessKeyId=AKIAIOSFODNN7EXAMPLE" \
  -F "x-amz-security-token=IQoJb3JpZ2luX2VjELv//////////..." \
  -F "policy=eyJ...base64_policy..." \
  -F "signature=abc123..." \
  -F "Content-Type=application/pdf" \
  -F "[email protected]"

Step 3

Finally, make a POST request to /v2/runs to start a new run.

In your request body, add the id (from the response in Step 1) to the file_ids array.

curl -X POST "https://rest-api.app.kognitos.com/v2/runs" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Process invoice with document",
    "process_id": "YOUR_PROCESS_ID",
    "agent_id": "YOUR_AGENT_ID",
    "stage": "Published",
    "file_ids": ["s3://bucket/path/to/uploaded-file.pdf"]
  }'

Refer to Example 6 for more details on optional and required fields for this request.

Notes

  1. Authentication: All requests require an API key. Include your key in the x-api-key header.

  2. Base URLs: All examples use the US region base URL: https://rest-api.app.kognitos.com. If you're in a different region, adjust the base URL accordingly:

    1. UK: https://rest-api.uk.kognitos.com

    2. EU: https://rest-api.eu.kognitos.com

  3. Placeholders: Replace placeholder values in the requests with your actual values:

    1. YOUR_API_KEY: Your API key secret

    2. YOUR_AGENT_ID: Your agent ID

    3. YOUR_PROCESS_ID: Your process ID

    4. YOUR_RUN_ID: Your run ID

Last updated

Was this helpful?