Skip to Content
Docs are evolving — expect frequent updates.
CompanyChange Criteria

Change Criteria

Set or update the scoring criteria values for a company report. This endpoint allows you to assign specific criteria selections that affect the company report’s scoring and analysis results.

Endpoint

POST https://api.kruncher.ai/api/integration/project/criteria

Headers

HeaderRequiredDescription
AuthorizationYesYour API key (format: YOUR_API_KEY)
Content-TypeYesapplication/json

Request Body

FieldTypeRequiredDescription
projectIdstring (UUID)YesThe unique identifier for the project
projectscoreIdstring (UUID)YesThe unique identifier for the project’s score
postanalysisoutputIdstring (UUID)YesThe unique identifier for the post-analysis output
criteriaSelectedCodestringYesCode representing the selected criteria (e.g., advertisingandmarketing)
criteriaSelectedNamestringYesDisplay name of the selected criteria (e.g., Advertising & Marketing)

Use Cases

  • Adjust Scoring Criteria: Change how projects are scored based on investment focus
  • Update Investment Thesis: Reflect changes in investment strategy and priorities
  • Multi-factor Analysis: Set different criteria for different project types
  • Risk Assessment: Adjust criteria to focus on specific risk factors
  • Portfolio Alignment: Update criteria to match portfolio company profiles

Quick Start

cURL

CODE
curl -X POST "https://api.kruncher.ai/api/integration/project/criteria" \
  -H "Authorization: YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "projectId": "521a93a6-091d-4943-ba13-7c1a654a14ae",
    "projectscoreId": "7c904e6a-e797-4b5b-8c28-feaf34b5ac75",
    "postanalysisoutputId": "8756d0e9-8398-47ba-8d0e-f88ab53c38f3",
    "criteriaSelectedCode": "advertisingandmarketing",
    "criteriaSelectedName": "Advertising & Marketing"
  }'

Response:

CODE
{
  "success": true,
  "data": {
    "projectId": "521a93a6-091d-4943-ba13-7c1a654a14ae",
    "criteriaCode": "advertisingandmarketing",
    "criteriaName": "Advertising & Marketing",
    "updatedAt": "2024-01-15T10:30:00Z",
    "scoreUpdated": true
  }
}

Code Examples

JavaScript/TypeScript

CODE
const API_KEY = "YOUR_API_KEY_HERE";
const BASE_URL = "https://api.kruncher.ai/api";
 
async function setProjectCriteria(
  projectId,
  projectscoreId,
  postanalysisoutputId,
  criteriaCode,
  criteriaName
) {
  const response = await fetch(`${BASE_URL}/integration/project/criteria`, {
    method: "POST",
    headers: {
      "Authorization": `${API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      projectId,
      projectscoreId,
      postanalysisoutputId,
      criteriaSelectedCode: criteriaCode,
      criteriaSelectedName: criteriaName
    })
  });
 
  if (!response.ok) {
    throw new Error(`Failed to set criteria: ${response.statusText}`);
  }
 
  return await response.json();
}
 
// Usage
const result = await setProjectCriteria(
  "521a93a6-091d-4943-ba13-7c1a654a14ae",
  "7c904e6a-e797-4b5b-8c28-feaf34b5ac75",
  "8756d0e9-8398-47ba-8d0e-f88ab53c38f3",
  "advertisingandmarketing",
  "Advertising & Marketing"
);
 
console.log("Criteria updated:", result.data.criteriaName);

Result: Basic criteria update.

Python

CODE
import requests
from typing import Dict
 
API_KEY = "YOUR_API_KEY_HERE"
BASE_URL = "https://api.kruncher.ai/api"
 
def set_project_criteria(
    project_id: str,
    projectscore_id: str,
    postanalysisoutput_id: str,
    criteria_code: str,
    criteria_name: str
) -> Dict:
    """Set criteria for a project."""
    url = f"{BASE_URL}/integration/project/criteria"
    
    headers = {
        "Authorization": f"{API_KEY}",
        "Content-Type": "application/json"
    }
    
    payload = {
        "projectId": project_id,
        "projectscoreId": projectscore_id,
        "postanalysisoutputId": postanalysisoutput_id,
        "criteriaSelectedCode": criteria_code,
        "criteriaSelectedName": criteria_name
    }
    
    response = requests.post(url, json=payload, headers=headers)
    response.raise_for_status()
    
    return response.json()
 
# Usage
result = set_project_criteria(
    "521a93a6-091d-4943-ba13-7c1a654a14ae",
    "7c904e6a-e797-4b5b-8c28-feaf34b5ac75",
    "8756d0e9-8398-47ba-8d0e-f88ab53c38f3",
    "advertisingandmarketing",
    "Advertising & Marketing"
)
 
print(f"Criteria updated: {result['data']['criteriaName']}")

Result: Basic criteria update.

Response Structure

Success Response (200 OK)

CODE
{
  "success": true,
  "data": {
    "projectId": "521a93a6-091d-4943-ba13-7c1a654a14ae",
    "criteriaCode": "advertisingandmarketing",
    "criteriaName": "Advertising & Marketing",
    "updatedAt": "2024-01-15T10:30:00Z",
    "scoreUpdated": true
  }
}

Response Fields

FieldTypeDescription
projectIdstringThe project UUID
criteriaCodestringCode of the selected criteria
criteriaNamestringDisplay name of the criteria
updatedAtstringISO 8601 timestamp when updated
scoreUpdatedbooleanWhether project score was recalculated

Error Responses

400 Bad Request - Missing/Invalid Fields

CODE
{
  "success": false,
  "error": "projectscoreId is required"
}

404 Not Found - Project/Score Not Found

CODE
{
  "success": false,
  "error": "Project or score not found"
}

Common Criteria Codes

CodeDisplay Name
advertisingandmarketingAdvertising & Marketing
softwareandtechSoftware & Technology
ecommerceE-Commerce
financialservicesFinancial Services
healthcareandlifesciencesHealthcare & Life Sciences
manufacturingandlogisticsManufacturing & Logistics
realestateReal Estate
telecomTelecommunications

Common Patterns

Pattern 1: Update Based on Company Profile

CODE
async function updateCriteriaByProfile(projectId, companyProfile) {
  // Map profile to appropriate criteria
  const criteriaMap = {
    "tech_startup": { code: "softwareandtech", name: "Software & Technology" },
    "ecommerce": { code: "ecommerce", name: "E-Commerce" },
    "healthcare": { code: "healthcareandlifesciences", name: "Healthcare & Life Sciences" },
    "financial": { code: "financialservices", name: "Financial Services" }
  };
 
  const criteria = criteriaMap[companyProfile.type];
  
  if (!criteria) {
    throw new Error(`Unknown profile type: ${companyProfile.type}`);
  }
 
  return await setProjectCriteria(
    projectId,
    companyProfile.projectscoreId,
    companyProfile.postanalysisoutputId,
    criteria.code,
    criteria.name
  );
}

Pattern 2: Bulk Criteria Update

CODE
def update_criteria_for_portfolio(portfolio_projects: List[Dict]):
    """Update criteria for entire portfolio."""
    manager = CriteriaManager()
    
    # Group by investment thesis
    by_thesis = {}
    for project in portfolio_projects:
        thesis = project['investment_thesis']
        if thesis not in by_thesis:
            by_thesis[thesis] = []
        by_thesis[thesis].append(project)
    
    all_results = []
    
    for thesis, projects in by_thesis.items():
        criteria = map_thesis_to_criteria(thesis)
        
        projects_with_criteria = [
            {
                **p,
                'criteriaCode': criteria['code'],
                'criteriaName': criteria['name']
            }
            for p in projects
        ]
        
        results = manager.update_criteria_batch(projects_with_criteria)
        all_results.append(results)
    
    return all_results

Pattern 3: Criteria Update on Status Change

CODE
async function updateCriteriaOnStatusChange(projectId, newStatus) {
  // Update criteria based on new status
  const statusCriteriaMap = {
    "screening": "advertisingandmarketing",
    "diligence": "softwareandtech",
    "invested": "financialservices"
  };
 
  const criteriaCode = statusCriteriaMap[newStatus];
  
  if (!criteriaCode) {
    console.warn(`No criteria mapping for status: ${newStatus}`);
    return;
  }
 
  try {
    const result = await setProjectCriteria(
      projectId,
      projectDetails.projectscoreId,
      projectDetails.postanalysisoutputId,
      criteriaCode,
      getCriteriaName(criteriaCode)
    );
    
    console.log(`Updated criteria for ${newStatus}: ${result.data.criteriaName}`);
  } catch (error) {
    console.error(`Failed to update criteria: ${error.message}`);
  }
}

Best Practices

Before Updating

  • Verify all UUID fields are correct format
  • Ensure project and score exist
  • Validate criteria code matches your system
  • Check investment thesis alignment

ID Management

  • Store projectscoreId and postanalysisoutputId together
  • Consider caching these values per project
  • Validate UUIDs before making requests

Batch Operations

  • Update in logical groups (by thesis, by stage, etc.)
  • Add delays between requests to respect rate limits
  • Log all changes for audit trail
  • Handle partial failures gracefully

Error Recovery

  • Retry failed updates
  • Log projects that couldn’t be updated
  • Alert on validation errors
  • Maintain fallback criteria

Error Handling

Handling Missing IDs

CODE
async function setProjectCriteriaWithFallback(
  projectId,
  criteriaCode,
  criteriaName,
  getProjectDetails
) {
  try {
    const details = await getProjectDetails(projectId);
    
    return await setProjectCriteria(
      projectId,
      details.projectscoreId,
      details.postanalysisoutputId,
      criteriaCode,
      criteriaName
    );
  } catch (error) {
    console.error(`Cannot update criteria - missing project details: ${error}`);
    throw error;
  }
}

Validating Before Update

CODE
def validate_and_update_criteria(
    project_id: str,
    projectscore_id: str,
    postanalysisoutput_id: str,
    criteria_code: str,
    criteria_name: str
) -> bool:
    """Validate all fields before updating."""
    
    # Validate UUIDs
    import re
    uuid_pattern = r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
    
    for uuid_val in [project_id, projectscore_id, postanalysisoutput_id]:
        if not re.match(uuid_pattern, uuid_val, re.IGNORECASE):
            print(f"Invalid UUID: {uuid_val}")
            return False
    
    # Validate criteria
    valid_codes = [
        "advertisingandmarketing", "softwareandtech", "ecommerce",
        "financialservices", "healthcareandlifesciences"
    ]
    
    if criteria_code not in valid_codes:
        print(f"Invalid criteria code: {criteria_code}")
        return False
    
    # Proceed with update
    try:
        set_project_criteria(
            project_id, projectscore_id, postanalysisoutput_id,
            criteria_code, criteria_name
        )
        return True
    except Exception as e:
        print(f"Update failed: {e}")
        return False

Troubleshooting

”Project not found” Error

  • Verify projectId is correct UUID format
  • Check project hasn’t been deleted
  • Confirm project exists in your environment

”Invalid criteria code” Error

  • Verify criteria code spelling (lowercase)
  • Check code is in supported list
  • Ensure criteria code matches your investment thesis

Score Not Updating

  • Verify scoreUpdated field in response
  • Check if criteria actually affects scoring
  • Review scoring configuration

Batch Updates Failing Partially

  • Check which projects have required IDs
  • Validate UUID formats for all records
  • Review failed items in error report

Need Help?

  • Finding project IDs? Use Get Project Details
  • Bulk updates? Use the CriteriaManager class for batch operations
  • Need lookup assistance? Implement the auto-lookup pattern with project details
Last updated on